# SimplygonShadingNetwork
command
# Description
The SimplygonShadingNetwork command is responsible for creating shading network templates in Maya. Shading networks are usually generated automatically in the plug-in but for some material types, such as DirectX, CGFX and Stingray, the mapping has to be done manually. It is recommended to read Shading network concepts before proceeding.
# Syntax
# Flags and args
Short flag | Long flag | Argument(s) | Description |
---|---|---|---|
cn | CreateNode | string materialName string nodeType string nodeName | Creates a node of the given type. |
si | SetInput | string materialName string nodeName uint inputSlot string nodeNameToConnect | Connects a node to another node’s input slot. |
sd | SetDefault | string materialName string nodeName uint inputSlot double A double B double C | Sets default values for the given node input. |
sd1 | SetDefault1f | string materialName string nodeName uint inputSlot uint component double A | Sets default value for the given node input on the given component [RGBA, 0-3]. |
sce | SetExitNode | string materialName string channelName string nodeName | Sets the exit node for the given material channel. |
exf | ExportXML | string materialName string channelName string filePath | Exports shading network for the given material channel to file. |
swz | Swizzle | string materialName string nodeName uint inputSlot uint outputSlot | Sets output slot for the given input slot for the specified swizzle node (RGBA -> 0, 1, 2, 3). |
svn | SetVertexColorName | string materialName string nodeName string colorSetName | Sets which color set to sample from for the given vertex color node. |
svc | SetVertCol | string materialName string nodeName uint colorSet | Sets which color set to sample from for the given vertex color node. |
uva | SetUVAll | string nodeName string uvSetName | Sets the UV-set for the texture nodes matching the specified node name. |
uvm | SetUVMaterial | string materialName string nodeName string uvSetName | Sets the UV-set for the texture nodes that matches the specified node name for the given material. |
uvc | SetUVMaterialChannel | string materialName string channelName string nodeName string uvSetName | Sets the UV-set for the texture nodes that matches the specified node name for the given material channel. |
sa | SetSRGBAll | string nodeName bool isSRGB | Sets the sRGB flag for the texture nodes matching the specified node name. |
sm | SetSRGBMaterial | string materialName string nodeName bool isSRGB | Sets the sRGB flag for the texture nodes that matches the specified node name for the given material. |
sc | SetSRGBMaterialChannel | string materialName string channelName string nodeName bool isSRGB | Sets the sRGB flag for the texture nodes that matches the specified node name for the given material channel. |
tmc | SetUVTilingMaterialChannel | string materialName string channelName string nodeName double uTiling double vTiling | Sets u- and v-tiling for the given texture node. |
omc | SetUVOffsetMaterialChannel | string materialName string channelName string nodeName double uOffset double vOffset | Sets u- and v-offset for the given texture node. |
sgn | SetGeometryFieldName | string materialName string nodeName string geometryFieldName | Sets the field name for the given geometry field node. |
sgi | SetGeometryFieldIndex | string materialName string nodeName int geometryFieldIndex | Sets the field index for the given geometry field node. |
sgt | SetGeometryFieldType | string materialName string nodeName int geometryFieldType | Sets the field type (EGeometryFieldType in Simplygon API) for the given geometry field node. |
# Examples
This section contains some examples on how to setup shading networks through MEL and Python. We've left out some parts of the scripts to keep things as simple as possible.
import maya.cmds as cmds
must declared at the top of each Python script.reductionPipeline
settings-path must be declared for both MEL and Python scripts where it makes sense.materialName
is used as a place-holder for the name of the material we are currently working on.- a scene-selection is made before each
Simplygon
-command.
# Create shading node
Creates two texture-nodes that points to the texture slots of the CGFX material's HLSL shader, in this case DiffuseSampler and NormalsSampler (as defined in the shader).
For CGFX materials the sampler2D
(DiffuseSampler) represents the texture slot. For DirectX materials the texture
(DiffuseTexture) represents the texture slot. This means that we'll use the sampler2D
when mapping textures from CGFX to Simplygon, and texture
when mapping textures from DirectX to Simplygon.
# Set default values
Sets the default values of (for example) a Multiply-node. The name of the node is "multiplyNode".
# Set exit node
Assigns a shading node to a material channel, in this case we connect as texture node (which points to DiffuseSampler in shader) to the Diffuse channel.
# Set swizzle
Reverses the color channels (RGBA -> ABGR) using a swizzling node. The name of the node is "swizzleNode".
# Set vertex-color set
Assigns "colorSet1" (of the mesh) to a vertex-color node. Can be used to blend textures by vertex colors or bake vertex colors to texture. The name of the node is "vertexColorNode".
# Specify geometry data field
Assigns a data field (of the mesh) to a geometry-field node. The node can be used to sample specific geometry fields in shading network such as Coords, TexCoords, Normals, Tangents, Bitangents, Colors, TriangleIds and MaterialIds (see EGeometryDataFieldType). In this example we will set up a geometry field node that samples from the color field 'colorSet1'.
SetGeometryFieldType (sgt) specifies which type of the field to sample from, as all colors are stored as 'Color'-fields in Simplygon we want to use the 'Color' index in EGeometryDataFieldType as the type, which is 5.
SetGeometryFieldName (sgn) and SetGeometryFieldIndex (sgi) specifies either the Name or Index of the Color field to sample from, Name har precedence over Index (index might also differ between meshes).
The name of the node is "geometryFieldNode".
# Override UV-set
Overrides a texture's UV-set (globally). The name of the texture node is "DiffuseSampler".
# Override sRGB
Overrides the sRGB-flag for Diffuse and Normals.
# Override tiling/offset
Overrides a texture-node's tiling and offset values for the Diffuse channel. The name of the texture node is "DiffuseSampler".
# Export Shading Network XML
Exports a shading network for the given material channel to XML.
# Import Shading Network XML
Imports shading network XML through the Simplygon command.
# Next steps
Get to know how to work with shading networks: