# 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 materialNamestring nodeTypestring nodeName | Creates a node of the given type. |
si | SetInput | string materialNamestring nodeNameuint inputSlotstring nodeNameToConnect | Connects a node to another node’s input slot. |
sd | SetDefault | string materialNamestring nodeNameuint inputSlotdouble Adouble Bdouble C | Sets default values for the given node input. |
sd1 | SetDefault1f | string materialNamestring nodeNameuint inputSlotuint componentdouble A | Sets default value for the given node input on the given component [RGBA, 0-3]. |
sce | SetExitNode | string materialNamestring channelNamestring nodeName | Sets the exit node for the given material channel. |
exf | ExportXML | string materialNamestring channelNamestring filePath | Exports shading network for the given material channel to file. |
swz | Swizzle | string materialNamestring nodeNameuint inputSlotuint outputSlot | Sets output slot for the given input slot for the specified swizzle node (RGBA -> 0, 1, 2, 3). |
svn | SetVertexColorName | string materialNamestring nodeNamestring colorSetName | Sets which color set to sample from for the given vertex color node. |
svc | SetVertCol | string materialNamestring nodeNameuint colorSet | Sets which color set to sample from for the given vertex color node. |
uva | SetUVAll | string nodeNamestring uvSetName | Sets the UV-set for the texture nodes matching the specified node name. |
uvm | SetUVMaterial | string materialNamestring nodeNamestring uvSetName | Sets the UV-set for the texture nodes that matches the specified node name for the given material. |
uvc | SetUVMaterialChannel | string materialNamestring channelNamestring nodeNamestring uvSetName | Sets the UV-set for the texture nodes that matches the specified node name for the given material channel. |
sa | SetSRGBAll | string nodeNamebool isSRGB | Sets the sRGB flag for the texture nodes matching the specified node name. |
sm | SetSRGBMaterial | string materialNamestring nodeNamebool isSRGB | Sets the sRGB flag for the texture nodes that matches the specified node name for the given material. |
sc | SetSRGBMaterialChannel | string materialNamestring channelNamestring nodeNamebool isSRGB | Sets the sRGB flag for the texture nodes that matches the specified node name for the given material channel. |
tmc | SetUVTilingMaterialChannel | string materialNamestring channelNamestring nodeNamedouble uTilingdouble vTiling | Sets u- and v-tiling for the given texture node. |
omc | SetUVOffsetMaterialChannel | string materialNamestring channelNamestring nodeNamedouble uOffsetdouble vOffset | Sets u- and v-offset for the given texture node. |
sgn | SetGeometryFieldName | string materialNamestring nodeNamestring geometryFieldName | Sets the field name for the given geometry field node. |
sgi | SetGeometryFieldIndex | string materialNamestring nodeNameint geometryFieldIndex | Sets the field index for the given geometry field node. |
sgt | SetGeometryFieldType | string materialNamestring nodeNameint 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 cmdsmust declared at the top of each Python script.reductionPipelinesettings-path must be declared for both MEL and Python scripts where it makes sense.materialNameis 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: