Unity translates the Cg to OpenGL, OpenGL ES, or DirectX during the build process.
To retrieve the OpenGL ES shader code:
- Select the shader you want to analyze in Unity.
- Choose OpenGLES30 or
OpenGLES20 as the Custom Platform you
want to build for.
- Click the Compile and show button.
The result is displayed in your development environment.
The Mali Offline Shader Compiler only supports OpenGL ES
If your build platform is set to Android, Unity builds
OpenGLES30 shaders by
Vertex and fragment sessions are typically delimited by
#ifdef VERTEX or
FRAGMENT. If you use an option such as
multi_compile <FEATURE_OFF> <FEATURE_ON>, multiple shader
variants are built in the file.
Typically there are multiple
FRAGMENT sections. Each variant is compiled
separately by Unity starts your application. When you enable a feature, the relevant
variant is selected.
Because the code has been translated into OpenGL ES, you can copy the
vertex and fragment shader code into two separate files and compile them with the Mali
Offline Shader Compiler.
Compile the shaders with one of the following options:
–v for vertex shaders.
–f for fragment shaders.
The following figure shows the output of the Mali Offline Shader Compiler:
Figure 4-23 Output of the Mali Offline Shader Compiler