GetShaderInputType (Shader)

Introduced

5.0

Description

Returns the shader input type for a parameter. If the parameter cannot be connected to a shader, GetShaderInputType returns siUnknownParameterType.

Scripting Syntax

    Shader.GetShaderInputType( ParameterScriptName )

C# Syntax

    siShaderParameterType Shader.GetShaderInputType( String in_Param );

Parameters

Parameter | Type | Description
ParameterScriptName | String | Script name of parameter.

Return Value

siShaderParameterType

Examples

JScript Example

    // This example shows how to traverse a shader tree and list the
    // available shader inputs and their input types.
    //
    // Create an object with a texture shader
    newscene(null,false);
    var root = Application.ActiveProject.ActiveScene.Root;
    var model = root.AddModel();
    model.name = "MyModel";
    var object = model.AddGeometry( "Sphere", "MeshSurface" );

    BlendInPresets( "Image", object, 1, false );
    CreateProjection( object, siTxtSpherical, siTxtDefaultSpherical, "TxtSupport", "TxtProjection" );

    var filename = Application.InstallationPath( siFactoryPath ) +
       "\\Data\\XSI_SAMPLES\\Pictures\\xsilogo.jpg";

    var imageclip = CreateImageClip( filename, "XSILogo" );

    // Set up the texture space on texture shader
    var mat = object.Material;
    var textureshader = object.Material.CurrentTexture;

    // Set the texturespace parameter
    textureshader.parameters("tspace_id").Value = "TxtProjection";
    textureshader.parameters("tex").Connect(imageclip);

    // Select the texture shader
    SelectObj("MyModel.sphere.Scene_Material1.Phong.ambient_blend.Image", null, null);

    // Get an object from the selection list
    var obj = selection(0);

    // object is a shader
    if ( obj.isclassof( siShaderID ) )
    {
       // Get the material from shader
       var mat = obj.Root;
       traverse_shadernode(mat);
    }

    function traverse_shadernode( shadernode )
    {
       if ( ! shadernode ) return;

       if (! ( shadernode.isclassof( siShaderID ) ||
            shadernode.isclassof( siMaterialID ) ||
            shadernode.isclassof( siLightID ) ||
            shadernode.isclassof( siCameraID )) )
           return;

       // Traverse the occupied shader inputs
       var eParam = new Enumerator(shadernode.parameters);

       for ( ;!eParam.atEnd(); eParam.moveNext() )
       {
           var param = eParam.item();

           if (param.capabilities & siTexturable)
           {
              var nextnode = param.source;
              // parameter connected to shader node
              if ( nextnode != null )
                  traverse_shadernode( nextnode );
              else // parameter free
              {
                  var inputtype = shadernode.GetShaderInputType(param.scriptname);
                  logmessage( param.fullname + " is free to be connected to a shader that will match input type " + ShaderParameterTypeAsText(type));
              }
           }
       }
    }

    function ShaderParameterTypeAsText(type)
    {
       switch (type)
       {
           case siUnknownParameterType : return "siUnknownParameterType";
           case siBooleanParameterType : return "siBooleanParameterType";
           case siColorParameterType : return "siColorParameterType";
           case siDataParameterType : return "siDataParameterType";
           case siIntegerParameterType : return "siIntegerParameterType";
           case siLensParameterType : return "siLensParameterType";
           case siLightParameterType : return "siLightParameterType";
           case siMaterialParameterType : return "siMaterialParameterType";
           case siMatrixParameterType : return "siMatrixParameterType";
           case siModelParameterType : return "siModelParameterType";
           case siRealTimeParameterType : return "siRealTimeParameterType";
           case siReferenceParameterType : return "siReferenceParameterType";
           case siScalarParameterType : return "siScalarParameterType";
           case siShaderParameterType : return "siShaderParameterType";
           case siStringParameterType : return "siStringParameterType";
           case siStructParameterType : return "siStructParameterType";
           case siTextureParameterType : return "siTextureParameterType";
           case siTextureSpaceParameterType : return "siTextureSpaceParameterType";
           case siVectorParameterType : return "siVectorParameterType";

           default: return type;
       }
    }
    //INFO : Sources.Materials.DefaultLib.Scene_Material1.Phong.ambient_blend.base_color is free to be connected to a shader that will match input type siColorParameterType
    //INFO : Sources.Materials.DefaultLib.Scene_Material1.Phong.ambient_blend.Image.repeats is free to be connected to a shader that will match input type siVectorParameterType
    //INFO : Sources.Materials.DefaultLib.Scene_Material1.Phong.ambient_blend.Image.alt_x is free to be connected to a shader that will match input type siBooleanParameterType
    //INFO : Sources.Materials.DefaultLib.Scene_Material1.Phong.ambient_blend.Image.alt_y is free to be connected to a shader that will match input type siBooleanParameterType
    //INFO : Sources.Materials.DefaultLib.Scene_Material1.Phong.ambient_blend.Image.alt_z is free to be connected to a shader that will match input type siBooleanParameterType
    // ...

See Also

Shader.GetShaderParameterTargets | Shader.GetShaderParameterType | Shader.OutputType | Parameter.HasInstanceValue
Parameter.SetInstanceValue | Parameter.GetInstanceValue | Parameter.ScriptName |

Autodesk Softimage v7.5