From d56b4ca660f62a1565d1abb959ce55cdf1b87f28 Mon Sep 17 00:00:00 2001 From: Tim Anema Date: Fri, 26 Sep 2014 13:42:00 -0400 Subject: [PATCH] fixed the scanlines shader --- lib/light_world.lua | 1 - lib/postshader.lua | 3 +-- shader/scanlines.glsl | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/light_world.lua b/lib/light_world.lua index 47fe140..aec51ac 100644 --- a/lib/light_world.lua +++ b/lib/light_world.lua @@ -290,7 +290,6 @@ function light_world:update() love.graphics.setBlendMode("alpha") end - print(self.optionGlow, self.isGlow) if self.optionGlow and self.isGlow then -- create glow map self.glowMap:clear(0, 0, 0) diff --git a/lib/postshader.lua b/lib/postshader.lua index 98c7aa9..5e59a18 100644 --- a/lib/postshader.lua +++ b/lib/postshader.lua @@ -121,14 +121,13 @@ love.postshader.addEffect = function(shader, ...) love.graphics.draw(LOVE_POSTSHADER_BUFFER_RENDER) elseif shader == "scanlines" then -- Scanlines Shader - --LOVE_POSTSHADER_SCANLINES:send("screen", {love.window.getWidth(), love.window.getHeight()}) + LOVE_POSTSHADER_SCANLINES:send("screen", {love.window.getWidth(), love.window.getHeight()}) LOVE_POSTSHADER_SCANLINES:send("strength", args[1] or 2.0) LOVE_POSTSHADER_SCANLINES:send("time", args[2] or love.timer.getTime()) love.graphics.setShader(LOVE_POSTSHADER_SCANLINES) love.graphics.draw(LOVE_POSTSHADER_BUFFER_RENDER) elseif shader == "tiltshift" then -- Blur Shader - LOVE_POSTSHADER_BLURV:send("screen", {love.window.getWidth(), love.window.getHeight()}) LOVE_POSTSHADER_BLURH:send("screen", {love.window.getWidth(), love.window.getHeight()}) LOVE_POSTSHADER_BLURV:send("steps", args[1] or 2.0) LOVE_POSTSHADER_BLURH:send("steps", args[1] or 2.0) diff --git a/shader/scanlines.glsl b/shader/scanlines.glsl index 0f677aa..72b68ec 100644 --- a/shader/scanlines.glsl +++ b/shader/scanlines.glsl @@ -1,9 +1,9 @@ -extern vec2 screenHeight = vec2(800.0, 600.0); +extern vec2 screen = vec2(800.0, 600.0); extern float strength = 2.0; extern float time = 0.0; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ - vec2 pSize = 1.0 / screenHeight; + vec2 pSize = 1.0 / screen; float brightness = 1.0; float offsetX = sin(texture_coords.y * 10.0 + time * strength) * pSize.x; float corner = 500.0; @@ -25,9 +25,9 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ float green = Texel(texture, vec2(texture_coords.x + offsetX, texture_coords.y - pSize.y * 0.5)).g; float blue = Texel(texture, vec2(texture_coords.x + offsetX, texture_coords.y)).b; - if(mod(texture_coords.y * screenHeight.y, 2.0) > 0.5) { + if(mod(texture_coords.y * screen.y, 2.0) > 0.5) { return vec4(vec3(red, green, blue) * brightness, 1.0); } else { return vec4(vec3(red * 0.75, green * 0.75, blue * 0.75) * brightness, 1.0); } -} \ No newline at end of file +}