vrld / moonshine

Postprocessing effect repository for LÖVE
538 stars 35 forks source link

Effects don't seem to stack #52

Open tomlum opened 5 years ago

tomlum commented 5 years ago

Hey! I'm running love 11.2 on a mac, and whenever I try to layer on blurs like this

blur1 = moonshine(moonshine.effects.boxblur)
blur2 = moonshine(moonshine.effects.boxblur)

blur1(function()
   lg.draw()
end)

blur2(function()
   lg.draw()
end)

anything before the second blur just turns to white. Am I misunderstanding how this is supposed to work? Are these shaders not stackable?

Thanks!

gustavostuff commented 4 years ago

I just noticed this and it's a bummer, the cause is probably that it's using the same canvas internally and it wipes it clean before using any effect.

vrld commented 4 years ago

moonshine uses double buffering (see moonshine.draw_shader() and chain.draw(). From what I understand this seems to be a issue with the blend mode. Can you check if changing the blend mode in init.lua:75 to this fixes the issue?

love.graphics.setBlendMode("screen", "premultiplied")
gustavostuff commented 4 years ago

Tried that but it doesn't seem to work. I also tried the other blend modes just in case.

vrld commented 4 years ago

Can you please give a code example that produces the bug? On my end, this will only show the second rectangle with blend mode "alpha" in init.lua, but both rectangles with blend "screen":

function love.load()
  blur1 = moonshine(moonshine.effects.boxblur)
  blur2 = moonshine(moonshine.effects.boxblur)
end

function love.draw()
  blur1(love.graphics.rectangle, 'fill', 100, 100, 100, 100)
  blur2(love.graphics.rectangle, 'fill', 220, 100, 100, 100)
end