Pass:send

Sends a value to a variable in the Pass's active Shader. The active shader is changed using using Pass:setShader.


Pass:send(name, buffer)

Arguments

NameTypeDescription
namestring The name of the Shader variable.
bufferBuffer The Buffer to assign.

Returns

Nothing


Pass:send(name, texture)

Arguments

NameTypeDescription
namestring The name of the Shader variable.
textureTexture The Texture to assign.

Returns

Nothing


Pass:send(name, sampler)

Arguments

NameTypeDescription
namestring The name of the Shader variable.
samplerSampler The Sampler to assign.

Returns

Nothing


Pass:send(name, constant)

Arguments

NameTypeDescription
namestring The name of the Shader variable.
constant* Numbers or vectors to assign to the push constant.

Returns

Nothing


Pass:send(binding, buffer)

Arguments

NameTypeDescription
bindingnumber The binding number of the Shader variable.
bufferBuffer The Buffer to assign.

Returns

Nothing


Pass:send(binding, texture)

Arguments

NameTypeDescription
bindingnumber The binding number of the Shader variable.
textureTexture The Texture to assign.

Returns

Nothing


Pass:send(binding, sampler)

Arguments

NameTypeDescription
bindingnumber The binding number of the Shader variable.
samplerSampler The Sampler to assign.

Returns

Nothing

Notes

Shader variables can be in different "sets". Variables changed by this function must be in set #2, because LÖVR uses set #0 and set #1 internally.

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([[
    layout(set = 2, binding = 0) uniform sampler mySampler;
    layout(set = 2, binding = 1) uniform Colors { vec4 colors[256]; };
    layout(set = 2, binding = 2) uniform texture2D rocks;

    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)
  -- Draw
end

See also