NEED A HELP WITH "love2D mutiplicative blend mode "
Posted: Thu Jul 02, 2015 5:52 am
Code: Select all
Background = love.graphics.newImage("background.png")
LightTexture = love.graphics.newImage("light_texture.png")
LightCanvas = {}
function love.draw()
love.graphics.setBlendMode("alpha")
love.graphics.setColor(255,0,255)
love.graphics.draw( LightCanvas.canvas, LightCanvas.quad, 0, 0)
love.graphics.setBlendMode("multiplicative")
love.graphics.setColor(255,255,255)
love.graphics.draw(Background, 0, 0)
end
function love.load()
love.window.setTitle("light engine implementation")
love.window.setMode(800, 600)
LightCanvas.canvas = love.graphics.newCanvas(love.window.getWidth(), love.window.getHeight())
LightCanvas.canvas:clear( 0, 0, 0 )
LightCanvas.quad = love.graphics.newQuad(0, 0, LightCanvas.canvas:getWidth(), LightCanvas.canvas:getHeight(), LightCanvas.canvas:getWidth(), LightCanvas.canvas:getHeight())
love.graphics.setBackgroundColor( 0, 0, 0 )
end
function love.update(dt)
LightCanvas.canvas:clear( 0, 0, 0 )
LightCanvas.canvas:renderTo(function()
love.graphics.draw(LightTexture, 0, 0)
end)
end
Im trying to make a 2D lighting by using mutipicative blending mode. but when I run this code, screen is just all black and nothing appears.
it works fine when I use just texture itself but when I use canvas, it just doesn't work.
can anyone help with it?