Replicating old "subtractive" blend mode [SOLVED]
Posted: Sat May 14, 2016 4:33 pm
Hello, löve community,
To fully explain my problem, I'll explain how my game is set up.
To have a fog of war, I have a fully black canvas. I also have an image with transparent background with a white circle (edges smoothed out) in it.
What this accomplished is it erased the part of canvas (where player walks). It looks the same as if you use eraser in any image editor on a black background with smooth brush.
Now here's the problem: In new version (0.10.1), the blend mode "subtract" does NOT modify alpha in any way, and none of the alpha blend modes accomplish the same thing as old "subtractive" blend mode.
I can use something like this (setCanvas functions left out):
And it accomplishes what is needed, kinda. The circle isn't smooth, resulting in a rough looking fog of war.
To fully explain my problem, I'll explain how my game is set up.
To have a fog of war, I have a fully black canvas. I also have an image with transparent background with a white circle (edges smoothed out) in it.
Code: Select all
love.graphics.setCanvas(self.map.fow_canvas) -- the black canvas
love.graphics.setColor(0,0,0,255)
love.graphics.setBlendMode("subtractive")
-- FOW_PUNCH: the aforementioned image
love.graphics.draw(FOW_PUNCH, entity.x-FOW_PUNCH:getWidth()/2, entity.y - FOW_PUNCH:getHeight()/2)
love.graphics.setBlendMode("alpha")
love.graphics.setCanvas()
Now here's the problem: In new version (0.10.1), the blend mode "subtract" does NOT modify alpha in any way, and none of the alpha blend modes accomplish the same thing as old "subtractive" blend mode.
I can use something like this (setCanvas functions left out):
Code: Select all
love.graphics.setColor(255,255,255,0)
love.graphics.setBlendMode("replace")
love.graphics.circle("fill", player.x, player.y, 300 )