Share a Shader!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Share a Shader!
Can someone make a shader that makes a monitor bulge effect like this?
Mari0 has a shader like this but I don't know how to use it in 0.9.0.
Mari0 has a shader like this but I don't know how to use it in 0.9.0.
macOS 10.14 Mojave | LÖVE 11.2
- retrotails
- Party member
- Posts: 212
- Joined: Wed Apr 18, 2012 12:37 am
Re: Share a Shader!
I don't even need to post a .love to demonstrate this.Ratchet wrote:Can someone make a shader that makes a monitor bulge effect like this?
Mari0 has a shader like this but I don't know how to use it in 0.9.0.
Take a shader from the Mari0 .love, such as CRT.frag, and store it with main.lua.
Code: Select all
function love.load()
canvas = love.graphics.newCanvas()
local str = love.filesystem.read('CRT.frag')
shader = love.graphics.newShader(str)
shader:send('inputSize', {love.graphics.getWidth(), love.graphics.getHeight()})
shader:send('textureSize', {love.graphics.getWidth(), love.graphics.getHeight()})
end
function love.draw()
love.graphics.setCanvas(canvas)
--draw stuff here
love.graphics.setCanvas()
love.graphics.setShader(shader)
love.graphics.draw(canvas)
love.graphics.setShader()
end
Re: Share a Shader!
Fantastic, thanks!
EDIT: Is there a way to make the scanlines more transparent? Everything looks so dark. Maybe a alpha of 0.5 for the scanlines would be nice
EDIT: Is there a way to make the scanlines more transparent? Everything looks so dark. Maybe a alpha of 0.5 for the scanlines would be nice
macOS 10.14 Mojave | LÖVE 11.2
- retrotails
- Party member
- Posts: 212
- Joined: Wed Apr 18, 2012 12:37 am
Re: Share a Shader!
Increase the last number in line 124 of CRT.frag. 0.5 seems okay.Ratchet wrote:Fantastic, thanks!
EDIT: Is there a way to make the scanlines more transparent? Everything looks so dark. Maybe a alpha of 0.5 for the scanlines would be nice
Code: Select all
vec4 weights = vec4(distance / 0.5);
Re: Share a Shader!
Much much better, thank you
I played with all these values, of cause this one I forgot... (And I'm too stupid to understand these complex math thingys)
I played with all these values, of cause this one I forgot... (And I'm too stupid to understand these complex math thingys)
macOS 10.14 Mojave | LÖVE 11.2
Re: Share a Shader!
Thanks for posting that shader! I'm learning how to use them too, and so I decided to try and base something off of yours, just without the brightness problems associated with making RGB values follow a sine wave patternbeforan wrote:this is pretty simple stuff, and sorry if it's duplicated but I couldn't find one from cursory searching:
a colour cycling shader!
Code's below for whoever wants it
- Attachments
-
- HueShift.love
- Works for 0.9.0+
- (31.19 KiB) Downloaded 706 times
"Bump." -CMFIend420
Re: Share a Shader!
For the Shader challenged, you could just change
to
and forget about Shaders.
Code: Select all
gfx.setColor(255, 255, 255)
gfx.print("Increase/Decrease transition speed: Up/Down")
gfx.setShader(shader)
gfx.draw(img, wdw.getWidth() / 2 - img:getWidth() / 2, wdw.getHeight() / 2 - img:getHeight() / 2)
gfx.setShader()
Code: Select all
gfx.print("Increase/Decrease transition speed: Up/Down")
gfx.setColor( 255 * c[1], 255 * c[2], 255 * c[3] )
gfx.draw(img, wdw.getWidth() / 2 - img:getWidth() / 2, wdw.getHeight() / 2 - img:getHeight() / 2)
Re: Share a Shader!
Aw crap
Yeah, but shaders!
EDIT: let's make this post more constructive! Zoom-blur shader, ported (and simplified) from here:
Also a similarly-coded spotlight shader:
Sorry if someone has already done this
Yeah, but shaders!
EDIT: let's make this post more constructive! Zoom-blur shader, ported (and simplified) from here:
Code: Select all
extern float strength;
vec4 effect(vec4 color, Image tex, vec2 tC, vec2 pC){
float[10] sample;
for(int i = 0; i < 10; i++){
sample[i] = (i - 5) / strength;
}
vec2 dir = (.5 - tC) * -1;
float dist = sqrt(dir.x * dir.x + dir.y * dir.y);
dir = dir/dist;
vec4 c = Texel(tex, tC);
vec4 sum = color;
for(int i = 0; i < 10; i++){
sum += Texel(tex, tC + dir * sample[i] * strength / 50);
}
sum /= 10;
float t = dist * strength;
t = clamp(t, 0, 1);
return mix(c, sum, t);
}
Code: Select all
extern float strength;
vec4 effect(vec4 color, Image tex, vec2 tC, vec2 pC){
vec2 dir = .5 - tC;
float dist = sqrt(dir.x * dir.x + dir.y * dir.y);
vec4 c = Texel(tex, tC);
float t = dist * strength;
t = clamp(t, 0, 1);
return mix(c, vec4(0), t);
}
"Bump." -CMFIend420
- OmarShehata
- Party member
- Posts: 259
- Joined: Tue May 29, 2012 6:46 pm
- Location: Egypt
- Contact:
Re: Share a Shader!
Just made a smoke shader. Was really interested about trying shaders that "propagate". By that I mean, shaders that have an initial state and build off it. Had to use two canvases to maintain the previous state and feed it back to the shader.
It's actually based off this paper. The algorithm itself can be summarized in one line (with the rest setting everything up), that being the one that sets the current pixel's alpha value, to the neighboring pixel's values with a certain factor.
It's actually based off this paper. The algorithm itself can be summarized in one line (with the rest setting everything up), that being the one that sets the current pixel's alpha value, to the neighboring pixel's values with a certain factor.
- Attachments
-
- Smoke.love
- (1.28 KiB) Downloaded 2891 times
Re: Share a Shader!
Really pretty, OmarShehata! I was playing around with it just now, if you 'paint' at the very bottom of the window the effect freezes. I didn't look at the source but I assume it's because the pixels at the bottom never change their alpha values (since there's nothing to sample below them).
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 4 guests