We support conversion of the CgFX shader file format to our internal format. For the broadest compatiblity we recommend targeting the OpenGL ES 2.0 feature set in order to be compatible with the WebGL and our compatibility mode.
We provide a tool for converting CGFX shaders to the Turbulenz Engine Shader format.
For a given CgFX file the cgfx2json tool will create a JSON file containing a shader definition:
Shader parameter semantics are ignored by the cgfx2json tool, parameters will be matched at runtime by the variable name.
It is recommended that the CgFX file compiles program code either into GLSL profiles or into ‘latest’.
For more information about the CgFX file format please read the NVidia tutorial.
For more information about JSON please visit json.org.
Steps 1 and 2 as on the loading case.
This workflow is less flexible than loading the shader definition file at runtime but it avoids the added latency of requesting the file. The CPU cost of parsing the JSON string from the JSON file to create a JavaScript object is about the same as the cost of parsing and executing the JavaScript code that contains the shader definition.