diff --git a/lib/init.lua b/lib/init.lua index 09619ac..c48abbb 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -138,6 +138,9 @@ function light_world:drawNormalShading(l,t,w,h,s) self.bodies[k]:drawShadow(light) end end + local angle = math.pi - light.angle / 2.0 + love.graphics.setColor(0, 0, 0) + love.graphics.arc("fill", light.x, light.y, light.range, light.direction - angle, light.direction + angle) end) -- draw scene for this light using normals and shadowmap self.shadowShader:send('shadowMap', self.shadowMap) @@ -146,8 +149,6 @@ function light_world:drawNormalShading(l,t,w,h,s) self.shadowShader:send('lightRange',{light.range * s}) self.shadowShader:send("lightSmooth", light.smooth) self.shadowShader:send("lightGlow", {1.0 - light.glowSize, light.glowStrength}) - self.shadowShader:send("lightAngle", math.pi - light.angle / 2.0) - self.shadowShader:send("lightDirection", light.direction) self.shadowShader:send("invert_normal", self.normalInvert == true) util.drawCanvasToCanvas(self.normalMap, self.normal2, { blendmode = 'additive', diff --git a/lib/shaders/shadow.glsl b/lib/shaders/shadow.glsl index bb623b1..31b300e 100644 --- a/lib/shaders/shadow.glsl +++ b/lib/shaders/shadow.glsl @@ -14,15 +14,6 @@ extern float lightAngle; //if set, the light becomes directional to a slice extern float lightDirection; //which direction to shine the light in if directional in degrees extern bool invert_normal; //if the light should invert normals -//calculate if a pixel is within the light slice -bool not_in_slice(vec2 pixel_coords){ - float angle = atan(lightPosition.x - pixel_coords.x, pixel_coords.y - lightPosition.y) + PI; - bool pastRightSide = angle < mod(lightDirection + lightAngle, PI * 2); - bool pastLeftSide = angle > mod(lightDirection - lightAngle, PI * 2); - bool lightUp = lightDirection - lightAngle > 0 && lightDirection + lightAngle < PI * 2; - return (lightUp && (pastRightSide && pastLeftSide)) || (!lightUp && (pastRightSide || pastLeftSide)); -} - vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { vec4 pixelColor = Texel(texture, texture_coords); vec4 shadowColor = Texel(shadowMap, texture_coords); @@ -33,11 +24,6 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { //not in range draw in shadows return vec4(0.0, 0.0, 0.0, 1.0); }else{ - //if the light is a slice and the pixel is not inside - if(lightAngle > 0.0 && not_in_slice(pixel_coords)) { - return vec4(0.0, 0.0, 0.0, 1.0); - } - vec3 normal; if(pixelColor.a > 0.0) { //if on the normal map ie there is normal map data