From 5e8ef63d6d5ec90dd6415ae1fd67c9ba53b8439a Mon Sep 17 00:00:00 2001 From: Tim Anema Date: Thu, 23 Oct 2014 12:17:28 -0400 Subject: [PATCH] fixed light position --- examples/short.lua | 2 +- lib/light.lua | 2 +- lib/shaders/poly_shadow.glsl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/short.lua b/examples/short.lua index 550c020..9f62a91 100644 --- a/examples/short.lua +++ b/examples/short.lua @@ -80,7 +80,7 @@ function love.update(dt) scale = scale + 0.01 end - lightMouse:setPosition(love.mouse.getX(), love.mouse.getY()) + lightMouse:setPosition(love.mouse.getX()/scale, love.mouse.getY()/scale) end function love.draw() diff --git a/lib/light.lua b/lib/light.lua index fb90de5..f1babd9 100644 --- a/lib/light.lua +++ b/lib/light.lua @@ -145,7 +145,7 @@ function light:drawShadow(l,t,w,h,s,bodies, canvas) -- draw shadow self.shadow:clear() util.drawto(self.shadow, l, t, s, function() - self.shader:send("lightPosition", {self.x + l, h - (self.y + t), self.z}) + self.shader:send("lightPosition", {self.x*s, (h/s - self.y)*s, self.z}) self.shader:send("lightRange", self.range) self.shader:send("lightColor", {self.red / 255.0, self.green / 255.0, self.blue / 255.0}) self.shader:send("lightSmooth", self.smooth) diff --git a/lib/shaders/poly_shadow.glsl b/lib/shaders/poly_shadow.glsl index ba8ae77..dde39e4 100644 --- a/lib/shaders/poly_shadow.glsl +++ b/lib/shaders/poly_shadow.glsl @@ -38,4 +38,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ } return pixel; -} \ No newline at end of file +}