diff --git a/lib/postshader.lua b/lib/postshader.lua index ee55f55..088a9e3 100644 --- a/lib/postshader.lua +++ b/lib/postshader.lua @@ -27,12 +27,13 @@ local util = require(_PACKAGE..'/util') local post_shader = {} post_shader.__index = post_shader -local files = love.filesystem.getInfo(_PACKAGE .. "/shaders/postshaders") +local files = love.filesystem.getDirectoryItems(_PACKAGE .. "/shaders/postshaders") local shaders = {} for i,v in ipairs(files) do local name = _PACKAGE.."/shaders/postshaders".."/"..v - if love.filesystem.isFile(name) then + inf = love.filesystem.getInfo(name) + if love.filesystem.getInfo(name).type == "file" then local str = love.filesystem.read(name) local effect = util.loadShader(name) local defs = {} diff --git a/lib/shaders/postshaders/phosphor.glsl b/lib/shaders/postshaders/phosphor.glsl index b799f9c..d2c1264 100644 --- a/lib/shaders/postshaders/phosphor.glsl +++ b/lib/shaders/postshaders/phosphor.glsl @@ -21,6 +21,7 @@ // 0.5 = the spot stays inside the original pixel // 1.0 = the spot bleeds up to the center of next pixel + #define PHOSPHOR_WIDTH 0.9 #define PHOSPHOR_HEIGHT 0.65 @@ -33,7 +34,7 @@ // Uncomment to only draw every third pixel, which highlights the shape // of individual (remaining) spots. -// #define DEBUG +//#define DEBUG // Uncomment one of these to choose a gamma correction method. // If none are uncommented, no gamma correction is done. @@ -61,6 +62,8 @@ vec4 A_IN = vec4( 12.0/(InputGamma+1.0)-3.0 ); vec4 B_IN = vec4(1.0) - A_IN; vec4 A_OUT = vec4(6.0 - 15.0 * OutputGamma / 2.0 / (OutputGamma+1.0)); vec4 B_OUT = vec4(1.0) - A_OUT; +uniform Image _tex0_; + #define GAMMA_IN(color) ( (A_IN + B_IN * color) * color * color ) #define GAMMA_OUT(color) ( A_OUT * sqrt(color) + B_OUT * sqrt( sqrt(color) ) ) @@ -78,7 +81,7 @@ vec4 B_IN = vec4(1.0) - A_IN; #ifdef DEBUG vec4 grid_color( vec2 coords ) { - vec2 snes = floor( coords * love_ScreenSize ); + vec2 snes = floor( coords * love_ScreenSize.xy ); if ( (mod(snes.x, 3.0) == 0.0) && (mod(snes.y, 3.0) == 0.0) ) return texture2D(_tex0_, coords); else diff --git a/lib/util.lua b/lib/util.lua index 26fab60..d4fad45 100644 --- a/lib/util.lua +++ b/lib/util.lua @@ -13,7 +13,7 @@ function util.drawCanvasToCanvas(canvas, other_canvas, options) util.drawto(other_canvas, 0, 0, 1, function() if options["blendmode"] then - love.graphics.setBlendMode(options["blendmode"]) + love.graphics.setBlendMode(options["blendmode"], "premultiplied") end if options["shader"] then love.graphics.setShader(options["shader"]) @@ -60,6 +60,7 @@ function util.drawto(canvas, x, y, scale, cb) end function util.loadShader(name) + print("loading:", name) local shader = "" local externInit = {} for line in love.filesystem.lines(name) do diff --git a/main.lua b/main.lua index 0fe66b2..f4aba07 100644 --- a/main.lua +++ b/main.lua @@ -27,7 +27,7 @@ function love.load() local n = 0 for i, v in ipairs(files) do - is_file = love.filesystem.isFile("examples/".. v ) + is_file = (love.filesystem.getInfo("examples/".. v ).type == "file") if is_file then n = n + 1 table.insert(exf.available, v); @@ -292,13 +292,13 @@ function List:mousepressed(mx, my, b) if b == "wd" then self.bar_pos = self.bar_pos + bar_pixel_dt - if self.bar_pos > self.bar_max_pos then - self.bar_pos = self.bar_max_pos + if self.bar_pos > self.bar_max_pos then + self.bar_pos = self.bar_max_pos end elseif b == "wu" then self.bar_pos = self.bar_pos - bar_pixel_dt - if self.bar_pos < 0 then - self.bar_pos = 0 + if self.bar_pos < 0 then + self.bar_pos = 0 end end end @@ -344,9 +344,9 @@ function List:draw() -- Get interval to display. local start_i = math.floor( self:getOffset()/(self.item_height+1) ) + 1 local end_i = start_i+math.floor( self.height/(self.item_height+1) ) + 1 - - if end_i > self.items.n then - end_i = self.items.n + + if end_i > self.items.n then + end_i = self.items.n end love.graphics.setScissor(self.x, self.y, self.width, self.height)