https://www.shadertoy.com/view/4ssGR8
Would someone so kind and make it run in LOVE 0.10.2 please? I never understand this shader language stuff. Many thanks

Code: Select all
shaderCustom = love.graphics.newShader [[
extern float soft = 0.3;
extern float threshold = 0.3;
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
{
float f = soft/2.0;
float a = threshold - f;
float b = threshold + f;
vec4 tx = Texel( texture, texture_coords );
float l = (tx.x + tx.y + tx.z) / 3.0;
vec3 col = vec3( smoothstep(a, b, l) );
return vec4( col, 1 )*color;
}
]]
Code: Select all
threshold = 0.3
soft = 0.3
function love.draw( dt )
--both preset at 0.3 in shader, but values can be changed using these 2 lines below. extreme value changes will result in ugly results.
shaderCustom.send( shaderCustom, "soft", soft )
shaderCustom.send( shaderCustom, "threshold", threshold )
love.graphics.setShader( shaderCustom )
love.graphics.draw( mm, 50, 50, 0, 2.5, 2.5 )
love.graphics.setShader()
end
Code: Select all
--white on transparent bkg
shaderCustom = love.graphics.newShader [[
extern float soft = 0.3;
extern float threshold = 0.3;
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
{
float f = soft/2.0;
float a = threshold - f;
float b = threshold + f;
vec4 tx = Texel( texture, texture_coords );
float l = (tx.x + tx.y + tx.z) / 3.0;
return vec4( smoothstep(a, b, l) )*color;
}
]]
Code: Select all
local Shader;
local firstCanvas;
local secondCanvas;
local currentCanvas
local otherCanvas
local lastPoint = {x=0,y=0}
function love.load()
-- love._openConsole()
Shader = love.graphics.newShader[[
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
{
number pW = 1/love_ScreenSize.x;//pixel width
number pH = 1/love_ScreenSize.y;//pixel height
vec4 pixel = Texel(texture, texture_coords );//This is the current pixel
vec2 coords = vec2(texture_coords.x-pW,texture_coords.y);
vec4 Lpixel = Texel(texture, coords );//Pixel on the left
coords = vec2(texture_coords.x+pW,texture_coords.y);
vec4 Rpixel = Texel(texture, coords );//Pixel on the right
coords = vec2(texture_coords.x,texture_coords.y-pH);
vec4 Upixel = Texel(texture, coords );//Pixel on the up
coords = vec2(texture_coords.x,texture_coords.y+pH);
vec4 Dpixel = Texel(texture, coords );//Pixel on the down
pixel.a += 10 * 0.0166667 * (Lpixel.a + Rpixel.a + Dpixel.a * 3 + Upixel.a - 6 * pixel.a);
pixel.rgb = vec3(1.0,1.0,1.0);
return pixel;
}
]]
firstCanvas = love.graphics.newCanvas()
secondCanvas = love.graphics.newCanvas()
currentCanvas = firstCanvas
otherCanvas = secondCanvas
lastPoint.x = love.mouse.getX()
lastPoint.y = love.mouse.getY()
end
local fps = 0;
local mouseParticles = {};
function love.draw()
love.graphics.setColor(0,0,0,255)
love.graphics.rectangle("fill",0,0,100,50)
love.graphics.setColor(255,255,255,255)
love.graphics.print("FPS: " .. fps,10,10)
if(#mouseParticles > 0)then
love.graphics.setCanvas(firstCanvas)
love.graphics.setColor(255,255,255,255)
for i=1,#mouseParticles do
local p = mouseParticles[i];
love.graphics.circle("fill",p.x,p.y,10);
end
love.graphics.setCanvas()
mouseParticles = {}
love.graphics.setColor(255,255,255,255)
end
love.graphics.setCanvas(otherCanvas)
love.graphics.setShader(Shader);
love.graphics.draw(currentCanvas)
love.graphics.setShader();
love.graphics.setCanvas()
-- currentCanvas:clear()
refactor_canvas = love.graphics.getCanvas()
love.graphics.setCanvas(currentCanvas)
love.graphics.clear()
love.graphics.setCanvas(refactor_canvas)
love.graphics.setCanvas(currentCanvas)
love.graphics.setShader(Shader);
love.graphics.draw(otherCanvas)
love.graphics.setShader();
love.graphics.setCanvas()
love.graphics.draw(currentCanvas)
-- otherCanvas:clear() --HAD TO REFACTOR THIS, dunno if it's convoluted
refactor_canvas = love.graphics.getCanvas()
love.graphics.setCanvas(otherCanvas)
love.graphics.clear()
love.graphics.setCanvas(refactor_canvas)
end
local c2 = 0;
local sum = 0;
local lastModified = love.filesystem.getLastModified("main.lua")
function love.update(dt)
------------To make the code update in real time
if(love.filesystem.getLastModified("main.lua") ~= lastModified)then
local testFunc = function()
love.filesystem.load('main.lua')
end
local test,e = pcall(testFunc)
if(test)then
love.filesystem.load('main.lua')()
love.run()
else
print(e)
end
lastModified = love.filesystem.getLastModified("main.lua")
end
-----------Get average FPS
c2 = c2 + 1;
sum = sum + dt;
if(sum > 1)then
sum = sum / c2;
fps = math.floor(1/sum);
c2 = 0;
sum = 0;
end
-----Add smoke
if(love.mouse.isDown(1))then
local x,y = love.mouse.getPosition()
local p = {};
p.x = x; p.y = y;
mouseParticles[#mouseParticles+1] = p;
local dx = p.x - lastPoint.x;
local dy = p.y - lastPoint.y;
local dist = math.sqrt(dx * dx + dy * dy);
---if there is a gap, fill it
if(dist > 5)then
local angle = math.atan2(dy,dx);
local cosine = math.cos(angle);
local sine = math.sin(angle)
for i=1,dist,1 do
local p2 = {};
p2.x = lastPoint.x + i * cosine;
p2.y = lastPoint.y + i * sine;
mouseParticles[#mouseParticles+1] = p2;
end
end
lastPoint.x = x; lastPoint.y = y;
else
--if mouse is up
local x,y = love.mouse.getPosition()
lastPoint.x = x; lastPoint.y = y;
end
end
Code: Select all
refactor_canvas = love.graphics.getCanvas()
love.graphics.setCanvas(currentCanvas)
love.graphics.clear()
love.graphics.setCanvas(refactor_canvas)
How do I remove the split? I'm still seeing 3 barsI modified it to work full screen and you're right; it's generally too blurry and dark. It can be sharpened up but at the cost of losing the shadow mask effect, which is mainly what I'm after in a CRT shader.
Got this error for that; running 11.1:
Code: Select all
Error: Cannot link shader program object:
Fragment info
-------------
0(52) : warning C7533: global variable gl_FragColor is deprecated after version 120
0(44) : error C5121: multiple bindings to output semantic "COL0"
stack traceback:
[string "boot.lua"]:637: in function <[string "boot.lua"]:633>
[C]: in function 'newShader'
tri.lua:60: in main chunk
[C]: in function 'require'
main.lua:2: in main chunk
[C]: in function 'require'
[string "boot.lua"]:475: in function <[string "boot.lua"]:311>
[C]: in function 'xpcall'
[string "boot.lua"]:645: in function <[string "boot.lua"]:639>
[C]: in function 'xpcall'
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 19 guests