5

For example:

var VertexShaderText = [

'attribute vec2 vertPosition;',

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

Is there a list online somewhere of all the WebGL shader variables you can code with other than gl_Position?

2
  • 1
    Its defined in the specification, Section 7 "Built-in Variables" Commented Feb 9, 2017 at 16:43
  • 3
    @Downvoter Why the downvote? Everyone has to start somewhere. Not everyone was as fortunate as you to already have extensive knowledge of the workings of OpenGL and, by extension, WebGL. Some people are just trying to muggle their way through learning a new concept in programming. One of the great difficulties of WebGL is that it is sooo old (WebGL v1, which is what all browsers support, is based off OpenGL 1.2) that many online references list all sorts of properties and tricks that simply do not work in WebGL v1. Commented Mar 26, 2020 at 14:29

1 Answer 1

7

You can find it in both the spec and the WebGL reference card

The reference card lists all of these

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.