Skip to content

Commit c1f1a3b

Browse files
committed
Lightgroups fixup + make sure to save the right channels out for the OIIO backend.
1 parent eb1a4b5 commit c1f1a3b

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/GafferCycles/IECoreCyclesPreview/Renderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class CyclesOutput : public IECore::RefCounted
319319
{
320320
p["name"] = m_denoise ? new StringData( ccl::string_printf( "%s_denoised", tokens[1].c_str() ) ) : new StringData( tokens[1] );
321321
p["type"] = new StringData( "lightgroup" );
322-
passType = "lightgroup";
322+
passType = "combined";
323323
m_data = tokens[1];
324324
m_lightgroup = true;
325325
}

src/GafferCycles/IECoreCyclesPreview/outputDriver/IEDisplayOutputDriver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ IEDisplayOutputDriver::IEDisplayOutputDriver( const Imath::Box2i &displayWindow,
106106

107107
const IECore::StringData *passTypeData = layerData->member<IECore::StringData>( "type", true );
108108
ccl::ustring passType( passTypeData->readable() );
109-
if( typeEnum.exists( passType ) )
109+
if( passType == ccl::ustring( "lightgroup" ) )
110+
{
111+
layer.numChannels = 3;
112+
}
113+
else if( typeEnum.exists( passType ) )
110114
{
111115
ccl::PassInfo passInfo = ccl::Pass::get_info( static_cast<ccl::PassType>( typeEnum[passType] ) );
112116
layer.numChannels = passInfo.num_components;

src/GafferCycles/IECoreCyclesPreview/outputDriver/OIIOOutputDriver.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ void applyCryptomatteMetadata( OIIO::ImageSpec &spec, std::string name, IECore::
8585
spec.attribute( prefix + "manifest", cryptomatte->member<IECore::StringData>( prefix + "manifest", true )->readable() );
8686
}
8787

88+
std::array<IECore::InternedString, 4> g_channels = { { "R", "G", "B", "A" } };
89+
8890
} // namespace
8991

9092
namespace IECoreCycles
@@ -109,7 +111,12 @@ OIIOOutputDriver::OIIOOutputDriver( const Imath::Box2i &displayWindow, const Ima
109111
const IECore::StringData *passTypeData = layerData->member<IECore::StringData>( "type", true );
110112
ccl::ustring passType( passTypeData->readable() );
111113
layer.passType = ccl::PASS_NONE;
112-
if( typeEnum.exists( passType ) )
114+
if( passType == ccl::ustring( "lightgroup" ) )
115+
{
116+
layer.passType = ccl::PASS_COMBINED;
117+
layer.numChannels = 3;
118+
}
119+
else if( typeEnum.exists( passType ) )
113120
{
114121
layer.passType = static_cast<ccl::PassType>( typeEnum[passType] );
115122
ccl::PassInfo passInfo = ccl::Pass::get_info( layer.passType );
@@ -204,10 +211,10 @@ void OIIOOutputDriver::write_render_tile( const Tile &tile )
204211
}
205212
else
206213
{
207-
spec.channelnames.push_back( "R" );
208-
spec.channelnames.push_back( "G" );
209-
spec.channelnames.push_back( "B" );
210-
spec.channelnames.push_back( "A" );
214+
for( int i = 0; i < layer.numChannels; ++i )
215+
{
216+
spec.channelnames.push_back( g_channels[i] );
217+
}
211218
}
212219
//spec.full_x = m_displayWindow.min.x;
213220
//spec.full_y = m_displayWindow.min.y;

0 commit comments

Comments
 (0)