From 1c697863867238ce217c9b46a3b29634ea93e560 Mon Sep 17 00:00:00 2001 From: flamendless Date: Wed, 30 May 2018 11:45:58 +0800 Subject: [PATCH] fixed canvas needing stencil = true --- lib/init.lua | 2 ++ lib/util.lua | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/init.lua b/lib/init.lua index 2067d54..96433f0 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -131,6 +131,7 @@ function light_world:drawShadows(l,t,w,h,s) love.graphics.setCanvas( self.shadowMap ) love.graphics.clear() love.graphics.setCanvas() + util.drawto(self.shadowMap, l, t, s, function() --I dont know if it uses both or just calls both love.graphics.stencil(function() @@ -154,6 +155,7 @@ function light_world:drawShadows(l,t,w,h,s) end end end) + -- draw scene for this light using normals and shadowmap self.shadowShader:send('lightColor', {light.red / 255.0, light.green / 255.0, light.blue / 255.0}) self.shadowShader:send("lightPosition", {(light.x + l/s) * s, (light.y + t/s) * s, (light.z * 10) / 255.0}) diff --git a/lib/util.lua b/lib/util.lua index d2c7d71..26fab60 100644 --- a/lib/util.lua +++ b/lib/util.lua @@ -51,7 +51,7 @@ function util.drawto(canvas, x, y, scale, cb) local last_buffer = love.graphics.getCanvas() love.graphics.push() love.graphics.origin() - love.graphics.setCanvas(canvas) + love.graphics.setCanvas({canvas,stencil = true}) love.graphics.translate(x, y) love.graphics.scale(scale) cb()