|
@@ -2,16 +2,16 @@ return {
|
|
|
summary = 'A block of memory on the GPU.',
|
|
|
description = [[
|
|
|
A Buffer is a block of GPU memory. Buffers are similar to Lua tables or arrays: they have a
|
|
|
- length and store a list of values. The length of a Buffer and its format (the types of values
|
|
|
- it stores) are declared upfront and can't be changed. The data for a Buffer is stored in VRAM,
|
|
|
- allowing Shaders running on the GPU to access the Buffer data.
|
|
|
+ length and store a list of values. The length of a Buffer and its format (the type of each
|
|
|
+ value) are declared upfront and can't be changed. Each value of a Buffer consists of one or
|
|
|
+ more fields, and each field has a type. For example, if a Buffer is used to store vertices,
|
|
|
+ each value might store 3 fields for the position, normal vector, and UV coordinates of a vertex.
|
|
|
|
|
|
Buffers are commonly used for:
|
|
|
|
|
|
- - Mesh data: Buffers hold the data that define the vertices in a mesh, like positions, normals,
|
|
|
- and UV coordinates. Buffers also store the vertex indices of a mesh, which define how the
|
|
|
- vertices are connected together into triangles. These are respectively called vertex and
|
|
|
- index buffers.
|
|
|
+ - Mesh data: Buffers hold the data that define the vertices in a mesh. Buffers also store the
|
|
|
+ vertex indices of a mesh, which define the order the vertices are connected together into
|
|
|
+ triangles. These are often called vertex buffers and index buffers.
|
|
|
- Shader data: Buffers can be bound to a Shader, letting the Shader read arbitrary data. For
|
|
|
example, Lua code could create a Buffer with the positions and colors of all the lights in a
|
|
|
scene, which a Shader can use to do lighting calculations.
|
|
@@ -31,8 +31,6 @@ return {
|
|
|
recreated every frame. They often have faster performance when used by the GPU, and compute
|
|
|
shaders can write to them. They are great for large pieces of data that are initialized once
|
|
|
at load time, or data that is updated infrequently.
|
|
|
-
|
|
|
- Choose wisely!
|
|
|
]],
|
|
|
constructors = {
|
|
|
'lovr.graphics.buffer',
|