How to find the texture slot label for a shader
When writing tools for dealing with real-time shaders it is often necessary to find out the label name for the samplers displayed in the DX or CG shader property pages. They often have labels like Decal_Map or Normal_Map but have parameter names such as Texture_0 and Texture_1. There is a script for finding those labels:
// how to find texture_slot label for a shader
var matlibs = Application.ActiveProject.ActiveScene.MaterialLibraries;
var eMatLibs = new Enumerator(matlibs);
for( ; ! eMatLibs.atEnd(); eMatLibs.moveNext())
{
var matlib = eMatLibs.item();
var eMats = new Enumerator(matlib.items);
for( ; ! eMats.atEnd(); eMats.moveNext())
{
var material = eMats.item();
var shaders = material .GetAllShaders();
// find the texture slots
var eShaders = new Enumerator (shaders );
for ( ; ! eShaders .atEnd(); eShaders .moveNext() )
{
var shader = eShaders .item();
var eParams = new Enumerator (shader.parameters);
var ppglayout = shader.PPGLayout;
for ( ; ! eParams.atEnd(); eParams.moveNext() )
{
var param = eParams .item();
if ( shader.GetShaderInputType(param.name) == siTextureParameterType )
{
var ppgitem = ppglayout.Item(param.Name);
logmessage( "texture slot: " + param + ":" + ppgitem.Label);
}
}
}
}
}
This page was last modified 04:28, 2 Oct 2010.
This page has been accessed 1733 times.

