@@ -4403,6 +4403,8 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
44034403 }
44044404 m_scene->film ->cryptomatte_passes = cryptoPasses;
44054405
4406+ bool cryptoAsset, cryptoObject, cryptoMaterial = false ;
4407+
44064408 for ( auto &coutput : m_outputs )
44074409 {
44084410 if ( coutput.second ->m_passType == ccl::PASS_COMBINED )
@@ -4413,26 +4415,19 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
44134415 {
44144416 if ( coutput.second ->m_data == " cryptomatte_asset" )
44154417 {
4418+ cryptoAsset = true ;
44164419 m_scene->film ->cryptomatte_passes = (ccl::CryptomatteType)( m_scene->film ->cryptomatte_passes | ccl::CRYPT_ASSET );
44174420 }
44184421 else if ( coutput.second ->m_data == " cryptomatte_object" )
44194422 {
4423+ cryptoObject = true ;
44204424 m_scene->film ->cryptomatte_passes = (ccl::CryptomatteType)( m_scene->film ->cryptomatte_passes | ccl::CRYPT_OBJECT );
44214425 }
44224426 else if ( coutput.second ->m_data == " cryptomatte_material" )
44234427 {
4428+ cryptoMaterial = true ;
44244429 m_scene->film ->cryptomatte_passes = (ccl::CryptomatteType)( m_scene->film ->cryptomatte_passes | ccl::CRYPT_MATERIAL );
44254430 }
4426- else
4427- {
4428- continue ;
4429- }
4430-
4431- for ( int i = 0 ; i < m_scene->film ->cryptomatte_depth ; ++i )
4432- {
4433- string cryptoFullName = ( boost::format ( " %s%02i" ) % coutput.second ->m_data % i ).str ();
4434- ccl::Pass::add ( ccl::PASS_CRYPTOMATTE, m_bufferParamsModified.passes , cryptoFullName.c_str () );
4435- }
44364431 continue ;
44374432 }
44384433 else if (
@@ -4467,6 +4462,29 @@ class CyclesRenderer final : public IECoreScenePreview::Renderer
44674462 }
44684463 }
44694464
4465+ // Order of adding these matters, hence why it was deferred to here
4466+ if ( cryptoObject )
4467+ {
4468+ for ( int i = 0 ; i < m_scene->film ->cryptomatte_depth ; ++i )
4469+ {
4470+ ccl::Pass::add ( ccl::PASS_CRYPTOMATTE, m_bufferParamsModified.passes , ccl::string_printf (" cryptomatte_object%02d" , i).c_str () );
4471+ }
4472+ }
4473+ if ( cryptoMaterial )
4474+ {
4475+ for ( int i = 0 ; i < m_scene->film ->cryptomatte_depth ; ++i )
4476+ {
4477+ ccl::Pass::add ( ccl::PASS_CRYPTOMATTE, m_bufferParamsModified.passes , ccl::string_printf (" cryptomatte_material%02d" , i).c_str () );
4478+ }
4479+ }
4480+ if ( cryptoAsset )
4481+ {
4482+ for ( int i = 0 ; i < m_scene->film ->cryptomatte_depth ; ++i )
4483+ {
4484+ ccl::Pass::add ( ccl::PASS_CRYPTOMATTE, m_bufferParamsModified.passes , ccl::string_printf (" cryptomatte_asset%02d" , i).c_str () );
4485+ }
4486+ }
4487+
44704488 // Adaptive
44714489 if ( m_sessionParams.adaptive_sampling )
44724490 {
0 commit comments