GLSL variable qualifiers
Avishkar Autar · Aug 27 2015 · Graphics and Rendering
I’ve been playing around with WebGL shader code recently and found this bit on variable prefixes helpful, particularly in the explanation of the variable qualifiers:
- Attribute: data provided by buffers
- Uniform: inputs to the shaders
- Varying: values passed from a vertex shader to a fragment shader and interpolated (or varied) between the vertices for each pixel drawn
Something important to keep in mind is that this relates to the OpenGL ES Shading Language, Version 1.00, which is (unfortunately) what’s currently supported by WebGL.
A WebGL implementation must only accept shaders which conform to The OpenGL ES Shading Language, Version 1.00 [GLES20GLSL], and which do not exceed the minimum functionality mandated in Sections 4 and 5 of Appendix A.
- in is for input from the previous pipeline stage, i.e. per vertex (or per fragment) values at most, per primitive if using glAttribDivisor and hardware instanciation
- out is for output to the next stage