WebGL着色器变量列表?

3

例如:

var VertexShaderText = [

'attribute vec2 vertPosition;',

'void main()',
'{',
'  gl_Position = vec4(vertPosition, 0.0, 1.0);',
'}'
].join('\n');

除了gl_Position之外,是否有在线列表列出了您可以使用的所有WebGL着色器变量?


它在规范的第7节“内置变量”中定义。 - LJᛃ
2
@Downvoter 为什么要点踩?每个人都需要从某个地方开始。并不是每个人都像你一样有OpenGL和WebGL的广泛知识。有些人只是试图通过学习编程中的新概念来摸索前行。WebGL的一个巨大难点在于它太老了(所有浏览器支持的WebGL v1都基于OpenGL 1.2),以至于许多在线参考资料列出的所有属性和技巧在WebGL v1中根本不起作用。 - Jack G
1个回答

6
你可以在规范WebGL 参考卡中找到它。
参考卡列出了所有这些内容。

Built-In Inputs, Outputs, and Constants [7]

Shader programs use Special Variables to communicate with fixed-function parts of the pipeline. Output Special Variables may be read back after writing. Input Special Variables are read-only. All Special Variables have global scope.

Vertex Shader Special Variables [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)

Fragment Shader Special Variables [7.2]

Fragment shaders may write to gl_FragColor or to one or more elements of gl_FragData[], but not both. The size of the gl_FragData array is given by the built-in constant 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

Built-In Constants With Minimum Values [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

Built-In Uniform State [7.5]

Specifies depth range in window coordinates. If an implementation does not support highp precision in the fragment language, and state is listed as highp, then that state will only be available as mediump in the fragment language.

struct gl_DepthRangeParameters {
  highp float near; // n
  highp float far;  // f
  highp float diff; // f - n
};
uniform gl_DepthRangeParameters gl_DepthRange;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接