Graphics Reference
In-Depth Information
void main()
{
// Will be the same value in all shaders with the
// same viewProjMatrix and vertex
gl_Position = u_viewProjMatrix * a_vertex;
}
It is also possible to make all variables globally invariant using a #pragma
directive:
#pragma STDGL invariant(all)
A word of caution: Because the compiler needs to guarantee invariance, it
might have to limit the optimizations it does. Therefore, the invariant
qualifier should be used only when necessary; otherwise, it might result in
performance degradation. For this reason, the #pragma directive to globally
enable invariance should be used only when invariance is really required for
all variables. Note also that while invariance does imply that the calculation
will have the same results on a given GPU, it does not mean that the
computation will be invariant across any implementation of OpenGL ES.
Summary
This chapter introduced the following features of the OpenGL ES Shading
Language:
• Shader version specification with #version
• Scalar, vector, and matrix data types and constructors
• Declaration of constants using the const qualiier
• Creation and initialization of structures and arrays
• Operators, control flow, and functions
• Vertex shader inputs/output and fragment shader inputs/outputs
using the in and out keywords and layout qualifier
• Smooth, flat, and centroid interpolation qualifiers
• Uniforms, uniform blocks, and uniform block layout qualifiers
• Preprocessor and directives
• Uniform and interpolator packing
• Precision qualifiers and invariance
 
 
Search WWH ::




Custom Search