GetShaderInputType (Material)
Introduced
5.0
Description
Returns the shader input type for the specified parameter. If the parameter cannot be connected to another shader GetShaderInputType returns siUnknownInputType.
Scripting Syntax
Material.GetShaderInputType( ParameterScriptName )
C# Syntax
siShaderParameterType Material.GetShaderInputType( String Parametername );
Parameters
|
Parameter |
Type |
Description |
|
ParameterScriptName |
Script name of the parameter |
Return Value
Examples
JScript Example
// Create an object with a texture shader
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 the texture shader
var mat = object.Material;
var textureshader = null;
// Different ways to get the texture shader:
// Method 1
textureshader = object.Material.CurrentTexture;
// Method 2
var shaders = mat.FindShaders(siShaderFilter);
textureshader = shaders("Image");
// Method 3
textureshader = mat.Shaders("Phong").Shaders("diffuse_blend").Shaders("Image");
// Set the texturespace parameters
textureshader.Parameters("tspace_id").Value = "TxtProjection";
textureshader.Parameters("tex").Connect(imageclip);
// List the names and input types of all parameters that support shader connections
var eParams = new Enumerator(mat.Parameters);
for ( ; !eParams.atEnd(); eParams.moveNext() )
{
var param = eParams.Item();
if (param.capabilities & siTexturable)
{
var inputtype = mat.GetShaderInputType(param.scriptname);
// This parameter supports a shader connection
Application.LogMessage( param.FullName + " has shader inputtype = " + 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 inputtype;
}
}
//INFO : MyModel.sphere.Scene_Material1.surface has shader inputtype = siColorParameterType
//INFO : MyModel.sphere.Scene_Material1.volume has shader inputtype = siColorParameterType
//INFO : MyModel.sphere.Scene_Material1.environment has shader inputtype = siColorParameterType
//INFO : MyModel.sphere.Scene_Material1.contour has shader inputtype = siColorParameterType
//INFO : MyModel.sphere.Scene_Material1.displacement has shader inputtype = siScalarParameterType
//INFO : MyModel.sphere.Scene_Material1.shadow has shader inputtype = siColorParameterType
//INFO : MyModel.sphere.Scene_Material1.Photon has shader inputtype = siColorParameterType
//INFO : MyModel.sphere.Scene_Material1.PhotonVolume has shaderinput type = siColorParameterType
//INFO : MyModel.sphere.Scene_Material1.normal has shader inputtype = siVectorParameterType
//INFO : MyModel.sphere.Scene_Material1.RealTime has shader inputtype = siRealTimeParameterType
//
See Also
SOFTIMAGE|XSI v6.01