Skip to content

Rendering to multiple color textures? #611

Answered by bjornbytes
eigenbom asked this question in Q&A
Discussion options

You must be logged in to vote

Here's a minimal example demonstrating how to do it:

function lovr.load()
  t1 = lovr.graphics.newTexture(1, 1)
  t2 = lovr.graphics.newTexture(1, 1)
  t3 = lovr.graphics.newTexture(1, 1)

  shader = lovr.graphics.newShader('fill', [[
    layout(location = 1) out vec4 SecondColor;
    layout(location = 2) out vec4 ThirdColor;

    vec4 lovrmain() {
      SecondColor = vec4(0, 1, 0, 1);
      ThirdColor = vec4(0, 0, 1, 1);
      return vec4(1, 0, 0, 1);
    }
  ]])
end

function lovr.draw(pass)
  local gbuffer = lovr.graphics.getPass('render', { t1, t2, t3, samples = 1, depth = false })

  gbuffer:setShader(shader)
  gbuffer:fill()

  pass:setMaterial(t1)
  pass:plane(-1, 2, -3)

  pass:se…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by eigenbom
Comment options

You must be logged in to vote
1 reply
@bjornbytes
Comment options

Comment options

You must be logged in to vote
1 reply
@bjornbytes
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants