例如:
var VertexShaderText = [
'attribute vec2 vertPosition;',
'void main()',
'{',
' gl_Position = vec4(vertPosition, 0.0, 1.0);',
'}'
].join('n');
除了gl_Position之外,是否有一个在线的所有WebGL着色器变量的列表?
您可以在规范和WebGL参考卡中找到它
参考卡列出了所有这些
内置输入、输出和常量[7]
着色器程序使用特殊变量与管道的固定函数部分进行通信。输出特殊变量可以在写入后读回。输入特殊变量是只读的。所有特殊变量都具有全局作用域。
顶点着色器特殊变量[7.1]
Outputs: Variable Description Units or coordinate system -------------------------------------------------------------------------------------- highp vec4 gl_Position; transformed vertex position clip coordinates mediump float gl_PointSize; transformed point size pixels (point rasterization only)
片段着色器特殊变量[7.2]
片段着色器可以写入gl_FragColor或gl_FragData[]的一个或多个元素,但不能同时写入两者。gl_FragData数组的大小由内置常量gl_MaxDrawBuffers给定。
Inputs: Variable Description Units or coordinate system ----------------------------------------------------------------------------------------------- mediump vec4 gl_FragCoord; fragment position within window coordinates frame buffer bool gl_FrontFacing; fragment belongs to a Boolean front-facing primitive mediump vec2 gl_PointCoord; fragment position within a 0.0 to 1.0 point (point rasterization for each only) component Outputs: Variable Description Units or coordinate system ----------------------------------------------------------------------------------------------- mediump vec4 gl_FragColor; fragment color RGBA color mediump vec4 gl_FragData[n] fragment color for RGBA color color attachment n
具有最小值的内置常量[7.4]
Built-in Constant Minimum value ---------------------------------------------------------------- const mediump int gl_MaxVertexAttribs 8 const mediump int gl_MaxVertexUniformVectors 128 const mediump int gl_MaxVaryingVectors 8 const mediump int gl_MaxVertexTextureImageUnits 0 const mediump int gl_MaxCombinedTextureImageUnits 8 const mediump int gl_MaxTextureImageUnits 8 const mediump int gl_MaxFragmentUniformVectors 16 const mediump int gl_MaxDrawBuffers 1
内置统一状态[7.5]
指定窗口坐标中的深度范围。如果实现在片段语言中不支持highp精度,并且state被列为highp,则该状态在片段中只能作为medium使用语言
struct gl_DepthRangeParameters { highp float near; // n highp float far; // f highp float diff; // f - n }; uniform gl_DepthRangeParameters gl_DepthRange;