From 5cbca9f63c60feb0bb3b5ba07ac897f3975226ac Mon Sep 17 00:00:00 2001 From: Tim Anema Date: Wed, 3 Dec 2014 08:31:09 -0500 Subject: [PATCH] took care of default polygon normal map problems show up at edges --- README.md | 1 - examples/short.lua | 8 +++++++- lib/body.lua | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c6b346..df549f9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ :todoing -make sure all draw calls check if the object is within range --refactor rectablges to be polygons to reduce code -optimize shadow body calculations and drawing methods # light_world.lua diff --git a/examples/short.lua b/examples/short.lua index 5d25f0c..a316015 100644 --- a/examples/short.lua +++ b/examples/short.lua @@ -31,7 +31,12 @@ function love.load() -- create shadow bodys circleTest = lightWorld:newCircle(256, 256, 16) rectangleTest = lightWorld:newRectangle(512, 512, 64, 64) - polygonTest = lightWorld:newPolygon(100, 200, 120, 200, 150, 250, 100, 250) + local px, py, pw, ph = 100, 200, 20, 50 + polygonTest = lightWorld:newPolygon( + px, py, + px+pw, py, + px+pw, py+ph, + px-50, py+ph) imageTest = lightWorld:newImage(image, 64, 64, 24, 6) imageTest:setNormalMap(image_normal) @@ -160,6 +165,7 @@ function love.draw() end) love.graphics.pop() + love.graphics.setBlendMode("alpha") love.graphics.setColor(0, 0, 0, 191) love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), 24) diff --git a/lib/body.lua b/lib/body.lua index 313c64a..ad16dff 100644 --- a/lib/body.lua +++ b/lib/body.lua @@ -244,6 +244,7 @@ function body:setPoints(...) self.height = self.height - self.y for i = 1, #points, 2 do points[i], points[i+1] = points[i] - self.x, points[i+1] - self.y + print(points[i], points[i+1]) end poly_canvas = love.graphics.newCanvas(self.width, self.height) @@ -256,6 +257,9 @@ function body:setPoints(...) self.ix = self.imgWidth * 0.5 self.iy = self.imgHeight * 0.5 self:generateNormalMapFlat("top") + --wrapping with polygon normals causes edges to show + --also we do not need wrapping for this default normal map + self.normal:setWrap("clamp", "clamp") self.nx, self.ny = 0, 0 self:setShadowType('polygon', ...)