Accessor class is a helper class that describes how a buffers memory is structured and should be accessed. Accessors are used.
The type of values, number of values per element, any offset and strides, etc. as well as some additional parameters relating to how the GPU should access buffer data (instance divisors, integer normalization etc).
By using multiple
Accessor instances, the application can defined different "views" of the data in a single buffer.
Accessors are immutable by design. Once they have been created they cannot be changed.
Accessors can be resolved (merged) into a new Accessor. This is useful since while some accessor properties can be extracted directly from a program's shaders (and some can be extracted when data is set to the buffer), some properties needs to be set by the application.
|data layout||N/A||Byte offset to start of data in buffer|
|data layout||N/A||Extra bytes between each successive data element|
|data type||Vertex Shader/||Low level data type (|
|data type||Vertex Shader||Components per element (|
|instancing||Attribute name||Enables/disables instancing|
|data access||N/A||Normalize integers to [-1,1], or [0,1] if unsigned|
|data access||N/A||Disable conversion of integer values to floats WebGL2|
sizevalues for attributes are read from the shaders when a program is created and linked, and normally do not need to be supplied. Also any attribute with
instancein its name will automatically be given an instance divisor of
divisoris automatically set to
1for any attribute that has some capitalization of
instancein the name.
strideare typically used to interleave data in buffers and are normally left undefined (i.e.
integerneed to be enabled by applications through an
Byte offset to start of data in buffer
Low level data type (GL.BYTE, GL.SHORT, GL.FLOAT, GL.INT, ...)
Number of (1-4 values per vertex)
true normalizes integer values (
GL.BYTE, ...). Signed values are normalized to [-1,1] and unsigned values are normalized to [0,1].
Disable conversion of integer values to floats.
Merges a number of partial accessors into a merged accessor that can be used to set vertex attributes. Any unspecified accessor properties will be set to their default values.
Note: Most applications do not need to merge accessors directly. Merging is done by the
Creates a new partial
Accessor. The new object will be immutable, i.e. its values cannot be changed after creation.
Returns the number of bytes per "element", based on the
type field in the accessor. Asserts if type is not set.
Returns the number of bytes per "vertex", based on the
size fields in the accessor. Asserts if
size are not set.
sizeare automatically inferred (through WebGL APIs that provide access to metadata extracted during compilation and linking of shader programs).
divisor- if attribute name starts with
instance...this will be automatically set to
strideare assumed to be 0 which corresponds to the simple non-interleaved case.
integer- if type is
GL.UINT, then integer is automatically true, as floating point shader inputs cannot be mapped to such attributes.