Shader workflowHere I try to describe how the shaders are translated from maya to vex code.
Basically its quite simple, there are a few steps:
- first, the shading network of an object is parsed
- all the nodes found in the network are stored with its connections
- then from these nodes a source code file is created which is then
- compiled by the vcc compiler
This image shows basic procedure:
Now it is important that the translators know which shading nodes and which attributes are supported. The source for this information is a text file called shaderDefinitions.txt and it resides in the ressources subdirectory of the installation. If you open the file you can see how the shaders are defined.
Every shader has its own segement. It is always started by:
shader_startthen follows the name in the form:
name:kTextureBasefollowes by input and output attributes like this one:
inatt:defaultColor:color:0.5,0.5,0.0and is finally finished by:
A comment starts at the very beginning of the like with a '#' sign.
A attribute line consists of these parts:
With this file, all supported nodes are defined. Every single node needs its counterpart as vex souce code file. e.g. a node called bulge needs its counterpart in the ShaderIncludes directory called bulge.h.
Now that we know the translator knows which nodes can be used. It parses the shading networks and save the found nodes with the connections in a list. If a node is not supported, the current value of the connection is used.
Then for every network the shading node list is translated in a source code file. The translator does not check if the include files are existent. It simply thinks that they exist if the node is known because it is found in the shaderDefinitions file. The translator simply write a #include xxx.h line into the shader code. From all parameters, the sourcecode is created.
And finally the vcc compiler is called to create the final vex file and otl library.