vertex shader和pixel shader可以使用的變數型態有些差異,從字面意義來記憶比較實際。
Variables
Declaring and using variables in GLSL is similar to using variables in C.
There are four options for variable qualifiers:
- const – A constant.
- varying – Read-only in a fragment shader, readable/writable in the vertex shader. Used to communicate between the two shaders.
- uniform – Global read-only variables available to vertex and fragment shaders which can’t be changed inside glBegin() and glEnd() calls.
- attribute – Global read-only variables only available to the vertex shader (and not the fragment shader). Passed from an OpenGL program, these can be changed on a per vertex level.
參考:Tutorials » GLSL 1.2 Tutorial » Data Types and Variables 。
隨意留個言吧:)~