# 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. |
# 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 NormalSampler (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.
# 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).
# 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.
# Override UV-set
Overrides a texture-node's UV-set (globally).
# 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.
# 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: