mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
trying out some new postshaders from mari0, fixed a couple bugs
This commit is contained in:
parent
cde3349852
commit
22c45f7bac
@ -32,7 +32,7 @@ function initScene()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
love.graphics.setBackgroundColor(0, 0, 0)
|
love.graphics.setBackgroundColor(0, 0, 0)
|
||||||
love.graphics.setDefaultFilter("nearest", "nearest")
|
love.graphics.setDefaultFilter("nearest", "nearest")
|
||||||
|
|
||||||
-- load image font
|
-- load image font
|
||||||
@ -367,19 +367,17 @@ function drawBackground(l,t,w,h)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function drawForground(l,t,w,h)
|
function drawForground(l,t,w,h)
|
||||||
for i = 1, phyCnt do
|
|
||||||
math.randomseed(i)
|
|
||||||
love.graphics.setColor(math.random(0, 255), math.random(0, 255), math.random(0, 255))
|
|
||||||
if phyLight[i]:getType() == "polygon" then
|
|
||||||
love.graphics.polygon("fill", phyLight[i]:getPoints())
|
|
||||||
elseif phyLight[i]:getType() == "circle" then
|
|
||||||
love.graphics.circle("fill", phyLight[i]:getX(), phyLight[i]:getY(), phyLight[i]:getRadius())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
love.graphics.setBlendMode("alpha")
|
love.graphics.setBlendMode("alpha")
|
||||||
for i = 1, phyCnt do
|
for i = 1, phyCnt do
|
||||||
if phyLight[i]:getType() == "image" then
|
if phyLight[i]:getType() == "polygon" then
|
||||||
|
math.randomseed(i)
|
||||||
|
love.graphics.setColor(math.random(0, 255), math.random(0, 255), math.random(0, 255))
|
||||||
|
love.graphics.polygon("fill", phyLight[i]:getPoints())
|
||||||
|
elseif phyLight[i]:getType() == "circle" then
|
||||||
|
math.randomseed(i)
|
||||||
|
love.graphics.setColor(math.random(0, 255), math.random(0, 255), math.random(0, 255))
|
||||||
|
love.graphics.circle("fill", phyLight[i]:getX(), phyLight[i]:getY(), phyLight[i]:getRadius())
|
||||||
|
elseif phyLight[i]:getType() == "image" then
|
||||||
if normalOn and phyLight[i].normal then
|
if normalOn and phyLight[i].normal then
|
||||||
love.graphics.setColor(255, 255, 255)
|
love.graphics.setColor(255, 255, 255)
|
||||||
love.graphics.draw(phyLight[i].normal, phyLight[i].x - phyLight[i].nx, phyLight[i].y - phyLight[i].ny)
|
love.graphics.draw(phyLight[i].normal, phyLight[i].x - phyLight[i].nx, phyLight[i].y - phyLight[i].ny)
|
||||||
@ -390,10 +388,6 @@ function drawForground(l,t,w,h)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not normalOn then
|
|
||||||
lightWorld:drawMaterial(l,t,w,h)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(x, y, c)
|
function love.mousepressed(x, y, c)
|
||||||
@ -415,7 +409,12 @@ function love.mousepressed(x, y, c)
|
|||||||
-- add rectangle
|
-- add rectangle
|
||||||
math.randomseed(love.timer.getTime())
|
math.randomseed(love.timer.getTime())
|
||||||
phyCnt = phyCnt + 1
|
phyCnt = phyCnt + 1
|
||||||
phyLight[phyCnt] = lightWorld:newPolygon()
|
phyLight[phyCnt] = lightWorld:newPolygon({
|
||||||
|
x, y,
|
||||||
|
x+16, y,
|
||||||
|
x+16, y+16,
|
||||||
|
x, y+16
|
||||||
|
})
|
||||||
phyBody[phyCnt] = love.physics.newBody(physicWorld, x, y, "dynamic")
|
phyBody[phyCnt] = love.physics.newBody(physicWorld, x, y, "dynamic")
|
||||||
phyShape[phyCnt] = love.physics.newRectangleShape(0, 0, math.random(32, 64), math.random(32, 64))
|
phyShape[phyCnt] = love.physics.newRectangleShape(0, 0, math.random(32, 64), math.random(32, 64))
|
||||||
phyFixture[phyCnt] = love.physics.newFixture(phyBody[phyCnt], phyShape[phyCnt])
|
phyFixture[phyCnt] = love.physics.newFixture(phyBody[phyCnt], phyShape[phyCnt])
|
||||||
|
@ -3,6 +3,7 @@ local gamera = require "vendor/gamera"
|
|||||||
local LightWorld = require "lib/light_world"
|
local LightWorld = require "lib/light_world"
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
|
testShader = 0
|
||||||
scale = 1
|
scale = 1
|
||||||
camera = gamera.new(0,0,2000,2000)
|
camera = gamera.new(0,0,2000,2000)
|
||||||
-- load images
|
-- load images
|
||||||
@ -14,10 +15,11 @@ function love.load()
|
|||||||
-- create light world
|
-- create light world
|
||||||
lightWorld = LightWorld({
|
lightWorld = LightWorld({
|
||||||
drawBackground = drawBackground,
|
drawBackground = drawBackground,
|
||||||
drawForground = drawForground
|
drawForground = drawForground,
|
||||||
|
ambient = {15,15,15},
|
||||||
|
refractionStrength = 32.0,
|
||||||
|
reflectionVisibility = 0.75,
|
||||||
})
|
})
|
||||||
lightWorld:setAmbientColor(15, 15, 31)
|
|
||||||
lightWorld:setRefractionStrength(32.0)
|
|
||||||
|
|
||||||
-- create light
|
-- create light
|
||||||
lightMouse = lightWorld:newLight(0, 0, 255, 127, 63, 300)
|
lightMouse = lightWorld:newLight(0, 0, 255, 127, 63, 300)
|
||||||
@ -37,6 +39,26 @@ function love.load()
|
|||||||
objectTest:setReflection(true)
|
objectTest:setReflection(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function love.keypressed(k)
|
||||||
|
if k == "1" then
|
||||||
|
lightWorld.post_shader:toggleEffect("4colors", {15, 56, 15}, {48, 98, 48}, {139, 172, 15}, {155, 188, 15})
|
||||||
|
elseif k == "2" then
|
||||||
|
lightWorld.post_shader:toggleEffect("monochrome")
|
||||||
|
elseif k == "3" then
|
||||||
|
lightWorld.post_shader:toggleEffect("scanlines")
|
||||||
|
elseif k == "4" then
|
||||||
|
lightWorld.post_shader:toggleEffect("tiltshift", 4.0)
|
||||||
|
elseif k == "5" then
|
||||||
|
lightWorld.post_shader:toggleEffect("bloom", 2.0, 0.25)
|
||||||
|
elseif k == "6" then
|
||||||
|
lightWorld.post_shader:toggleEffect("blur", 2.0, 2.0)
|
||||||
|
--lightWorld.post_shader:addEffect("chromatic", math.sin(lightDirection * 10.0) * colorAberration, math.cos(lightDirection * 10.0) * colorAberration, math.cos(lightDirection * 10.0) * colorAberration, math.sin(lightDirection * 10.0) * -colorAberration, math.sin(lightDirection * 10.0) * colorAberration, math.cos(lightDirection * 10.0) * -colorAberration)
|
||||||
|
elseif k == "7" then
|
||||||
|
testShader = testShader + 1
|
||||||
|
lightWorld.post_shader:addEffect("test", testShader)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
love.window.setTitle("Light vs. Shadow Engine (FPS:" .. love.timer.getFPS() .. ")")
|
love.window.setTitle("Light vs. Shadow Engine (FPS:" .. love.timer.getFPS() .. ")")
|
||||||
|
|
||||||
|
@ -363,6 +363,7 @@ function body:setShadowType(type, ...)
|
|||||||
self:refresh()
|
self:refresh()
|
||||||
elseif self.shadowType == "polygon" then
|
elseif self.shadowType == "polygon" then
|
||||||
self.data = args or {0, 0, 0, 0, 0, 0}
|
self.data = args or {0, 0, 0, 0, 0, 0}
|
||||||
|
print(self.data)
|
||||||
elseif self.shadowType == "image" then
|
elseif self.shadowType == "image" then
|
||||||
if self.img then
|
if self.img then
|
||||||
self.width = self.imgWidth
|
self.width = self.imgWidth
|
||||||
|
@ -23,11 +23,12 @@ function light:init(x, y, r, g, b, range)
|
|||||||
self.glowSize = 0.1
|
self.glowSize = 0.1
|
||||||
self.glowStrength = 0.0
|
self.glowStrength = 0.0
|
||||||
self.visible = true
|
self.visible = true
|
||||||
self:refresh(1)
|
self:refresh()
|
||||||
end
|
end
|
||||||
|
|
||||||
function light:refresh(scale)
|
function light:refresh(w, h)
|
||||||
local w, h = love.window.getWidth(), love.window.getHeight()
|
w, h = w or love.window.getWidth(), h or love.window.getHeight()
|
||||||
|
|
||||||
self.shadow = love.graphics.newCanvas(w, h)
|
self.shadow = love.graphics.newCanvas(w, h)
|
||||||
self.shine = love.graphics.newCanvas(w, h)
|
self.shine = love.graphics.newCanvas(w, h)
|
||||||
end
|
end
|
||||||
|
@ -59,7 +59,7 @@ function light_world:init(options)
|
|||||||
options = options or {}
|
options = options or {}
|
||||||
for k, v in pairs(options) do self[k] = v end
|
for k, v in pairs(options) do self[k] = v end
|
||||||
|
|
||||||
self:refreshScreenSize(1)
|
self:refreshScreenSize()
|
||||||
end
|
end
|
||||||
|
|
||||||
function light_world:drawBlur(blendmode, blur, canvas, canvas2, l, t, w, h)
|
function light_world:drawBlur(blendmode, blur, canvas, canvas2, l, t, w, h)
|
||||||
@ -209,9 +209,9 @@ function light_world:updateRelfection(l,t,w,h)
|
|||||||
love.graphics.setCanvas(self.render_buffer)
|
love.graphics.setCanvas(self.render_buffer)
|
||||||
end
|
end
|
||||||
|
|
||||||
function light_world:refreshScreenSize(scale)
|
function light_world:refreshScreenSize(w, h)
|
||||||
local w, h = love.window.getWidth(), love.window.getHeight()
|
w, h = w or love.window.getWidth(), h or love.window.getHeight()
|
||||||
self.scale = scale
|
|
||||||
self.render_buffer = love.graphics.newCanvas(w, h)
|
self.render_buffer = love.graphics.newCanvas(w, h)
|
||||||
self.shadow = love.graphics.newCanvas(w, h)
|
self.shadow = love.graphics.newCanvas(w, h)
|
||||||
self.shadow2 = love.graphics.newCanvas(w, h)
|
self.shadow2 = love.graphics.newCanvas(w, h)
|
||||||
@ -233,15 +233,18 @@ function light_world:refreshScreenSize(scale)
|
|||||||
self.reflectionShader:send("screen", {w, h})
|
self.reflectionShader:send("screen", {w, h})
|
||||||
|
|
||||||
for i = 1, #self.lights do
|
for i = 1, #self.lights do
|
||||||
self.lights[i]:refresh(scale)
|
self.lights[i]:refresh(w, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.post_shader:refreshScreenSize(w, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
function light_world:draw(l,t,w,h,s)
|
function light_world:draw(l,t,w,h,s)
|
||||||
l,t,w,h,s = (l or 0), (t or 0), (w or love.graphics.getWidth()), (h or love.graphics.getHeight()), s or 1
|
l,t,w,h,s = (l or 0), (t or 0), (w or love.graphics.getWidth()), (h or love.graphics.getHeight()), s or 1
|
||||||
|
|
||||||
if s ~= self.scale then
|
if s ~= self.scale then
|
||||||
--self:refreshScreenSize(s)
|
--self:refreshScreenSize(w, h)
|
||||||
|
self.scale = scale
|
||||||
end
|
end
|
||||||
|
|
||||||
local last_buffer = love.graphics.getCanvas()
|
local last_buffer = love.graphics.getCanvas()
|
||||||
@ -253,6 +256,7 @@ function light_world:draw(l,t,w,h,s)
|
|||||||
self.drawBackground( sl,st,sw,sh,s)
|
self.drawBackground( sl,st,sw,sh,s)
|
||||||
self:drawShadow( sl,st,sw,sh,s)
|
self:drawShadow( sl,st,sw,sh,s)
|
||||||
self.drawForground( sl,st,sw,sh,s)
|
self.drawForground( sl,st,sw,sh,s)
|
||||||
|
self:drawMaterial( sl,st,sw,sh,s)
|
||||||
self:drawShine( sl,st,sw,sh,s)
|
self:drawShine( sl,st,sw,sh,s)
|
||||||
self:drawPixelShadow( sl,st,sw,sh,s)
|
self:drawPixelShadow( sl,st,sw,sh,s)
|
||||||
self:drawGlow( sl,st,sw,sh,s)
|
self:drawGlow( sl,st,sw,sh,s)
|
||||||
@ -260,7 +264,7 @@ function light_world:draw(l,t,w,h,s)
|
|||||||
self:drawReflection( sl,st,sw,sh,s)
|
self:drawReflection( sl,st,sw,sh,s)
|
||||||
love.graphics.pop()
|
love.graphics.pop()
|
||||||
|
|
||||||
self.post_shader:drawWith(self.render_buffer, l, t)
|
self.post_shader:drawWith(self.render_buffer, l, t, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw shadow
|
-- draw shadow
|
||||||
|
@ -27,25 +27,30 @@ local class = require(_PACKAGE..'/class')
|
|||||||
local post_shader = class()
|
local post_shader = class()
|
||||||
post_shader.blurv = love.graphics.newShader(_PACKAGE.."/shaders/blurv.glsl")
|
post_shader.blurv = love.graphics.newShader(_PACKAGE.."/shaders/blurv.glsl")
|
||||||
post_shader.blurh = love.graphics.newShader(_PACKAGE.."/shaders/blurh.glsl")
|
post_shader.blurh = love.graphics.newShader(_PACKAGE.."/shaders/blurh.glsl")
|
||||||
post_shader.contrast = love.graphics.newShader(_PACKAGE.."/shaders/contrast.glsl")
|
post_shader.contrast = love.graphics.newShader(_PACKAGE.."/shaders/postshaders/contrast.glsl")
|
||||||
post_shader.chromatic_aberration = love.graphics.newShader(_PACKAGE.."/shaders/chromatic_aberration.glsl")
|
post_shader.chromatic_aberration = love.graphics.newShader(_PACKAGE.."/shaders/postshaders/chromatic_aberration.glsl")
|
||||||
post_shader.four_color = love.graphics.newShader(_PACKAGE.."/shaders/four_colors.glsl")
|
post_shader.four_color = love.graphics.newShader(_PACKAGE.."/shaders/postshaders/four_colors.glsl")
|
||||||
post_shader.monochrome = love.graphics.newShader(_PACKAGE.."/shaders/monochrome.glsl")
|
post_shader.monochrome = love.graphics.newShader(_PACKAGE.."/shaders/postshaders/monochrome.glsl")
|
||||||
post_shader.scanlines = love.graphics.newShader(_PACKAGE.."/shaders/scanlines.glsl")
|
post_shader.scanlines = love.graphics.newShader(_PACKAGE.."/shaders/postshaders/scanlines.glsl")
|
||||||
post_shader.tilt_shift = love.graphics.newShader(_PACKAGE.."/shaders/tilt_shift.glsl")
|
post_shader.tilt_shift = love.graphics.newShader(_PACKAGE.."/shaders/postshaders/tilt_shift.glsl")
|
||||||
|
|
||||||
function post_shader:init()
|
function post_shader:init()
|
||||||
self:refreshScreenSize()
|
self:refreshScreenSize()
|
||||||
self.effects = {}
|
self.effects = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function post_shader:refreshScreenSize()
|
function post_shader:refreshScreenSize(w, h)
|
||||||
self.render_buffer = love.graphics.newCanvas()
|
w, h = w or love.window.getWidth(), h or love.window.getHeight()
|
||||||
self.back_buffer = love.graphics.newCanvas()
|
|
||||||
|
|
||||||
post_shader.blurv:send("screen", {love.window.getWidth(), love.window.getHeight()})
|
self.render_buffer = love.graphics.newCanvas(w, h)
|
||||||
post_shader.blurh:send("screen", {love.window.getWidth(), love.window.getHeight()})
|
self.back_buffer = love.graphics.newCanvas(w, h)
|
||||||
post_shader.scanlines:send("screen", {love.window.getWidth(), love.window.getHeight()})
|
|
||||||
|
post_shader.blurv:send("screen", {w, h})
|
||||||
|
post_shader.blurh:send("screen", {w, h})
|
||||||
|
post_shader.scanlines:send("screen", {w, h})
|
||||||
|
|
||||||
|
self.w = w
|
||||||
|
self.h = h
|
||||||
end
|
end
|
||||||
|
|
||||||
function post_shader:addEffect(shaderName, ...)
|
function post_shader:addEffect(shaderName, ...)
|
||||||
@ -80,6 +85,8 @@ function post_shader:drawWith(canvas, l, t)
|
|||||||
self:drawScanlines(canvas, args)
|
self:drawScanlines(canvas, args)
|
||||||
elseif shader == "tiltshift" then
|
elseif shader == "tiltshift" then
|
||||||
self:drawTiltshift(canvas, args)
|
self:drawTiltshift(canvas, args)
|
||||||
|
elseif shader == "test" then
|
||||||
|
self:drawTest(canvas, args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -232,4 +239,50 @@ function post_shader:drawTiltshift(canvas, args)
|
|||||||
love.graphics.draw(self.back_buffer)
|
love.graphics.draw(self.back_buffer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local files = love.filesystem.getDirectoryItems(_PACKAGE.."/shaders/postshaders/test")
|
||||||
|
local testShaders = {}
|
||||||
|
|
||||||
|
for i,v in ipairs(files) do
|
||||||
|
local name = _PACKAGE.."/shaders/postshaders/test".."/"..v
|
||||||
|
if love.filesystem.isFile(name) then
|
||||||
|
local str = love.filesystem.read(name)
|
||||||
|
local effect = love.graphics.newShader(name)
|
||||||
|
local defs = {}
|
||||||
|
for vtype, extern in str:gmatch("extern (%w+) (%w+)") do
|
||||||
|
defs[extern] = true
|
||||||
|
end
|
||||||
|
testShaders[#testShaders+1] = {effect, defs, name}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function post_shader:drawTest(canvas, args)
|
||||||
|
local w, h = love.graphics.getWidth(), love.graphics.getHeight()
|
||||||
|
local scale = 1
|
||||||
|
local defaults = {
|
||||||
|
textureSize = {w, h},
|
||||||
|
inputSize = {w, h},
|
||||||
|
outputSize = {w, h},
|
||||||
|
time = love.timer.getTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
love.graphics.setCanvas(self.back_buffer)
|
||||||
|
love.graphics.setBlendMode("alpha")
|
||||||
|
|
||||||
|
local effect = testShaders[args[1]]
|
||||||
|
for def in pairs(effect[2]) do
|
||||||
|
if defaults[def] then
|
||||||
|
effect[1]:send(def, defaults[def])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print(effect[3])
|
||||||
|
love.graphics.setShader(effect[1])
|
||||||
|
love.graphics.draw(canvas)
|
||||||
|
|
||||||
|
love.graphics.setBlendMode("alpha")
|
||||||
|
love.graphics.setCanvas(canvas)
|
||||||
|
love.graphics.setShader()
|
||||||
|
love.graphics.setColor(255, 255, 255)
|
||||||
|
love.graphics.draw(self.back_buffer)
|
||||||
|
end
|
||||||
|
|
||||||
return post_shader
|
return post_shader
|
||||||
|
@ -25,7 +25,7 @@ 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 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;
|
float blue = Texel(texture, vec2(texture_coords.x + offsetX, texture_coords.y)).b;
|
||||||
|
|
||||||
if(mod(texture_coords.y * screen.y, 2.0) > 0.5) {
|
if(fract(gl_FragCoord.y * (0.5*4.0/3.0)) > 0.5) {
|
||||||
return vec4(vec3(red, green, blue) * brightness, 1.0);
|
return vec4(vec3(red, green, blue) * brightness, 1.0);
|
||||||
} else {
|
} else {
|
||||||
return vec4(vec3(red * 0.75, green * 0.75, blue * 0.75) * brightness, 1.0);
|
return vec4(vec3(red * 0.75, green * 0.75, blue * 0.75) * brightness, 1.0);
|
9
lib/shaders/postshaders/test/HDR-TV.frag
Normal file
9
lib/shaders/postshaders/test/HDR-TV.frag
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
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;
|
||||||
|
}
|
24
lib/shaders/postshaders/test/black_and_white.frag
Normal file
24
lib/shaders/postshaders/test/black_and_white.frag
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
extern float exposure = 0.7;
|
||||||
|
extern float brightness = 1.0;
|
||||||
|
extern vec3 lumacomponents = vec3(1.0, 1.0, 1.0);
|
||||||
|
|
||||||
|
|
||||||
|
// luma
|
||||||
|
//const vec3 lumcoeff = vec3(0.299,0.587,0.114);
|
||||||
|
const vec3 lumcoeff = vec3(0.212671, 0.715160, 0.072169);
|
||||||
|
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 texcoord, vec2 pixel_coords)
|
||||||
|
{
|
||||||
|
vec4 input0 = Texel(texture, texcoord);
|
||||||
|
|
||||||
|
//exposure knee
|
||||||
|
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);
|
||||||
|
}
|
88
lib/shaders/postshaders/test/curvature.frag
Normal file
88
lib/shaders/postshaders/test/curvature.frag
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
extern vec2 inputSize;
|
||||||
|
extern vec2 textureSize;
|
||||||
|
|
||||||
|
|
||||||
|
#define distortion 0.2
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define f 0.6
|
||||||
|
#define ox 0.5
|
||||||
|
#define oy 0.5
|
||||||
|
#define scale 0.8
|
||||||
|
#define k1 0.7
|
||||||
|
#define k2 -0.5
|
||||||
|
|
||||||
|
vec2 barrelDistort(vec2 coord)
|
||||||
|
{
|
||||||
|
vec2 xy = (coord - vec2(ox, oy))/vec2(f) * scale;
|
||||||
|
|
||||||
|
vec2 r = vec2(sqrt(dot(xy, xy)));
|
||||||
|
|
||||||
|
float r2 = float(r*r);
|
||||||
|
|
||||||
|
float r4 = r2*r2;
|
||||||
|
|
||||||
|
float coeff = (k1*r2 + k2*r4);
|
||||||
|
|
||||||
|
return ((xy+xy*coeff) * f) + vec2(ox, oy);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
vec2 radialDistortion(vec2 coord, const vec2 ratio)
|
||||||
|
{
|
||||||
|
float offsety = 1.0 - ratio.y;
|
||||||
|
coord.y -= offsety;
|
||||||
|
coord /= ratio;
|
||||||
|
|
||||||
|
vec2 cc = coord - 0.5;
|
||||||
|
float dist = dot(cc, cc) * distortion;
|
||||||
|
vec2 result = coord + cc * (1.0 + dist) * dist;
|
||||||
|
|
||||||
|
result *= ratio;
|
||||||
|
result.y += offsety;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
vec4 checkTexelBounds(Image texture, vec2 coords, vec2 bounds)
|
||||||
|
{
|
||||||
|
vec4 color = Texel(texture, coords) *
|
||||||
|
|
||||||
|
vec2 ss = step(coords, vec2(bounds.x, 1.0)) * step(vec2(0.0, bounds.y), coords);
|
||||||
|
|
||||||
|
color.rgb *= ss.x * ss.y;
|
||||||
|
color.a = step(color.a, ss.x * ss.y);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
vec4 checkTexelBounds(Image texture, vec2 coords, vec2 bounds)
|
||||||
|
{
|
||||||
|
vec2 ss = step(coords, vec2(bounds.x, 1.0)) * step(vec2(0.0, bounds.y), coords);
|
||||||
|
return Texel(texture, coords) * ss.x * ss.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
vec4 checkTexelBounds(Image texture, vec2 coords)
|
||||||
|
{
|
||||||
|
vec2 bounds = vec2(inputSize.x / textureSize.x, 1.0 - inputSize.y / textureSize.y);
|
||||||
|
|
||||||
|
vec4 color;
|
||||||
|
if (coords.x > bounds.x || coords.x < 0.0 || coords.y > 1.0 || coords.y < bounds.y)
|
||||||
|
color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
else
|
||||||
|
color = Texel(texture, coords);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
|
||||||
|
{
|
||||||
|
vec2 coords = radialDistortion(texture_coords, inputSize / textureSize);
|
||||||
|
|
||||||
|
vec4 texcolor = checkTexelBounds(texture, coords, vec2(inputSize.x / textureSize.x, 1.0 - inputSize.y / textureSize.y));
|
||||||
|
texcolor.a = 1.0;
|
||||||
|
|
||||||
|
return texcolor;
|
||||||
|
}
|
||||||
|
|
42
lib/shaders/postshaders/test/edges.frag
Normal file
42
lib/shaders/postshaders/test/edges.frag
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
Edge shader
|
||||||
|
Author: Themaister
|
||||||
|
License: Public domain.
|
||||||
|
|
||||||
|
modified by slime73 for use with love2d and mari0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern vec2 textureSize;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
float x = 0.5 / textureSize.x;
|
||||||
|
float y = 0.5 / textureSize.y;
|
||||||
|
vec2 dg1 = vec2( x, y);
|
||||||
|
vec2 dg2 = vec2(-x, y);
|
||||||
|
|
||||||
|
vec3 c00 = Texel(texture, tex - dg1).xyz;
|
||||||
|
vec3 c02 = Texel(texture, tex + dg2).xyz;
|
||||||
|
vec3 c11 = texcolor.xyz;
|
||||||
|
vec3 c20 = Texel(texture, tex - dg2).xyz;
|
||||||
|
vec3 c22 = Texel(texture, tex + dg1).xyz;
|
||||||
|
|
||||||
|
vec2 texsize = textureSize;
|
||||||
|
|
||||||
|
vec3 first = mix(c00, c20, fract(tex.x * texsize.x + 0.5));
|
||||||
|
vec3 second = mix(c02, c22, fract(tex.x * texsize.x + 0.5));
|
||||||
|
|
||||||
|
vec3 res = mix(first, second, fract(tex.y * texsize.y + 0.5));
|
||||||
|
vec4 final = vec4(5.0 * grayscale(abs(res - c11)), 1.0);
|
||||||
|
return clamp(final, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
159
lib/shaders/postshaders/test/phosphor.frag
Normal file
159
lib/shaders/postshaders/test/phosphor.frag
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
caligari's scanlines
|
||||||
|
|
||||||
|
Copyright (C) 2011 caligari
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 2 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
(caligari gave their consent to have this shader distributed under the GPL
|
||||||
|
in this message:
|
||||||
|
|
||||||
|
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
|
||||||
|
deal...)"
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern vec2 textureSize;
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// Used to counteract the desaturation effect of weighting.
|
||||||
|
#define COLOR_BOOST 1.9
|
||||||
|
|
||||||
|
// Constants used with gamma correction.
|
||||||
|
#define InputGamma 2.4
|
||||||
|
#define OutputGamma 2.2
|
||||||
|
|
||||||
|
// Uncomment to only draw every third pixel, which highlights the shape
|
||||||
|
// of individual (remaining) spots.
|
||||||
|
// #define DEBUG
|
||||||
|
|
||||||
|
// Uncomment one of these to choose a gamma correction method.
|
||||||
|
// If none are uncommented, no gamma correction is done.
|
||||||
|
// #define REAL_GAMMA
|
||||||
|
#define FAKE_GAMMA
|
||||||
|
// #define FAKER_GAMMA
|
||||||
|
|
||||||
|
#ifdef REAL_GAMMA
|
||||||
|
#define GAMMA_IN(color) pow(color, vec4(InputGamma))
|
||||||
|
#define GAMMA_OUT(color) pow(color, vec4(1.0 / OutputGamma))
|
||||||
|
|
||||||
|
#elif defined FAKE_GAMMA
|
||||||
|
/*
|
||||||
|
* Approximations:
|
||||||
|
* for 1<g<2 : x^g ~ ax + bx^2
|
||||||
|
* where a=6/(g+1)-2 and b=1-a
|
||||||
|
* for 2<g<3 : x^g ~ ax^2 + bx^3
|
||||||
|
* where a=12/(g+1)-3 and b=1-a
|
||||||
|
* for 1<g<2 : x^(1/g) ~ (sqrt(a^2+4bx)-a)
|
||||||
|
* where a=6/(g+1)-2 and b=1-a
|
||||||
|
* for 2<g<3 : x^(1/g) ~ (a sqrt(x) + b sqrt(sqrt(x)))
|
||||||
|
* where a = 6 - 15g / 2(g+1) and b = 1-a
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
#define GAMMA_IN(color) ( (A_IN + B_IN * color) * color * color )
|
||||||
|
#define GAMMA_OUT(color) ( A_OUT * sqrt(color) + B_OUT * sqrt( sqrt(color) ) )
|
||||||
|
|
||||||
|
#elif defined FAKER_GAMMA
|
||||||
|
vec4 A_IN = vec4(6.0/( InputGamma/OutputGamma + 1.0 ) - 2.0);
|
||||||
|
vec4 B_IN = vec4(1.0) - A_IN;
|
||||||
|
#define GAMMA_IN(color) ( (A_IN + B_IN * color) * color )
|
||||||
|
#define GAMMA_OUT(color) color
|
||||||
|
|
||||||
|
#else // No gamma correction
|
||||||
|
#define GAMMA_IN(color) color
|
||||||
|
#define GAMMA_OUT(color) color
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
vec4 grid_color( vec2 coords )
|
||||||
|
{
|
||||||
|
vec2 snes = floor( coords * textureSize );
|
||||||
|
if ( (mod(snes.x, 3.0) == 0.0) && (mod(snes.y, 3.0) == 0.0) )
|
||||||
|
return texture2D(_tex0_, coords);
|
||||||
|
else
|
||||||
|
return vec4(0.0);
|
||||||
|
}
|
||||||
|
#define TEX2D(coords) GAMMA_IN( grid_color( coords ) )
|
||||||
|
|
||||||
|
#else // DEBUG
|
||||||
|
#define TEX2D(coords) GAMMA_IN( texture2D(_tex0_, coords) )
|
||||||
|
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
|
vec2 onex = vec2( 1.0/textureSize.x, 0.0 );
|
||||||
|
vec2 oney = vec2( 0.0, 1.0/textureSize.y );
|
||||||
|
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 texCoord, vec2 pixel_coords)
|
||||||
|
{
|
||||||
|
vec2 coords = (texCoord * textureSize);
|
||||||
|
vec2 pixel_start = floor(coords);
|
||||||
|
coords -= pixel_start;
|
||||||
|
vec2 pixel_center = pixel_start + vec2(0.5);
|
||||||
|
vec2 texture_coords = pixel_center / textureSize;
|
||||||
|
|
||||||
|
vec4 color = vec4(0.0);
|
||||||
|
vec4 pixel;
|
||||||
|
vec3 centers = vec3(-0.25,-0.5,-0.75);
|
||||||
|
vec3 posx = vec3(coords.x);
|
||||||
|
vec3 hweight;
|
||||||
|
float vweight;
|
||||||
|
float dx,dy;
|
||||||
|
float w;
|
||||||
|
|
||||||
|
float i,j;
|
||||||
|
|
||||||
|
for (j = -1.0; j<=1.0; j++) {
|
||||||
|
// Vertical weight
|
||||||
|
dy = abs(coords.y - 0.5 - j );
|
||||||
|
vweight = smoothstep(1.0,0.0, dy / PHOSPHOR_HEIGHT);
|
||||||
|
|
||||||
|
if (vweight !=0.0 ) {
|
||||||
|
for ( i = -1.0; i<=1.0; i++ ) {
|
||||||
|
pixel = TEX2D(
|
||||||
|
texture_coords
|
||||||
|
+ i * onex
|
||||||
|
+ j * oney
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Evaluate the distance (in x) from
|
||||||
|
* the pixel (posx) to the RGB centers
|
||||||
|
* (~centers):
|
||||||
|
* x_red = 0.25
|
||||||
|
* x_green = 0.5
|
||||||
|
* x_blue = 0.75
|
||||||
|
* if the distance > PHOSPHOR_WIDTH,
|
||||||
|
* this pixel doesn't contribute
|
||||||
|
* otherwise, smoothstep gives the
|
||||||
|
* weight of the contribution
|
||||||
|
*/
|
||||||
|
hweight = smoothstep(
|
||||||
|
1.0, 0.0,
|
||||||
|
abs((posx + centers - vec3(i))
|
||||||
|
/ vec3(PHOSPHOR_WIDTH))
|
||||||
|
);
|
||||||
|
color.rgb +=
|
||||||
|
pixel.rgb *
|
||||||
|
hweight *
|
||||||
|
vec3(vweight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
color *= vec4(COLOR_BOOST);
|
||||||
|
color.a = 1.0;
|
||||||
|
|
||||||
|
return clamp(GAMMA_OUT(color), 0.0, 1.0);
|
||||||
|
}
|
48
lib/shaders/postshaders/test/phosphorish.frag
Normal file
48
lib/shaders/postshaders/test/phosphorish.frag
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Plain (and obviously inaccurate) phosphor.
|
||||||
|
Author: Themaister
|
||||||
|
License: Public Domain
|
||||||
|
*/
|
||||||
|
// modified by slime73 for use with love pixeleffects
|
||||||
|
|
||||||
|
|
||||||
|
extern vec2 textureSize;
|
||||||
|
|
||||||
|
vec3 to_focus(float pixel)
|
||||||
|
{
|
||||||
|
pixel = mod(pixel + 3.0, 3.0);
|
||||||
|
if (pixel >= 2.0) // Blue
|
||||||
|
return vec3(pixel - 2.0, 0.0, 3.0 - pixel);
|
||||||
|
else if (pixel >= 1.0) // Green
|
||||||
|
return vec3(0.0, 2.0 - pixel, pixel - 1.0);
|
||||||
|
else // Red
|
||||||
|
return vec3(1.0 - pixel, pixel, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 texture_coords, vec2 pixel_coords)
|
||||||
|
{
|
||||||
|
float y = mod(texture_coords.y * textureSize.y, 1.0);
|
||||||
|
float intensity = exp(-0.2 * y);
|
||||||
|
|
||||||
|
vec2 one_x = vec2(1.0 / (3.0 * textureSize.x), 0.0);
|
||||||
|
|
||||||
|
vec3 color = Texel(texture, texture_coords - 0.0 * one_x).rgb;
|
||||||
|
vec3 color_prev = Texel(texture, texture_coords - 1.0 * one_x).rgb;
|
||||||
|
vec3 color_prev_prev = Texel(texture, texture_coords - 2.0 * one_x).rgb;
|
||||||
|
|
||||||
|
float pixel_x = 3.0 * texture_coords.x * textureSize.x;
|
||||||
|
|
||||||
|
vec3 focus = to_focus(pixel_x - 0.0);
|
||||||
|
vec3 focus_prev = to_focus(pixel_x - 1.0);
|
||||||
|
vec3 focus_prev_prev = to_focus(pixel_x - 2.0);
|
||||||
|
|
||||||
|
vec3 result =
|
||||||
|
0.8 * color * focus +
|
||||||
|
0.6 * color_prev * focus_prev +
|
||||||
|
0.3 * color_prev_prev * focus_prev_prev;
|
||||||
|
|
||||||
|
result = 2.3 * pow(result, vec3(1.4));
|
||||||
|
|
||||||
|
return vec4(intensity * result, 1.0);
|
||||||
|
}
|
||||||
|
|
66
lib/shaders/postshaders/test/pip.frag
Normal file
66
lib/shaders/postshaders/test/pip.frag
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#define glarebasesize 0.896
|
||||||
|
#define power 0.50
|
||||||
|
|
||||||
|
extern vec2 textureSize;
|
||||||
|
extern vec2 outputSize;
|
||||||
|
|
||||||
|
extern float time;
|
||||||
|
|
||||||
|
const vec3 green = vec3(0.17, 0.62, 0.25);
|
||||||
|
|
||||||
|
float luminance(vec3 color)
|
||||||
|
{
|
||||||
|
return (0.212671 * color.r) + (0.715160 * color.g) + (0.072169 * color.b);
|
||||||
|
}
|
||||||
|
|
||||||
|
float scanline(float ypos)
|
||||||
|
{
|
||||||
|
|
||||||
|
float c = mod(time * 3.0 + ypos * 5.0, 15.0);
|
||||||
|
return 1.0 - smoothstep(0.0, 1.0, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 texcoord, vec2 pixel_coords)
|
||||||
|
{
|
||||||
|
vec4 texcolor = Texel(texture, texcoord);
|
||||||
|
|
||||||
|
vec4 sum = vec4(0.0);
|
||||||
|
vec4 bum = vec4(0.0);
|
||||||
|
|
||||||
|
vec2 glaresize = vec2(glarebasesize) / textureSize;
|
||||||
|
|
||||||
|
float y_one = 1.0 / outputSize.y;
|
||||||
|
|
||||||
|
int j;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = -2; i < 2; i++)
|
||||||
|
{
|
||||||
|
for (j = -1; j < 1; j++)
|
||||||
|
{
|
||||||
|
sum += Texel(texture, texcoord + vec2(-i, j)*glaresize) * power;
|
||||||
|
bum += Texel(texture, texcoord + vec2(j, i)*glaresize) * power;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float a = (scanline(texcoord.y) + scanline(texcoord.y + y_one * 1.5) + scanline(texcoord.y - y_one * 1.5)) / 3.0;
|
||||||
|
|
||||||
|
vec4 finalcolor;
|
||||||
|
|
||||||
|
if (texcolor.r < 2.0)
|
||||||
|
{
|
||||||
|
finalcolor = sum*sum*sum*0.001+bum*bum*bum*0.0080 * (0.8 + 0.05 * a) + texcolor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finalcolor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
float lum = pow(luminance(finalcolor.rgb), 1.4);
|
||||||
|
|
||||||
|
finalcolor.rgb = lum * green + (a * 0.03);
|
||||||
|
finalcolor.a = 1.0;
|
||||||
|
|
||||||
|
return finalcolor;
|
||||||
|
}
|
||||||
|
|
13
lib/shaders/postshaders/test/pixellate.frag
Normal file
13
lib/shaders/postshaders/test/pixellate.frag
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
extern vec2 textureSize;
|
||||||
|
|
||||||
|
const float pixel_w = 2.0;
|
||||||
|
const float pixel_h = 2.0;
|
||||||
|
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 uv, vec2 pixel_coords)
|
||||||
|
{
|
||||||
|
float dx = pixel_w*(1.0/textureSize.x);
|
||||||
|
float dy = pixel_h*(1.0/textureSize.y);
|
||||||
|
vec2 coord = vec2(dx*floor(uv.x/dx), dy*floor(uv.y/dy));
|
||||||
|
return Texel(texture, coord);
|
||||||
|
}
|
21
lib/shaders/postshaders/test/radialblur.frag
Normal file
21
lib/shaders/postshaders/test/radialblur.frag
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#define nsamples 5
|
||||||
|
|
||||||
|
extern number blurstart = 1.0; // 0 to 1
|
||||||
|
extern number blurwidth = -0.02; // -1 to 1
|
||||||
|
|
||||||
|
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 texture_coords, vec2 pixel_coords)
|
||||||
|
{
|
||||||
|
vec4 c = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < nsamples; i++)
|
||||||
|
{
|
||||||
|
number scale = blurstart + blurwidth * (i / float(nsamples-1));
|
||||||
|
c.rgb += Texel(texture, texture_coords * scale).rgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.rgb /= nsamples;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
57
lib/shaders/postshaders/test/waterpaint.frag
Normal file
57
lib/shaders/postshaders/test/waterpaint.frag
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
Themaister's Waterpaint shader
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
extern vec2 textureSize;
|
||||||
|
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 tex, vec2 pixel_coords)
|
||||||
|
{
|
||||||
|
float x = 0.5 * (1.0 / textureSize.x);
|
||||||
|
float y = 0.5 * (1.0 / textureSize.y);
|
||||||
|
|
||||||
|
vec2 dg1 = vec2( x, y);
|
||||||
|
vec2 dg2 = vec2(-x, y);
|
||||||
|
vec2 dx = vec2(x, 0.0);
|
||||||
|
vec2 dy = vec2(0.0, y);
|
||||||
|
|
||||||
|
vec3 c00 = Texel(texture, tex - dg1).xyz;
|
||||||
|
vec3 c01 = Texel(texture, tex - dx).xyz;
|
||||||
|
vec3 c02 = Texel(texture, tex + dg2).xyz;
|
||||||
|
vec3 c10 = Texel(texture, tex - dy).xyz;
|
||||||
|
vec3 c11 = Texel(texture, tex).xyz;
|
||||||
|
vec3 c12 = Texel(texture, tex + dy).xyz;
|
||||||
|
vec3 c20 = Texel(texture, tex - dg2).xyz;
|
||||||
|
vec3 c21 = Texel(texture, tex + dx).xyz;
|
||||||
|
vec3 c22 = Texel(texture, tex + dg1).xyz;
|
||||||
|
|
||||||
|
vec2 texsize = textureSize;
|
||||||
|
|
||||||
|
vec3 first = mix(c00, c20, fract(tex.x * texsize.x + 0.5));
|
||||||
|
vec3 second = mix(c02, c22, fract(tex.x * texsize.x + 0.5));
|
||||||
|
|
||||||
|
vec3 mid_horiz = mix(c01, c21, fract(tex.x * texsize.x + 0.5));
|
||||||
|
vec3 mid_vert = mix(c10, c12, fract(tex.y * texsize.y + 0.5));
|
||||||
|
|
||||||
|
vec3 res = mix(first, second, fract(tex.y * texsize.y + 0.5));
|
||||||
|
vec4 final = vec4(0.26 * (res + mid_horiz + mid_vert) + 3.5 * abs(res - mix(mid_horiz, mid_vert, 0.5)), 1.0);
|
||||||
|
|
||||||
|
final = compress(final, 0.8, 5.0);
|
||||||
|
final.a = 1.0;
|
||||||
|
|
||||||
|
return final;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user