Just My Life & My Work

[GLSL] Variables

vertex shaderpixel 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.
  • varyingRead-only in a fragment shader, readable/writable in the vertex shader. Used to communicate between the two shaders.
  • uniformGlobal read-only variables available to vertex and fragment shaders which can’t be changed inside glBegin() and glEnd() calls.
  • attributeGlobal 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

隨意留個言吧:)~

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料

標籤雲