mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
Love 11.2
Now it runs with Love 11.2, but 'phosphor.glsl' should be revised.
This commit is contained in:
parent
eaade0dd3c
commit
cd5ac35662
@ -27,12 +27,13 @@ local util = require(_PACKAGE..'/util')
|
|||||||
local post_shader = {}
|
local post_shader = {}
|
||||||
post_shader.__index = 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 = {}
|
local shaders = {}
|
||||||
|
|
||||||
for i,v in ipairs(files) do
|
for i,v in ipairs(files) do
|
||||||
local name = _PACKAGE.."/shaders/postshaders".."/"..v
|
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 str = love.filesystem.read(name)
|
||||||
local effect = util.loadShader(name)
|
local effect = util.loadShader(name)
|
||||||
local defs = {}
|
local defs = {}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
// 0.5 = the spot stays inside the original pixel
|
// 0.5 = the spot stays inside the original pixel
|
||||||
// 1.0 = the spot bleeds up to the center of next pixel
|
// 1.0 = the spot bleeds up to the center of next pixel
|
||||||
|
|
||||||
#define PHOSPHOR_WIDTH 0.9
|
#define PHOSPHOR_WIDTH 0.9
|
||||||
#define PHOSPHOR_HEIGHT 0.65
|
#define PHOSPHOR_HEIGHT 0.65
|
||||||
|
|
||||||
@ -33,7 +34,7 @@
|
|||||||
|
|
||||||
// Uncomment to only draw every third pixel, which highlights the shape
|
// Uncomment to only draw every third pixel, which highlights the shape
|
||||||
// of individual (remaining) spots.
|
// of individual (remaining) spots.
|
||||||
// #define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
// Uncomment one of these to choose a gamma correction method.
|
// Uncomment one of these to choose a gamma correction method.
|
||||||
// If none are uncommented, no gamma correction is done.
|
// 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 B_IN = vec4(1.0) - A_IN;
|
||||||
vec4 A_OUT = vec4(6.0 - 15.0 * OutputGamma / 2.0 / (OutputGamma+1.0));
|
vec4 A_OUT = vec4(6.0 - 15.0 * OutputGamma / 2.0 / (OutputGamma+1.0));
|
||||||
vec4 B_OUT = vec4(1.0) - A_OUT;
|
vec4 B_OUT = vec4(1.0) - A_OUT;
|
||||||
|
uniform Image _tex0_;
|
||||||
|
|
||||||
#define GAMMA_IN(color) ( (A_IN + B_IN * color) * color * color )
|
#define GAMMA_IN(color) ( (A_IN + B_IN * color) * color * color )
|
||||||
#define GAMMA_OUT(color) ( A_OUT * sqrt(color) + B_OUT * sqrt( sqrt(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
|
#ifdef DEBUG
|
||||||
vec4 grid_color( vec2 coords )
|
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) )
|
if ( (mod(snes.x, 3.0) == 0.0) && (mod(snes.y, 3.0) == 0.0) )
|
||||||
return texture2D(_tex0_, coords);
|
return texture2D(_tex0_, coords);
|
||||||
else
|
else
|
||||||
|
@ -13,7 +13,7 @@ function util.drawCanvasToCanvas(canvas, other_canvas, options)
|
|||||||
|
|
||||||
util.drawto(other_canvas, 0, 0, 1, function()
|
util.drawto(other_canvas, 0, 0, 1, function()
|
||||||
if options["blendmode"] then
|
if options["blendmode"] then
|
||||||
love.graphics.setBlendMode(options["blendmode"])
|
love.graphics.setBlendMode(options["blendmode"], "premultiplied")
|
||||||
end
|
end
|
||||||
if options["shader"] then
|
if options["shader"] then
|
||||||
love.graphics.setShader(options["shader"])
|
love.graphics.setShader(options["shader"])
|
||||||
@ -60,6 +60,7 @@ function util.drawto(canvas, x, y, scale, cb)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function util.loadShader(name)
|
function util.loadShader(name)
|
||||||
|
print("loading:", name)
|
||||||
local shader = ""
|
local shader = ""
|
||||||
local externInit = {}
|
local externInit = {}
|
||||||
for line in love.filesystem.lines(name) do
|
for line in love.filesystem.lines(name) do
|
||||||
|
2
main.lua
2
main.lua
@ -27,7 +27,7 @@ function love.load()
|
|||||||
local n = 0
|
local n = 0
|
||||||
|
|
||||||
for i, v in ipairs(files) do
|
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
|
if is_file then
|
||||||
n = n + 1
|
n = n + 1
|
||||||
table.insert(exf.available, v);
|
table.insert(exf.available, v);
|
||||||
|
Loading…
Reference in New Issue
Block a user