lovr.graphics.getPass

Creates and returns a temporary Pass object.


Create a compute or transfer pass.

pass = lovr.graphics.getPass(type)

Arguments

NameTypeDescription
typePassType The type of pass to create.

Returns

NameTypeDescription
passPass The new Pass.

Create a render pass.

pass = lovr.graphics.getPass(type, texture)

Arguments

NameTypeDescription
typePassType The type of pass to create.
textureTexture The texture the render pass will render to. Ignored for non-render passes.

Returns

NameTypeDescription
passPass The new Pass.

Create a render pass, with options.

pass = lovr.graphics.getPass(type, canvas)

Arguments

NameTypeDefaultDescription
typePassType The type of pass to create.
canvastable Render pass configuration. Up to 4 textures can be provided in table keys 1 through 4. Ignored for non-render passes.
.depthtable Depth/stencil buffer configuration. In addition to a table, it can be a Texture, a TextureFormat, or false to disable the depth buffer.
.formatTextureFormat'd32f' The format of the depth buffer texture, which must be a depth format (the ones that start with d). LÖVR will create or reuse an internal depth buffer with this format.
.textureTexture A Texture to use as the depth buffer. Takes precedence over format.
.clearnumber0 How to clear the depth buffer at the beginning of the pass. Can be a floating point number to clear each pixel to, true to do a "fast clear" that clears to random data, or false to not clear at all and instead load the depth texture's pixels.
.clear* How to clear the color textures at the beginning of the pass. If this is a boolean or a color, that value will be used for all color textures. It can also be a table of colors or booleans, one for each color texture. Colors may be provided as Vec3, Vec4, hexcodes, or tables of numbers. Note that tables of hexcode colors are ambiguous and therefore unsupported. When using a boolean, true means to do a "fast clear" that clears the texture to random data, and false means to not clear at all and instead load the texture's existing pixels.
.samplesnumber4 The number of multisamples to use. Can be 4 for antialiasing, or 1 to disable antialiasing.
.mipmapbooleanfalse Whether mipmaps for the color and depth textures should be regenerated after the pass is finished.

Returns

NameTypeDescription
passPass The new Pass.

Notes

Fun facts about render passes:

For compute and transfer passes, all of the commands in the pass act as though they run in parallel. This means that writing to the same element of a buffer twice, or writing to it and reading from it again is not guaranteed to work properly on all GPUs. LÖVR is not currently able to check for this. If compute or transfers need to be sequenced, multiple passes should be used. It is, however, completely fine to read and write to non-overlapping regions of the same buffer or texture.

See also