Getting the shader connected to a material

In previous versions of Softimage, you could use Parameter.Source to get the shader/texture connected to a material parameter such as the diffuse port.

As of 2011, Source returns a ShaderParameter. To get the connected shader, use ShaderParameter.Parent (in C++, GetSource().GetParent()).

var m = Dictionary.GetObject( "Sources.Materials.DefaultLib.Material.Blinn" );
var p = m.Parameters("diffuse");
LogMessage( p.Source );
// INFO : Sources.Materials.DefaultLib.Material.Image.out

LogMessage( ClassName( p.Source ) );
// INFO : ShaderParameter

LogMessage( p.Source.Parent );
// INFO : Sources.Materials.DefaultLib.Material.Image

LogMessage( ClassName( p.Source.Parent ) );
// INFO : Texture

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s