Main | API | WebRender | addSBOVertexAttribute

Function

addSBOVertexAttribute(sbo, shader, type, length);

Attaches attributes to the vertex and pixel/fragment shaders.

Parameters

sbo - [Unsigned Integer]

The id of the shader program this is effecting. The id was provided by getSBOId.

shader - [String]

This string defines which shader in the program this is effecting. Valid strings: VERTEX, PIXEL, FRAGMENT.

Due to different naming conventions, pixel and fragment are both included and refer to the same shader.

type - [String]

This defines what type of data is stored in this attribute. Although any string can be used here, the values POSITION and TEXCOORD have special functions. See description for more details.

length - [Unsigned Integer]

The amount of numbers that make up this attribute.

Return

None.

Description

In order to have a functioning shader you must have a POSITION attribute with a length of 4 assigned to the PIXEL/FRAGMENT shader. This is required as the entire rendering pipeline works on the assumption that we have a vertex with XYZW values. The TEXCOORD type is to be used to define your UV values as it will allow the pipeline to optimise them for texture sampling. Any other string value is allowed so that you can more easily identify how your data is structured.

Due to the amount of inputs and complexity of setting up a shader, there are a number of errors that can occur if inputs are incorrect. These are printed to the console once the shader is created with loadSBO.

See more detailed information about shaders here.

Additional Notes

None.