buffer
Tag: buffer
Parent tag: buffers
Attributes: name
(string)
Child tags:
SIZE
(int) – the size in bytesDIM
(uivec3) – the number of structs in each dimension, like a 3D array. To be used in combination withstructure
structure
– the definition of the structure.CLEAR
(enum) – {NEVER
(default),BY_FRAME
}. IfBY_FRAME
is specified the buffer will be filled with zeroes at the beginning of each frame.file
(string) – a file name for the buffer initial contents.
This tag defines a buffer that can later be used in a material.
The buffer’s size can be specified either in bytes or using a friendlier notation based on a structure. This last approach requires the definition of a structure
with the types of each field, and the definition of dimensions (x, y, and z).
In the example below, buffers hits and hits2 have the same size.
Example:
<buffer name="hits"> <SIZE value=150994944 /> </buffer> <buffer name="hits2"> <DIM x=1024 y=1024 z=9 /> <structure> <field value="FLOAT" /> <field value="INT" /> <field value="FLOAT" /> <field value="FLOAT" /> </structure> </buffer> <buffer name="atomicsBuffer"> <SIZE value=16 /> <CLEAR value="BY_FRAME" /> </buffer>
The initial buffer contents can also be loaded from a text file. In this case the DIM
and structure
are required to describe the file structure. For instance consider the following buffer definition:
<buffer name="myBuffer"> <DIM x=5 y=1 z=1 /> <structure> <field value="FLOAT" /> <field value="INT" /> </structure> <file name="myBufferContents.txt" /> </buffer>
The DIM
field specifies that there will be 5 items. Each item will have a float and a int according to the filed structure
. An example of such a file is:
5.0 1 4.0 2 3.0 3 2.0 4 1.0 5