- Real-Time 3D Graphics with WebGL 2
- Farhad Ghayour Diego Cantor
- 171字
- 2021-06-10 19:43:05
Storage Qualifier
Variable declarations may have a storage qualifier specified in front of the type:
- attribute: Data pulled from buffers that serve as the link between a vertex shader and a WebGL application for per-vertex data. This storage qualifier is only legal inside the vertex shader.
- uniform: Value does not change across the object being processed. Uniforms form the link between a shader and a WebGL application. Uniforms are legal in both the vertex and fragment shaders. If a uniform is shared by the vertex and fragment shader, the respective declarations must match. Uniform values stay the same for all vertices of a single draw call.
- varying: This is the link between a vertex shader and a fragment shader for interpolated data. By definition, varyings must be shared by the vertex shader and fragment shader. The declaration of varyings needs to match between the vertex and fragment shaders.
- const: A compile-time constant, or a function parameter that is read-only. They can be used anywhere in the code of an ESSL program.