From e74c0d8961ecf3b64c3d7cea02948a4486aa2f10 Mon Sep 17 00:00:00 2001 From: Tim Anema Date: Tue, 28 Oct 2014 21:03:00 -0400 Subject: [PATCH] fixed the light drawing with translation and scaling --- lib/init.lua | 2 +- lib/light.lua | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/init.lua b/lib/init.lua index e8aa2f9..1b83f90 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -180,7 +180,7 @@ function light_world:drawPixelShadow(l,t,w,h,s) self.pixelShadow2:clear() for i = 1, #self.lights do - self.lights[i]:drawPixelShadow(l,t,w,h, self.normalMap, self.pixelShadow2) + self.lights[i]:drawPixelShadow(l,t,w,h,s, self.normalMap, self.pixelShadow2) end self.pixelShadow:clear(255, 255, 255) diff --git a/lib/light.lua b/lib/light.lua index 86c732a..1804fcd 100644 --- a/lib/light.lua +++ b/lib/light.lua @@ -129,7 +129,7 @@ function light:drawShadow(l,t,w,h,s,bodies, canvas) self.shadow:clear() util.drawto(self.shadow, l, t, s, function() - self.shader:send("lightPosition", {(self.x + l/s) * s, (h/s - (self.y + t/s)) * s, self.z}) + self.shader:send("lightPosition", {(self.x + l/s) * s, (h/s - (self.y + t/s)) * s, self.z/255.0}) self.shader:send("lightRange", self.range*s) self.shader:send("lightColor", {self.red / 255.0, self.green / 255.0, self.blue / 255.0}) self.shader:send("lightSmooth", self.smooth) @@ -182,11 +182,11 @@ function light:drawShine(l,t,w,h,s,bodies,canvas) end end -function light:drawPixelShadow(l,t,w,h, normalMap, canvas) +function light:drawPixelShadow(l,t,w,h,s, normalMap, canvas) if self.visible then if self.normalInvert then self.normalInvertShader:send('lightColor', {self.red / 255.0, self.green / 255.0, self.blue / 255.0}) - self.normalInvertShader:send('lightPosition',{self.x, h - self.y, self.z / 255.0}) + self.normalInvertShader:send("lightPosition", {(self.x + l/s) * s, (h/s - (self.y + t/s)) * s, self.z / 255.0}) self.normalInvertShader:send('lightRange',{self.range}) self.normalInvertShader:send("lightSmooth", self.smooth) self.normalInvertShader:send("lightAngle", math.pi - self.angle / 2.0) @@ -194,7 +194,7 @@ function light:drawPixelShadow(l,t,w,h, normalMap, canvas) util.drawCanvasToCanvas(normalMap, canvas, {shader = self.normalInvertShader}) else self.normalShader:send('lightColor', {self.red / 255.0, self.green / 255.0, self.blue / 255.0}) - self.normalShader:send('lightPosition',{self.x, h - self.y, self.z / 255.0}) + self.normalShader:send("lightPosition", {(self.x + l/s) * s, (h/s - (self.y + t/s)) * s, self.z / 255.0}) self.normalShader:send('lightRange',{self.range}) self.normalShader:send("lightSmooth", self.smooth) self.normalShader:send("lightAngle", math.pi - self.angle / 2.0)