The TextureLayerPort is an object used to describe which specific shader and material parameters a TextureLayer affects. Like shader connections, they indicate what shader ports are being driven by the layer.
The port has a few properties which describe how the layer affects a single shading parameter, generally these are used to modify the layer's settings in a port-specific way, for example by inverting or scaling the overall effect. A layer may be set up to blend its color by 50% with the layer beneath it. However, that layer's the ambient port effect may only be 25% whereas the diffuse port contribution could be set to 100%.
- See also:
- TextureLayer::GetTextureLayerPorts, TextureLayer::AddTextureLayerPort, Shader
- Since:
- 4.0
- Example:
- This C++ example shows how to create texture layer ports, plus enumerating and removing them.
using namespace XSI;
Application app;
Model root = app.GetActiveSceneRoot();
X3DObject mySphere;
root.AddGeometry( L"Sphere",L"MeshSurface",L"" ,mySphere );
Material myMaterial;
mySphere.AddMaterial(L"Phong",false,L"",myMaterial);
CRefArray myShaders;
Shader myPhong;
myShaders = myMaterial.GetShaders();
myPhong = myShaders[0];
TextureLayer myLayer;
myLayer = myPhong.CreateTextureLayer( L"DirtLayer", true );
CRefArray myPorts(3);
myPorts[0] = myLayer.AddTextureLayerPort( myPhong.GetParameters().GetItem( L"ambient" ) );
myPorts[1] = myLayer.AddTextureLayerPort( myPhong.GetParameters().GetItem( L"diffuse" ) );
myPorts[2] = myLayer.AddTextureLayerPort( myPhong.GetParameters().GetItem( L"specular" ) );
myPorts = myLayer.GetTextureLayerPorts();
app.LogMessage( L"Created " + CValue(myPorts.GetCount()).GetAsText() + L" ports." );
for ( LONG i = 0; i < myPorts.GetCount(); i++ )
{
TextureLayerPort curPort = myPorts[i];
app.LogMessage( CValue(i + 1L).GetAsText() + L": " + curPort.GetName() +
L" --> " + curPort.GetTarget().GetFullName() );
}
myLayer.RemoveTextureLayerPort( myPorts[1] );
myLayer.RemoveTextureLayerPort( myLayer.GetFullName() + L"." + TextureLayerPort(myPorts[2]).GetName() );
myPorts = myLayer.GetTextureLayerPorts();
app.LogMessage( L"Only " + CValue(myPorts.GetCount()).GetAsText() + L" remain(s) after removal." );
for ( i = 0; i < myPorts.GetCount(); i++ )
{
app.LogMessage( CValue(i + 1L).GetAsText() + L": " + TextureLayerPort(myPorts[i]).GetFullName() );
}