SDK KB : How to get color parameters hidden by a shader connection


When you connect a shader to a color parameter, you can no longer access the RGBA values.

However, if you do want the original RGBA values, there is a way to get at them:

var oGrid = ActiveSceneRoot.AddGeometry( "Cube", "MeshSurface" );
var oMat = oGrid.AddMaterial();
var oSurface = oMat.Parameters("Surface");

var oPhong = oSurface.ConnectFromPreset( "Phong","Material Shaders" );

var oShadow = oMat.Parameters("Shadow");
oShadow.Connect( oPhong );

var oPhoton = oMat.Parameters( "Photon" );
oPhoton.Connect( oPhong );

var oAmbient = oPhong.Parameters( "ambient" );

oAmbient.red = 0.3;
oAmbient.green = 0.4;
oAmbient.blue = 0.5;

// This shader connection will hide the ambient colors
var oCloud = oAmbient.ConnectFromPreset( "Cloud","Texture Shaders" );

// But this Attrib will allow you to get them back even 
// though there is nothing useful to be done with them in XSI
var oHiddenColor = oAmbient.FindAttrib( "{37E9DB0B-7D6D-4ed9-B3AB-A384932623D6}" );

LogMessage( classname( oHiddenColor ) );
// Should log "Parameter" = It's a compound parameter.

oEnum = new Enumerator( oHiddenColor.Parameters ) ;
for (;!oEnum.atEnd();oEnum.moveNext() )
{
	var oItem = oEnum.item() ;
	LogMessage( oItem.Name + " = " + oItem.Value );
}

This page was last modified 15:23, 23 Mar 2007.
This page has been accessed 1581 times.

© Copyright 2009 Autodesk Inc. All Rights Reserved. Privacy Policy | Legal Notices and Trademarks | Report Piracy