Page 1 of 1

Premultiplied alpha

Posted: Thu May 17, 2018 7:43 am
by veethree
I'm trying to draw a canvas with the "multiply" blend mode but it throws an error.

Code: Select all

Error

data/class/light.lua:41: The 'multiply' blend mode must be used with premultiplied alpha.


Traceback

[C]: in function 'setBlendMode'
data/class/light.lua:41: in function 'draw'
data/state/game.lua:131: in function 'draw'
data/class/state.lua:41: in function 'draw'
main.lua:163: in function 'draw'
[C]: in function 'xpcall'
I don't get it.

Re: Premultiplied alpha

Posted: Thu May 17, 2018 8:15 am
by grump

Code: Select all

love.graphics.setBlendMode('multiply', 'premultiplied')
It's a questionable design choice, but this is how you have to set the multiply blendmode.

Re: Premultiplied alpha

Posted: Thu May 17, 2018 8:29 am
by veethree
Oh. I didn't realise that setBlendMode had a 2nd argument. You'd think if you need premultiplied alpha to use the multiply blend mode it would default to that.
Or the error would indicate that it needs a 2nd argument.