GLSL语言摘要(一)
来源:互联网 发布:水果店淘宝首页模板 编辑:程序博客网 时间:2024/05/18 01:06
一、流水线
二、顶点处理器
1. 顶点属性
// Vertex Attributes
attribute vec4 gl_Color;
attribute vec4 gl_SecondaryColor;
attribute vec3 gl_Normal;
attribute vec4 gl_Vertex;
attribute vec4 gl_MultiTexCoord0;
attribute vec4 gl_MultiTexCoord1;
attribute vec4 gl_MultiTexCoord2;
// . . . up to gl_MultiTexCoordN-1 where N = gl_MaxTextureCoords
attribute float gl_FogCoord;
2. 特殊的输出变量
vec4 gl_Position; // must be written to
float gl_PointSize; // may be written to
vec4 gl_ClipVertex; // may be written to
3. 内置易变变量
varying vec4 gl_FrontColor; varying vec4 gl_BackColor; varying vec4 gl_FrontSecondaryColor; varying vec4 gl_BackSecondaryColor; varying vec4 gl_TexCoord[]; // at most will be gl_MaxTextureCoords varying float gl_FogFragCoord;
三、片元处理器
1. 内置易变变量
varying vec4 gl_Color; varying vec4 gl_SecondaryColor; varying vec4 gl_TexCoord[]; // at most will be gl_MaxTextureCoords varying float gl_FogFragCoord;
2.特殊输入变量
vec4 gl_FragCoord;
bool gl_FrontFacing;
3. 特殊输出变量
vec4 gl_FragColor; vec4 gl_FragData[gl_MaxDrawbuffers]; float gl_FragDepth;
四、内置一致性变量
//// Matrix state//uniform mat4 gl_ModelViewMatrix;uniform mat4 gl_ProjectionMatrix;uniform mat4 gl_ModelViewProjectionMatrix;uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];//// Derived matrix state that provides inverse and transposed versions// of the matrices above. Poorly conditioned matrices may result// in unpredictable values in their inverse forms.//uniform mat3 gl_NormalMatrix; // transpose of the inverse of the upper // leftmost 3x3 of gl_ModelViewMatrixuniform mat4 gl_ModelViewMatrixInverse;uniform mat4 gl_ProjectionMatrixInverse;uniform mat4 gl_ModelViewProjectionMatrixInverse;uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];uniform mat4 gl_ModelViewMatrixTranspose;uniform mat4 gl_ProjectionMatrixTranspose;uniform mat4 gl_ModelViewProjectionMatrixTranspose;uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords]uniform mat4 gl_ModelViewMatrixInverseTranspose;uniform mat4 gl_ProjectionMatrixInverseTranspose;uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords]//// Normal scaling//uniform float gl_NormalScale;//// Depth range in window coordinates//struct gl_DepthRangeParameters{ float near; // n float far; // f float diff; // f - n};uniform gl_DepthRangeParameters gl_DepthRange;//// Clip planes//uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];//// Point Size//struct gl_PointParameters{ float size; float sizeMin; float sizeMax; float fadeThresholdSize; float distanceConstantAttenuation; float distanceLinearAttenuation; float distanceQuadraticAttenuation;};uniform gl_PointParameters gl_Point;//// Material State//struct gl_MaterialParameters{ vec4 emission; // Ecm vec4 ambient; // Acm vec4 diffuse; // Dcm vec4 specular; // Scm float shininess; // Srm};uniform gl_MaterialParameters gl_FrontMaterial;uniform gl_MaterialParameters gl_BackMaterial;//// Light State//struct gl_LightSourceParameters{ vec4 ambient; // Acli vec4 diffuse; // Dcli vec4 specular; // Scli vec4 position; // Ppli vec4 halfVector; // Derived: Hi vec3 spotDirection; // Sdli float spotExponent; // Srli float spotCutoff; // Crli // (range: [0.0,90.0], 180.0) float spotCosCutoff; // Derived: cos(Crli) // (range: [1.0,0.0],-1.0) float constantAttenuation; // K0 float linearAttenuation; // K1 float quadraticAttenuation; // K2};uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];struct gl_LightModelParameters{ vec4 ambient; // Acs};uniform gl_LightModelParameters gl_LightModel;//// Derived state from products of light and material.//struct gl_LightModelProducts{ vec4 sceneColor; // Derived. Ecm + Acm * Acs};uniform gl_LightModelProducts gl_FrontLightModelProduct;uniform gl_LightModelProducts gl_BackLightModelProduct;struct gl_LightProducts{ vec4 ambient; // Acm * Acli vec4 diffuse; // Dcm * Dcli vec4 specular; // Scm * Scli};uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];//// Texture Environment and Generation//uniform vec4 gl_TextureEnvColor[gl_MaxTextureUnits];uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];//// Fog//struct gl_FogParameters{ vec4 color; float density; float start; float end; float scale; // 1.0 / (gl_Fog.end - gl_Fog.start)};uniform gl_FogParameters gl_Fog;
五、内置常量
//// Implementation dependent constants. The values below// are the minimum values allowed for these constants.//const int gl_MaxLights = 8;const int gl_MaxClipPlanes = 6;const int gl_MaxTextureUnits = 2;const int gl_MaxTextureCoords = 2;const int gl_MaxVertexAttribs = 16;const int gl_MaxVertexUniformComponents = 512;const int gl_MaxVaryingFloats = 32;const int gl_MaxVertexTextureImageUnits = 0;const int gl_MaxTextureImageUnits = 2;const int gl_MaxFragmentUniformComponents = 64;const int gl_MaxCombinedTextureImageUnits = 2;const int gl_MaxDrawBuffers = 1;
- GLSL语言摘要(一)
- GLSL语言摘要(二): build-in function
- GLSL着色语言的学习(一)渲染管线流程
- 图形处理之Shader语言(一)GLSL语法篇
- GLSL语言内置变量
- GLSL语言内置变量
- GLSL语言内置变量
- GLSL语言内置变量
- GLSL语言基础
- GLSL语言基础
- OpenGL着色语言GLSL
- GLSL语言基础
- GLSL语言内置变量
- GLSL语言基础
- GLSL语言基础
- glsl语言基础
- GLSL语言基础
- GLSL语言基础
- 网站拒绝访问问题
- 对/u-boot-1.1.6/board/smdk2410/u-boot.lds的更详细的分析
- 最近开发的一个项目的一些感想
- 快速求最小公倍数的四种方法
- HoneyComb3.0技术系列之Fragment
- GLSL语言摘要(一)
- HoneyComb3.0技术系列之ActionBar
- 新的开始
- HoneyComb3.0技术系列之ClipBoard
- 以太网简介
- 基础很重要..
- 一体化枪机和快速球机
- 伤痕实验启示
- Vimrc (个人总结)