moonshine icon indicating copy to clipboard operation
moonshine copied to clipboard

Effects don't seem to stack

Open tomlum opened this issue 6 years ago • 4 comments

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!

tomlum avatar Sep 07 '19 04:09 tomlum

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.

gustavostuff avatar Apr 30 '20 19:04 gustavostuff

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")

vrld avatar May 01 '20 14:05 vrld

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

gustavostuff avatar May 02 '20 19:05 gustavostuff

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

vrld avatar May 02 '20 20:05 vrld