## Shader.GetShaderParameterTargets

### Introduced

v7.0

### Description

Returns a ParameterCollection containing the object(s) connected to a shader output parameter. This traverses the render tree in the opposite direction as the Parameter.Source property:
Shader1.Out
Shader1.Out ==> Shader2.In (ie., 'Shader1.GetShaderParameterTargets(Shader1.Out)' returns Shader2.In)
Note: You can also use this method on a shader compound to get the exposed input ports.

### C# Syntax

    ParameterCollection Shader.GetShaderParameterTargets( String in_ParameterName );

### Scripting Syntax

    oReturn = Shader.GetShaderParameterTargets( ParameterScriptName );

### Return Value

ParameterCollection

### Parameters

Parameter | Type | Description
--- | --- | ---
ParameterScriptName | String | Script name of the parameter. Tip: On single output shaders, you can use an empty scriptname to get the shader connected to the output.

### Examples

#### JScript Example

    /*

    	This example creates a sample shader tree and shows how to traverse a shader

    	tree from left to right using the Source property and right to left using the

    	GetShaderParameterTargets method. Both shader compound ports and non-compound

    	ports are demonstrated.

    */

    // Fill the Default Material with some shaders.

    NewScene(null,false);

    CreatePrim("Sphere", "MeshSurface", null, null);

    SelectObj("Sources.Materials.DefaultLib.Scene_Material", null, null);

    CreateShaderFromPreset("Shaders\\Texture\\Share\\Color_share.Preset",

    	"Sources.Materials.DefaultLib.Scene_Material", null);

    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Color_share",

    	"Sources.Materials.DefaultLib.Scene_Material.Phong.ambient", false);

    CreateShaderFromPreset("Shaders\\Texture\\Share\\Color_share.Preset",

    	"Sources.Materials.DefaultLib.Scene_Material", null);

    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Color_share",

    	"Sources.Materials.DefaultLib.Scene_Material.Color_share1.input", false);

    CreateShaderFromPreset("Shaders\\Texture\\Share\\Color_share.Preset",

    	"Sources.Materials.DefaultLib.Scene_Material", null);

    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Color_share",

    	"Sources.Materials.DefaultLib.Scene_Material.Color_share2.input", false);

    CreateShaderCompound("Sources.Materials.DefaultLib.Scene_Material.Color_share2", null);

    CreateShaderFromPreset("Shaders\\Texture\\Share\\Color_share.Preset",

    	"Sources.Materials.DefaultLib.Scene_Material", null);

    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Color_share2",

    	"Sources.Materials.DefaultLib.Scene_Material.Color_share.input", false);

    CreateShaderFromPreset("Shaders\\Texture\\Share\\Color_share.Preset",

    	"Sources.Materials.DefaultLib.Scene_Material", null);

    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Color_share3",

    	"Sources.Materials.DefaultLib.Scene_Material.Color_share2.input", false);

    CreateShaderCompound("Sources.Materials.DefaultLib.Scene_Material.Color_share3", null);

    // Get the Shader Source (single output shader) connected to a shader input port using

    // the Parameter.Source property.

    Application.LogMessage( "Source (Right to Left Traversal) of single output shader" );

    var oColorShareShader = GetValue("Sources.Materials.DefaultLib.Scene_Material.Color_share");

    var oColorShareInputParam = oColorShareShader.Parameters.Item("input");

    var oSource = oColorShareInputParam.Source;

    if( oSource != null ) {

    	Application.LogMessage( "  CnxSource: "  + oSource.FullName + ", "

    		+ "CnxTarget: " + oColorShareInputParam.FullName +"." );

    }

    // Get the Parameter Source (multi-output shader) connected to a shader input port using

    // the Parameter.Source property.

    Application.LogMessage( "Source (Right to Left Traversal) of multi-output shader" );

    var oColorShareShader = GetValue("Sources.Materials.DefaultLib.Scene_Material.Color_share2");

    var oColorShareInputParam = oColorShareShader.Parameters.Item("input");

    var oSource = oColorShareInputParam.Source;

    if( oSource != null ) {

    	Application.LogMessage( "  CnxSource: "  + oSource.FullName + ", "

    		+ "CnxTarget: " + oColorShareInputParam.FullName +"." );

    }

    // Get each Parameter Target driven by this multi-output shader's output port using the

    // Shader.GetShaderParameterTargets method.

    Application.LogMessage( "Target (Left to Right Traversal) for multi-output shader" );

    var oColorShareShader = GetValue("Sources.Materials.DefaultLib.Scene_Material.Color_share");

    var oTargets = oColorShareShader.GetShaderParameterTargets("");

    if( oTargets != null ) {

    	for( var i=0; i<oTargets.Count; i++ ) {

    		Application.LogMessage( "  CnxSource: "  + oColorShareShader.FullName + ", "

    			+ "CnxTarget: " + oTargets.Item(i).FullName +"." );

    	}

    }

    // Get the Parameter Source connected inside a shader compound output port using

    // the Parameter.Source property.

    Application.LogMessage( "Source (Right to Left Traversal) of shader compound" );

    var oShaderCompound = GetValue("Sources.Materials.DefaultLib.Scene_Material.ShaderCompound1");

    var oShaderCompoundOutputParam = oShaderCompound.Parameters.Item("input");

    var oSource = oShaderCompoundOutputParam.Source;

    if( oSource != null ) {

    	Application.LogMessage( "  CnxSource: "  + oSource.FullName + ", "

    		+ "CnxTarget: " + oShaderCompoundOutputParam.FullName +"." );

    }

    // Get the Parameter Target driven by this shader's output port (connected inside a shader

    // compound) using the Shader.GetShaderParameterTargets method.

    Application.LogMessage( "Target (Left to Right Traversal) for compound shader" );

    var oShaderCompound = GetValue("Sources.Materials.DefaultLib.Scene_Material.ShaderCompound");

    var oShaderCompoundInputParam = oShaderCompound.Parameters.Item("input");

    var oTargets = oShaderCompound.GetShaderParameterTargets( oShaderCompoundInputParam.Name );

    if( oTargets != null ) {

    	for( var i=0; i<oTargets.Count; i++ ) {

    		Application.LogMessage( "  CnxSource: "  + oShaderCompoundInputParam.FullName + ", "

    			+ "CnxTarget: " + oTargets.Item(i).FullName +"." );

    	}

    }

    // Expected results:

    // INFO : Source (Right to Left Traversal) of single output shader

    // INFO :   CnxSource: Sources.Materials.DefaultLib.Scene_Material.Color_share2,

    //          CnxTarget: Sources.Materials.DefaultLib.Scene_Material.Color_share.input.

    // INFO : Source (Right to Left Traversal) of multi-output shader

    // INFO :   CnxSource: Sources.Materials.DefaultLib.Scene_Material.ShaderCompound1.input,

    //          CnxTarget: Sources.Materials.DefaultLib.Scene_Material.Color_share2.input.

    // INFO : Target (Left to Right Traversal) for multi-output shader

    // INFO :   CnxSource: Sources.Materials.DefaultLib.Scene_Material.Color_share,

    //          CnxTarget: Sources.Materials.DefaultLib.Scene_Material.Phong.ambient.

    // INFO :   CnxSource: Sources.Materials.DefaultLib.Scene_Material.Color_share,

    //          CnxTarget: Sources.Materials.DefaultLib.Scene_Material.Color_share1.input.

    // INFO :   CnxSource: Sources.Materials.DefaultLib.Scene_Material.Color_share,

    //          CnxTarget: Sources.Materials.DefaultLib.Scene_Material.ShaderCompound.input.

    // INFO : Source (Right to Left Traversal) of shader compound

    // INFO :   CnxSource: Sources.Materials.DefaultLib.Scene_Material.ShaderCompound1.Color_share3,

    //          CnxTarget: Sources.Materials.DefaultLib.Scene_Material.ShaderCompound1.input.

    // INFO : Target (Left to Right Traversal) for compound shader

    // INFO :   CnxSource: Sources.Materials.DefaultLib.Scene_Material.ShaderCompound.input,

    //          CnxTarget: Sources.Materials.DefaultLib.Scene_Material.ShaderCompound.Color_share2.input.

### See Also

Shader.GetShaderParameterType Parameter.Source