From 0691826e0775ae1023d1652972c1c71145a42769 Mon Sep 17 00:00:00 2001 From: Kyle McLamb Date: Sat, 30 Apr 2016 09:37:28 -0400 Subject: [PATCH] Store shaders as lua strings --- lib/body.lua | 4 ++-- lib/init.lua | 8 ++++---- lib/postshader.lua | 7 ++++--- lib/shaders/{glow.glsl => glow.lua} | 2 ++ lib/shaders/{image_mask.glsl => image_mask.lua} | 2 ++ lib/shaders/{material.glsl => material.lua} | 4 +++- .../{black_and_white.glsl => black_and_white.lua} | 6 ++++-- lib/shaders/postshaders/{blurh.glsl => blurh.lua} | 2 ++ lib/shaders/postshaders/{blurv.glsl => blurv.lua} | 2 ++ ...omatic_aberration.glsl => chromatic_aberration.lua} | 2 ++ .../postshaders/{contrast.glsl => contrast.lua} | 2 ++ .../postshaders/{curvature.glsl => curvature.lua} | 2 ++ lib/shaders/postshaders/{edges.glsl => edges.lua} | 8 ++++---- .../postshaders/{four_colors.glsl => four_colors.lua} | 4 +++- lib/shaders/postshaders/{hdr_tv.glsl => hdr_tv.lua} | 4 +++- .../postshaders/{monochrome.glsl => monochrome.lua} | 6 ++++-- .../postshaders/{phosphor.glsl => phosphor.lua} | 4 +++- .../postshaders/{phosphorish.glsl => phosphorish.lua} | 3 ++- lib/shaders/postshaders/{pip.glsl => pip.lua} | 7 ++++--- .../postshaders/{pixellate.glsl => pixellate.lua} | 2 ++ .../postshaders/{radialblur.glsl => radialblur.lua} | 2 ++ .../postshaders/{scanlines.glsl => scanlines.lua} | 2 ++ .../postshaders/{tilt_shift.glsl => tilt_shift.lua} | 2 ++ .../postshaders/{waterpaint.glsl => waterpaint.lua} | 10 ++++++---- lib/shaders/{reflection.glsl => reflection.lua} | 2 ++ lib/shaders/{refraction.glsl => refraction.lua} | 2 ++ lib/shaders/{shadow.glsl => shadow.lua} | 3 ++- 27 files changed, 74 insertions(+), 30 deletions(-) rename lib/shaders/{glow.glsl => glow.lua} (97%) rename lib/shaders/{image_mask.glsl => image_mask.lua} (93%) rename lib/shaders/{material.glsl => material.lua} (93%) rename lib/shaders/postshaders/{black_and_white.glsl => black_and_white.lua} (94%) rename lib/shaders/postshaders/{blurh.glsl => blurh.lua} (97%) rename lib/shaders/postshaders/{blurv.glsl => blurv.lua} (97%) rename lib/shaders/postshaders/{chromatic_aberration.glsl => chromatic_aberration.lua} (97%) rename lib/shaders/postshaders/{contrast.glsl => contrast.lua} (92%) rename lib/shaders/postshaders/{curvature.glsl => curvature.lua} (97%) rename lib/shaders/postshaders/{edges.glsl => edges.lua} (98%) rename lib/shaders/postshaders/{four_colors.glsl => four_colors.lua} (94%) rename lib/shaders/postshaders/{hdr_tv.glsl => hdr_tv.lua} (89%) rename lib/shaders/postshaders/{monochrome.glsl => monochrome.lua} (84%) rename lib/shaders/postshaders/{phosphor.glsl => phosphor.lua} (99%) rename lib/shaders/postshaders/{phosphorish.glsl => phosphorish.lua} (98%) rename lib/shaders/postshaders/{pip.glsl => pip.lua} (94%) rename lib/shaders/postshaders/{pixellate.glsl => pixellate.lua} (95%) rename lib/shaders/postshaders/{radialblur.glsl => radialblur.lua} (96%) rename lib/shaders/postshaders/{scanlines.glsl => scanlines.lua} (98%) rename lib/shaders/postshaders/{tilt_shift.glsl => tilt_shift.lua} (96%) rename lib/shaders/postshaders/{waterpaint.glsl => waterpaint.lua} (96%) rename lib/shaders/{reflection.glsl => reflection.lua} (98%) rename lib/shaders/{refraction.glsl => refraction.lua} (98%) rename lib/shaders/{shadow.glsl => shadow.lua} (99%) diff --git a/lib/body.lua b/lib/body.lua index 52a12c8..b0592ba 100644 --- a/lib/body.lua +++ b/lib/body.lua @@ -7,8 +7,8 @@ local vector = require(_PACKAGE..'/vector') local body = {} body.__index = body -body.glowShader = love.graphics.newShader(_PACKAGE.."/shaders/glow.glsl") -body.materialShader = love.graphics.newShader(_PACKAGE.."/shaders/material.glsl") +body.glowShader = love.graphics.newShader(require(_PACKAGE..".shaders.glow")) +body.materialShader = love.graphics.newShader(require(_PACKAGE..".shaders.material")) local function new(id, type, ...) local args = {...} diff --git a/lib/init.lua b/lib/init.lua index 130f1a1..8c60213 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -31,10 +31,10 @@ local PostShader = require(_PACKAGE..'postshader') local light_world = {} light_world.__index = light_world -light_world.image_mask = love.graphics.newShader(_PACKAGE.."/shaders/image_mask.glsl") -light_world.shadowShader = love.graphics.newShader(_PACKAGE.."/shaders/shadow.glsl") -light_world.refractionShader = love.graphics.newShader(_PACKAGE.."shaders/refraction.glsl") -light_world.reflectionShader = love.graphics.newShader(_PACKAGE.."shaders/reflection.glsl") +light_world.image_mask = love.graphics.newShader(require(_PACKAGE.."shaders.image_mask")) +light_world.shadowShader = love.graphics.newShader(require(_PACKAGE.."shaders.shadow")) +light_world.refractionShader = love.graphics.newShader(require(_PACKAGE.."shaders.refraction")) +light_world.reflectionShader = love.graphics.newShader(require(_PACKAGE.."shaders.reflection")) local function new(options) local obj = {} diff --git a/lib/postshader.lua b/lib/postshader.lua index efcc6d5..46368bf 100644 --- a/lib/postshader.lua +++ b/lib/postshader.lua @@ -31,15 +31,16 @@ local files = love.filesystem.getDirectoryItems(_PACKAGE.."/shaders/postshaders" local shaders = {} for i,v in ipairs(files) do - local name = _PACKAGE.."/shaders/postshaders".."/"..v + local name = _PACKAGE.."/shaders/postshaders/"..v + local module = _PACKAGE..".shaders.postshaders."..v:gsub("%.lua","") if love.filesystem.isFile(name) then local str = love.filesystem.read(name) - local effect = love.graphics.newShader(name) + local effect = love.graphics.newShader(require(module)) local defs = {} for vtype, extern in str:gmatch("extern (%w+) (%w+)") do defs[extern] = true end - local shaderName = name:match(".-([^\\|/]-[^%.]+)$"):gsub("%.glsl", "") + local shaderName = name:match(".-([^\\|/]-[^%.]+)$"):gsub("%.lua", "") shaders[shaderName] = {effect, defs} end end diff --git a/lib/shaders/glow.glsl b/lib/shaders/glow.lua similarity index 97% rename from lib/shaders/glow.glsl rename to lib/shaders/glow.lua index 2e302ce..1b17fa4 100644 --- a/lib/shaders/glow.glsl +++ b/lib/shaders/glow.lua @@ -1,3 +1,4 @@ +return [[// extern Image glowImage; extern float glowTime; @@ -17,3 +18,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { return vec4(Texel(texture, texture_coords).rgb * glowInfo.r, 1.0); } +]] diff --git a/lib/shaders/image_mask.glsl b/lib/shaders/image_mask.lua similarity index 93% rename from lib/shaders/image_mask.glsl rename to lib/shaders/image_mask.lua index 196f00d..3567aed 100644 --- a/lib/shaders/image_mask.glsl +++ b/lib/shaders/image_mask.lua @@ -1,6 +1,8 @@ +return [[// //https://love2d.org/wiki/love.graphics.setStencil image mask vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) { if (Texel(texture, texture_coords).rgb == vec3(0.0)) discard; return vec4(1.0); } +]] diff --git a/lib/shaders/material.glsl b/lib/shaders/material.lua similarity index 93% rename from lib/shaders/material.glsl rename to lib/shaders/material.lua index ea8f8c1..ed2814c 100644 --- a/lib/shaders/material.glsl +++ b/lib/shaders/material.lua @@ -1,3 +1,4 @@ +return [[// extern Image material; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { @@ -7,4 +8,5 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { } else { return vec4(0.0); } -} \ No newline at end of file +} +]] diff --git a/lib/shaders/postshaders/black_and_white.glsl b/lib/shaders/postshaders/black_and_white.lua similarity index 94% rename from lib/shaders/postshaders/black_and_white.glsl rename to lib/shaders/postshaders/black_and_white.lua index cf90ee8..3090d8b 100644 --- a/lib/shaders/postshaders/black_and_white.glsl +++ b/lib/shaders/postshaders/black_and_white.lua @@ -1,13 +1,15 @@ +return [[// extern float exposure = 0.7; extern float brightness = 1.0; extern vec3 lumacomponents = vec3(1.0, 1.0, 1.0); const vec3 lumcoeff = vec3(0.212671, 0.715160, 0.072169); -vec4 effect(vec4 vcolor, Image texture, vec2 texcoord, vec2 pixel_coords) { +vec4 effect(vec4 vcolor, Image texture, vec2 texcoord, vec2 pixel_coords) { vec4 input0 = Texel(texture, texcoord); input0 *= (exp2(input0)*vec4(exposure)); vec4 lumacomponents = vec4(lumcoeff * lumacomponents, 0.0 ); float luminance = dot(input0,lumacomponents); vec4 luma = vec4(luminance); return vec4(luma.rgb * brightness, 1.0); -} +} +]] diff --git a/lib/shaders/postshaders/blurh.glsl b/lib/shaders/postshaders/blurh.lua similarity index 97% rename from lib/shaders/postshaders/blurh.glsl rename to lib/shaders/postshaders/blurh.lua index ae58eff..2961190 100644 --- a/lib/shaders/postshaders/blurh.glsl +++ b/lib/shaders/postshaders/blurh.lua @@ -1,3 +1,4 @@ +return [[// extern float steps = 2.0; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { @@ -10,3 +11,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { col = col / (steps * 2.0 + 1.0); return vec4(col.r, col.g, col.b, 1.0); } +]] diff --git a/lib/shaders/postshaders/blurv.glsl b/lib/shaders/postshaders/blurv.lua similarity index 97% rename from lib/shaders/postshaders/blurv.glsl rename to lib/shaders/postshaders/blurv.lua index 00b929e..7033c94 100644 --- a/lib/shaders/postshaders/blurv.glsl +++ b/lib/shaders/postshaders/blurv.lua @@ -1,3 +1,4 @@ +return [[// extern float steps = 2.0; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { @@ -10,3 +11,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { col = col / (steps * 2.0 + 1.0); return vec4(col.r, col.g, col.b, 1.0); } +]] diff --git a/lib/shaders/postshaders/chromatic_aberration.glsl b/lib/shaders/postshaders/chromatic_aberration.lua similarity index 97% rename from lib/shaders/postshaders/chromatic_aberration.glsl rename to lib/shaders/postshaders/chromatic_aberration.lua index a86ade2..2f05102 100644 --- a/lib/shaders/postshaders/chromatic_aberration.glsl +++ b/lib/shaders/postshaders/chromatic_aberration.lua @@ -1,3 +1,4 @@ +return [[// extern vec2 redStrength = vec2(4.0, 3.0); extern vec2 greenStrength = vec2(-2.0, -1.0); extern vec2 blueStrength = vec2(1.0, -3.0); @@ -10,3 +11,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { return vec4(colRed, colGreen, colBlue, 1.0); } +]] diff --git a/lib/shaders/postshaders/contrast.glsl b/lib/shaders/postshaders/contrast.lua similarity index 92% rename from lib/shaders/postshaders/contrast.glsl rename to lib/shaders/postshaders/contrast.lua index dea0d10..b9ae362 100644 --- a/lib/shaders/postshaders/contrast.glsl +++ b/lib/shaders/postshaders/contrast.lua @@ -1,5 +1,7 @@ +return [[// vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { vec3 col = Texel(texture, texture_coords).rgb * 2.0; col *= col; return vec4(col, 1.0); } +]] diff --git a/lib/shaders/postshaders/curvature.glsl b/lib/shaders/postshaders/curvature.lua similarity index 97% rename from lib/shaders/postshaders/curvature.glsl rename to lib/shaders/postshaders/curvature.lua index 79f0e30..fcfebd3 100644 --- a/lib/shaders/postshaders/curvature.glsl +++ b/lib/shaders/postshaders/curvature.lua @@ -1,3 +1,4 @@ +return [[// #define distortion 0.2 vec2 radialDistortion(vec2 coord) { vec2 cc = coord - 0.5; @@ -16,3 +17,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { texcolor.a = 1.0; return texcolor; } +]] diff --git a/lib/shaders/postshaders/edges.glsl b/lib/shaders/postshaders/edges.lua similarity index 98% rename from lib/shaders/postshaders/edges.glsl rename to lib/shaders/postshaders/edges.lua index c8add09..051e3a2 100644 --- a/lib/shaders/postshaders/edges.glsl +++ b/lib/shaders/postshaders/edges.lua @@ -1,8 +1,9 @@ +return [[// /* Edge shader Author: Themaister License: Public domain. - + modified by slime73 for use with love2d and mari0 */ @@ -10,7 +11,7 @@ vec3 grayscale(vec3 color) { return vec3(dot(color, vec3(0.3, 0.59, 0.11))); } - + vec4 effect(vec4 vcolor, Image texture, vec2 tex, vec2 pixel_coords) { vec4 texcolor = Texel(texture, tex); @@ -35,5 +36,4 @@ vec4 effect(vec4 vcolor, Image texture, vec2 tex, vec2 pixel_coords) vec4 final = vec4(5.0 * grayscale(abs(res - c11)), 1.0); return clamp(final, 0.0, 1.0); } - - +]] diff --git a/lib/shaders/postshaders/four_colors.glsl b/lib/shaders/postshaders/four_colors.lua similarity index 94% rename from lib/shaders/postshaders/four_colors.glsl rename to lib/shaders/postshaders/four_colors.lua index c68b1cf..d6e58e8 100644 --- a/lib/shaders/postshaders/four_colors.glsl +++ b/lib/shaders/postshaders/four_colors.lua @@ -1,3 +1,4 @@ +return [[// extern vec3 palette[4]; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ @@ -5,4 +6,5 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ int index = int(min(0.9999, max(0.0001,(pixel.r + pixel.g + pixel.b) / 3.0)) * 4); return vec4(palette[index], 1.0); -} \ No newline at end of file +} +]] diff --git a/lib/shaders/postshaders/hdr_tv.glsl b/lib/shaders/postshaders/hdr_tv.lua similarity index 89% rename from lib/shaders/postshaders/hdr_tv.glsl rename to lib/shaders/postshaders/hdr_tv.lua index ba5e30b..fdb64a1 100644 --- a/lib/shaders/postshaders/hdr_tv.glsl +++ b/lib/shaders/postshaders/hdr_tv.lua @@ -1,8 +1,10 @@ +return [[// vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { vec4 rgb = Texel(texture, texture_coords); vec4 intens = smoothstep(0.2,0.8,rgb) + normalize(vec4(rgb.xyz, 1.0)); if (fract(pixel_coords.y * 0.5) > 0.5) intens = rgb * 0.8; intens.a = 1.0; - return intens; + return intens; } +]] diff --git a/lib/shaders/postshaders/monochrome.glsl b/lib/shaders/postshaders/monochrome.lua similarity index 84% rename from lib/shaders/postshaders/monochrome.glsl rename to lib/shaders/postshaders/monochrome.lua index d4bc55b..e08dd0d 100644 --- a/lib/shaders/postshaders/monochrome.glsl +++ b/lib/shaders/postshaders/monochrome.lua @@ -1,13 +1,15 @@ +return [[// extern float time = 0.0; extern vec3 tint = vec3(1.0, 1.0, 1.0); extern float fudge = 0.1; float rand(vec2 position, float seed) { - return fract(sin(dot(position.xy,vec2(12.9898, 78.233))) * seed); + return fract(sin(dot(position.xy,vec2(12.9898, 78.233))) * seed); } vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ vec4 pixel = Texel(texture, texture_coords); float intensity = (pixel.r + pixel.g + pixel.b) / 3.0 + (rand(texture_coords, time) - 0.5) * fudge; return vec4(intensity * tint.r, intensity * tint.g, intensity * tint.b, 1.0); -} \ No newline at end of file +} +]] diff --git a/lib/shaders/postshaders/phosphor.glsl b/lib/shaders/postshaders/phosphor.lua similarity index 99% rename from lib/shaders/postshaders/phosphor.glsl rename to lib/shaders/postshaders/phosphor.lua index cf58451..f600e86 100644 --- a/lib/shaders/postshaders/phosphor.glsl +++ b/lib/shaders/postshaders/phosphor.lua @@ -1,3 +1,4 @@ +return [[// /* caligari's scanlines @@ -13,7 +14,7 @@ http://board.byuu.org/viewtopic.php?p=36219#p36219 - "As I said to Hyllian by PM, I'm fine with the GPL (not really a bi + "As I said to Hyllian by PM, I'm fine with the GPL (not really a big deal...)" ) */ @@ -155,3 +156,4 @@ vec4 effect(vec4 vcolor, Image texture, vec2 texCoord, vec2 pixel_coords) return clamp(GAMMA_OUT(color), 0.0, 1.0); } +]] diff --git a/lib/shaders/postshaders/phosphorish.glsl b/lib/shaders/postshaders/phosphorish.lua similarity index 98% rename from lib/shaders/postshaders/phosphorish.glsl rename to lib/shaders/postshaders/phosphorish.lua index 5449cbd..bde9e15 100644 --- a/lib/shaders/postshaders/phosphorish.glsl +++ b/lib/shaders/postshaders/phosphorish.lua @@ -1,3 +1,4 @@ +return [[// /* Plain (and obviously inaccurate) phosphor. Author: Themaister @@ -42,4 +43,4 @@ vec4 effect(vec4 vcolor, Image texture, vec2 texture_coords, vec2 pixel_coords) return vec4(intensity * result, 1.0); } - +]] diff --git a/lib/shaders/postshaders/pip.glsl b/lib/shaders/postshaders/pip.lua similarity index 94% rename from lib/shaders/postshaders/pip.glsl rename to lib/shaders/postshaders/pip.lua index 56e9b7e..bfbc118 100644 --- a/lib/shaders/postshaders/pip.glsl +++ b/lib/shaders/postshaders/pip.lua @@ -1,3 +1,4 @@ +return [[// #define glarebasesize 0.896 #define power 0.50 extern float time; @@ -12,7 +13,7 @@ float luminance(vec3 color) float scanline(float ypos) { - float c = mod(time * 3.0 + ypos * 5.0, 15.0); + float c = mod(time * 3.0 + ypos * 5.0, 15.0); return 1.0 - smoothstep(0.0, 1.0, c); } @@ -35,7 +36,7 @@ vec4 effect(vec4 vcolor, Image texture, vec2 texcoord, vec2 pixel_coords) for (j = -1; j < 1; j++) { sum += Texel(texture, texcoord + vec2(-i, j)*glaresize) * power; - bum += Texel(texture, texcoord + vec2(j, i)*glaresize) * power; + bum += Texel(texture, texcoord + vec2(j, i)*glaresize) * power; } } @@ -59,4 +60,4 @@ vec4 effect(vec4 vcolor, Image texture, vec2 texcoord, vec2 pixel_coords) return finalcolor; } - +]] diff --git a/lib/shaders/postshaders/pixellate.glsl b/lib/shaders/postshaders/pixellate.lua similarity index 95% rename from lib/shaders/postshaders/pixellate.glsl rename to lib/shaders/postshaders/pixellate.lua index 6a7935e..d5dc8ed 100644 --- a/lib/shaders/postshaders/pixellate.glsl +++ b/lib/shaders/postshaders/pixellate.lua @@ -1,3 +1,4 @@ +return [[// const float pixel_w = 2.0; const float pixel_h = 2.0; @@ -8,3 +9,4 @@ vec4 effect(vec4 vcolor, Image texture, vec2 uv, vec2 pixel_coords) vec2 coord = vec2(dx*floor(uv.x/dx), dy*floor(uv.y/dy)); return Texel(texture, coord); } +]] diff --git a/lib/shaders/postshaders/radialblur.glsl b/lib/shaders/postshaders/radialblur.lua similarity index 96% rename from lib/shaders/postshaders/radialblur.glsl rename to lib/shaders/postshaders/radialblur.lua index 5c2a032..1299932 100644 --- a/lib/shaders/postshaders/radialblur.glsl +++ b/lib/shaders/postshaders/radialblur.lua @@ -1,3 +1,4 @@ +return [[// #define nsamples 5 extern number blurstart = 1.0; // 0 to 1 extern number blurwidth = -0.02; // -1 to 1 @@ -18,3 +19,4 @@ vec4 effect(vec4 vcolor, Image texture, vec2 texture_coords, vec2 pixel_coords) return c; } +]] diff --git a/lib/shaders/postshaders/scanlines.glsl b/lib/shaders/postshaders/scanlines.lua similarity index 98% rename from lib/shaders/postshaders/scanlines.glsl rename to lib/shaders/postshaders/scanlines.lua index 1e460d4..d980cba 100644 --- a/lib/shaders/postshaders/scanlines.glsl +++ b/lib/shaders/postshaders/scanlines.lua @@ -1,3 +1,4 @@ +return [[// extern float strength = 2.0; extern float time = 0.0; @@ -30,3 +31,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ return vec4(vec3(red * 0.75, green * 0.75, blue * 0.75) * brightness, 1.0); } } +]] diff --git a/lib/shaders/postshaders/tilt_shift.glsl b/lib/shaders/postshaders/tilt_shift.lua similarity index 96% rename from lib/shaders/postshaders/tilt_shift.glsl rename to lib/shaders/postshaders/tilt_shift.lua index 911878c..788c1dd 100644 --- a/lib/shaders/postshaders/tilt_shift.glsl +++ b/lib/shaders/postshaders/tilt_shift.lua @@ -1,3 +1,4 @@ +return [[// extern Image imgBuffer; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ @@ -10,3 +11,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ return vec4(pixel.rgb * (0.5 - texture_coords.y) * 2.0 + pixelBuffer.rgb * texture_coords.y * 2.0, 1.0); } } +]] diff --git a/lib/shaders/postshaders/waterpaint.glsl b/lib/shaders/postshaders/waterpaint.lua similarity index 96% rename from lib/shaders/postshaders/waterpaint.glsl rename to lib/shaders/postshaders/waterpaint.lua index 8c44c92..acb7fe4 100644 --- a/lib/shaders/postshaders/waterpaint.glsl +++ b/lib/shaders/postshaders/waterpaint.lua @@ -1,22 +1,23 @@ +return [[// /* Themaister's Waterpaint shader - Placed in the public domain. + Placed in the public domain. (From this thread: http://board.byuu.org/viewtopic.php?p=30483#p30483 PD declaration here: http://board.byuu.org/viewtopic.php?p=30542#p30542 ) - + modified by slime73 for use with love2d and mari0 */ - + vec4 compress(vec4 in_color, float threshold, float ratio) { vec4 diff = in_color - vec4(threshold); diff = clamp(diff, 0.0, 100.0); return in_color - (diff * (1.0 - 1.0/ratio)); } - + vec4 effect(vec4 vcolor, Image texture, vec2 tex, vec2 pixel_coords) { float x = 0.5 * (1.0 / love_ScreenSize.x); @@ -53,3 +54,4 @@ vec4 effect(vec4 vcolor, Image texture, vec2 tex, vec2 pixel_coords) return final; } +]] diff --git a/lib/shaders/reflection.glsl b/lib/shaders/reflection.lua similarity index 98% rename from lib/shaders/reflection.glsl rename to lib/shaders/reflection.lua index 16c14e9..2a19152 100644 --- a/lib/shaders/reflection.glsl +++ b/lib/shaders/reflection.lua @@ -1,3 +1,4 @@ +return [[// extern Image backBuffer; extern float reflectionStrength; @@ -21,3 +22,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { return vec4(0.0); } } +]] diff --git a/lib/shaders/refraction.glsl b/lib/shaders/refraction.lua similarity index 98% rename from lib/shaders/refraction.glsl rename to lib/shaders/refraction.lua index 8ded775..0a4beb9 100644 --- a/lib/shaders/refraction.glsl +++ b/lib/shaders/refraction.lua @@ -1,3 +1,4 @@ +return [[// extern Image backBuffer; extern float refractionStrength = 1.0; @@ -16,3 +17,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { return vec4(0.0); } } +]] diff --git a/lib/shaders/shadow.glsl b/lib/shaders/shadow.lua similarity index 99% rename from lib/shaders/shadow.glsl rename to lib/shaders/shadow.lua index 5bae828..29ecdde 100644 --- a/lib/shaders/shadow.glsl +++ b/lib/shaders/shadow.lua @@ -1,3 +1,4 @@ +return [[// /* Copyright (c) 2014 Tim Anema light shadow, shine and normal shader all in one @@ -47,4 +48,4 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { return pixel; } } - +]]