平民程序 - linghuye's blog

天下风云出我辈,一入江湖岁月催。皇图霸业谈笑中,不胜人生一场醉。提剑跨骑挥鬼雨,白骨如山鸟惊飞。尘事如潮人如水,只笑江湖几人回。

随笔 - 221, 文章 - 0, 评论 - 680, 引用 - 0
数据加载中……

OpenGL Shader Language笔记

Vector: vec2,vec3,vec4/xyzw,rgba,stpq
Matrix: mat2,mat2,mat3
Sampler: sampler1D,sampler2D
Qualifiers have been added to manage the input and output of shaders: 
  1.attribute: From app to vertex shader
  2.uniform: From app to any shader 
  3.varying: Interpolated values from vertex shader to fragment shader
 

Shaders written in the OpenGL Shading Language can use built-in variables that begin with the reserved prefix "gl_" in order to access existing OpenGL state and to communicate with the fixed functionality of OpenGL.

the compiler for the OpenGL Shading Language is actually part of the OpenGL driver environment. This is one of the key differences between the OpenGL Shading Language and other shading language designs.

Varying variables provide an interface between Vertex and Fragment Shader. Vertex Shaders compute values per vertex and fragment shaders compute values per fragment. If you define a varying variable in a vertex shader, its value will be interpolated (perspective-correct) over the primitve being rendered and you can access the interpolated value in the fragment shader.

Varying can be used only with the data types float, vec2, vec3, vec4, mat2, mat3, mat4. (arrays of them too.)

References:
http://www.clockworkcoders.com/oglsl/

posted on 2005-10-08 00:49 linghuye 阅读(2464) 评论(0)  编辑 收藏 引用 所属分类: 3D图形学研究

只有注册用户登录后才能发表评论。