Pass:setCanvas
EditSets the Pass's canvas. The canvas is a set of textures that the Pass will draw to when it's submitted, along with configuration for the depth buffer and antialiasing.
Arguments
Name | Type | Description |
...textures | Texture | One or more color textures the pass will render to. |
Returns
Nothing
Arguments
Name | Type | Default | Description |
canvas | table | The canvas. Each numeric key is a color texture to render to (up to 4), along with the following keys to control depth buffer and antialiasing settings: | |
.depth | * | d32f |
A Texture or TextureFormat with the depth buffer.
|
.samples | number | 4 | The number of multisamples used for antialiasing (either 1 or 4). |
Returns
Nothing
Disable the canvas. Any draws in the Pass will be skipped when it is submitted (compute shaders will still run though).
Arguments
None
Returns
Nothing
Notes
Changing the canvas will reset the pass, as though Pass:reset
was called.
All textures must have the same dimensions, layer counts, and multisample counts. They also must have been created with the render
usage flag.
The number of layers in the textures determines how many views (cameras) the pass has. Each draw will be rendered to all texture layers, as seen from the corresponding camera. For example, VR rendering will use a canvas texture with 2 layers, one for each eye.
To render to a specific mipmap level or layer of a texture, use texture views (lovr.graphics.newTextureView
).
Mipmaps will be regenerated for all of canvas textures at the end of a render pass.
If the Pass has multiple color textures, a fragment shader should be used to write a different color to each texture. Here's an example that writes red to the first texture and blue to the second texture:
// Declare an output variable for the second texture
layout(location = 1) out vec4 secondColor;
vec4 lovrmain() {
secondColor = vec4(0, 0, 1, 1);
return vec4(1, 0, 0, 1);
}