Light.GetAllShaders

Introduced

v7.0

Description

Returns all shaders nested under the light, even the ones that are not connected. If no shaders are found, this method returns an empty collection.

Scripting Syntax

oReturn = Light.GetAllShaders();

Return Value

ShaderCollection

Examples

JScript Example

// Create a scene with an object lit by a spotlight
var root = Application.ActiveProject.ActiveScene.Root;
var grid = root.AddGeometry( "Grid", "MeshSurface" );
scale( grid, 2, 2, 2, siAbsolute );
var cone = root.AddGeometry( "Cone", "MeshSurface" );
translate(cone, 0, 1.3, 0 );
var light = root.AddLight( "LightSpot", true, "SpotLight" );
ApplyCns( "Position", light.interest, cone );
ApplyCns( "Orientation", light.interest, cone );
translate( light, 4, 6, 4);
var strFileName = Application.InstallationPath( siFactoryPath ) + 
        "\\Data\\XSI_SAMPLES\\Pictures\\xsilogo.jpg";
var imageclip = CreateImageClip( strFileName, "XSILogo" );
// Find the first parameter that is texturable and of type color. 
// This is the shader connection point.
var shader_param = null;
for ( i=0; i < light.parameters.count; i++ )
{
        var param =  light.parameters(i);
        var inputtype =  light.GetShaderInputType(param.scriptname);
        if ((param.capabilities & siTexturable) && (inputtype == siColorParameterType ))
        {
                shader_param = param;
                break;
        }
}
logmessage( "shader connection point = " + shader_param.fullname );
// set up shader tree
if ( shader_param )
{
        var mix2 = shader_param.ConnectFromProgID("Softimage.sib_color_2mix");
        var soft_light = mix2.parameters("base_color").ConnectFromProgID("Softimage.soft_light");
        var fast_light_effect = mix2.parameters("color1").ConnectFromProgID("Softimage.Bionic_Light.lit");
        fast_light_effect.parameters("Projector_Pic").connect(imageclip);
}
// Find the soft_light shader
var shaders = light.GetAllShaders();
var eShaders = new Enumerator(shaders);
// Set up shadows with a softlight.
var soft_light_id = String("Softimage.soft_light.1").toLowerCase();
for ( ; !eShaders.atEnd(); eShaders.moveNext() )
{
        var shader = eShaders.item();
        if (shader.progid.toLowerCase() == soft_light_id)
        {
                // setup shadows
                var soft_light = shader;
                soft_light.parameters("shadow").value = true;
                soft_light.parameters("factor").value = 0.5;
                break;
        }
}
//INFO : shader connection point = SpotLight.light.LightShader

See Also

Light.GetShaderInputType Camera.GetAllShaders Material.GetAllShaders Shader.GetAllShaders