SICALLBACK UtShaderPlugin_ColorShare_1_0_Define( CRef& in_ctxt )
{
XSI::Context ctxt(in_ctxt);
XSI::ShaderDef shaderDef = ctxt.GetAttribute( L"Definition" );
// Check if the user attribute is there
{
CValue valDune = shaderDef.GetAttributes().GetAttribute( L"{F2EF07FE-1B57-4245-BF08-F5556212BFDF}" );
assert( !valDune.IsEmpty() );
}
// Define PassThrough ports
definePassThroughPorts( shaderDef, XSI::siColorParameterType );
// Fill Meta shader section
{
shaderDef.AddType( L"texture" );
MetaShaderRendererDef rendererDef = shaderDef.AddRendererDef( L"Mental Ray");
assert( rendererDef.IsValid() );
rendererDef.PutSymbolName( L"sib_color_passthrough" );
rendererDef.PutCodePath( L"{LIBS}/sibase.{EXT}" );
rendererDef.GetRendererOptions().SetAttribute( L"version", CValue((LONG)1) );
}
return CStatus::OK;
}
// Helper function
void definePassThroughPorts( ShaderDef& in_ShaderDef, XSI::siShaderParameterType in_eParamType )
{
XSI::Application app;
XSI::Factory fact=app.GetFactory();
XSI::ShaderParamDefOptions optDefault= fact.CreateShaderParamDefOptions();
optDefault.SetTexturable(true);
ShaderParamDefOptions opt= fact.CreateShaderParamDefOptions();
opt.SetTexturable(true);
// Add input + 8 channels + output
if( in_eParamType==XSI::siColorParameterType )
{
XSI::CValueArray valArray;
valArray.Add( 0.5f );
valArray.Add( 0.5f );
valArray.Add( 0.5f );
valArray.Add( 1.0f );
optDefault.SetDefaultValue( valArray );
}
XSI::ShaderParamDef pdef;
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"input", in_eParamType, optDefault );
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"channel1", in_eParamType, opt );
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"channel2", in_eParamType, opt );
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"channel3", in_eParamType, opt );
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"channel4", in_eParamType, opt );
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"channel5", in_eParamType, opt );
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"channel6", in_eParamType, opt );
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"channel7", in_eParamType, opt );
pdef = in_ShaderDef.GetInputParamDefs().AddParamDef( L"channel8", in_eParamType, opt );
pdef = in_ShaderDef.GetOutputParamDefs().AddParamDef( L"out_result", in_eParamType );
// Get the ShaderDefs Layouts
XSI::PPGLayout layoutPPG = in_ShaderDef.GetPPGLayout();
XSI::PPGLayout layoutRT = in_ShaderDef.GetRenderTreeLayout();
// Define the PPG Layout.. only input should be visible
layoutPPG.AddItem( L"name", L"Name" );
layoutPPG.AddItem( L"input", L"Input" );
// Define the RT Layout.. input alone, then all the channels in a group
{
layoutRT.AddItem( L"input", L"Input" );
layoutRT.AddGroup( L"Channels", false );
layoutRT.AddItem( L"channel1", L"Channel 1" );
layoutRT.AddItem( L"channel2", L"Channel 2" );
layoutRT.AddItem( L"channel3", L"Channel 3" );
layoutRT.AddItem( L"channel4", L"Channel 4" );
layoutRT.AddItem( L"channel5", L"Channel 5" );
layoutRT.AddItem( L"channel6", L"Channel 6" );
layoutRT.AddItem( L"channel7", L"Channel 7" );
layoutRT.AddItem( L"channel8", L"Channel 8" );
layoutRT.EndGroup();
}
} |