Pass:send
EditSends a value to a variable in the Pass's active Shader
. The active shader is changed using Pass:setShader
.
Arguments
Name | Type | Default | Description |
name | string | The name of the Shader variable. | |
buffer | Buffer | The Buffer to assign. | |
offset | number | 0 | An offset from the start of the buffer where data will be read, in bytes. |
extent | number | 0 |
The number of bytes that will be available for reading. If zero, as much data as possible will be bound, depending on the offset, buffer size, and the uniformBufferRange or storageBufferRange limit.
|
Returns
Nothing
Arguments
Name | Type | Description |
name | string | The name of the Shader variable. |
texture | Texture | The Texture to assign. |
Returns
Nothing
Arguments
Name | Type | Description |
name | string | The name of the Shader variable. |
sampler | Sampler | The Sampler to assign. |
Returns
Nothing
Arguments
Name | Type | Description |
name | string | The name of the Shader variable. |
data | * | Numbers, booleans, vectors, or tables to assign to the data or uniform buffer. |
Returns
Nothing
Notes
The new value will persist until a new shader is set that uses a different "type" for the binding number of the variable. See Pass:setShader
for more details.
Example
function lovr.load()
shader = lovr.graphics.newShader([[
uniform sampler mySampler;
uniform Colors { vec4 colors[256]; };
uniform texture2D rocks;
uniform uint constant;
vec4 lovrmain() {
return DefaultPosition;
}
]], 'unlit')
clampler = lovr.graphics.newSampler({ wrap = 'clamp' })
colorBuffer = lovr.graphics.newBuffer(256, 'vec4')
rockTexture = lovr.graphics.newTexture('rocks.jpg')
end
function lovr.draw(pass)
pass:setShader(shader)
pass:send('mySampler', clampler)
pass:send('Colors', colorBuffer)
pass:send('rocks', rockTexture)
pass:send('constant', 42)
-- Draw
end