hyprland-community / awesome-hyprland

Awesome list for Hyprland [maintainer=@yavko]
Creative Commons Zero v1.0 Universal
2.68k stars 64 forks source link

Share your shaders! #22

Open yavko opened 1 year ago

yavko commented 1 year ago

Shaders are pretty powerful, you can force colorschemes on your entire display, make modern LCD look like a 80s CRT, and other stuff I'm not even thinking of. So let's add a section for them. Problem is I have 1 shader, and having just one is pointless, so if you have any shaders or know someone who does please share shaders in the replies!

end-4 commented 1 year ago
the shader ```glsl precision highp float; varying vec2 v_texcoord; uniform sampler2D tex; uniform float time; void warpco(inout vec2 tc) { tc -= 0.5; tc *= length(tc) * 2.0; tc += 0.5; } float rand1d(float seed) { return sin(seed*1454.0); } float rand2d(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898,78.233))) * 43758.5453); } vec3 rgb(in vec2 tc, float freq, float amp, inout vec4 centre) { vec2 off = vec2(1.0/800.0, 0.0) * sin(tc.t * freq + time) * amp; vec2 off2 = vec2(1.0/800.0, 0.0) * sin(tc.t * freq - time * 1.5) * amp; centre = texture2D(tex, tc); return vec3(texture2D(tex, tc-off).r, centre.g, texture2D(tex, tc+off2).b); } void main() { // vec2 px = 1.0 / textureSize(tex, 0).st; vec2 tc = v_texcoord; warpco(tc); tc = mix(v_texcoord, tc, sin(time * 2.0)*0.07); tc.x += rand2d(floor(tc * 20.0 + floor(time * 2.5))) * 0.01; tc.x += rand1d(floor(tc.x * 40.0)) * 0.005 * rand1d(time * 0.001); tc.y += sin(tc.x + time) * 0.02; vec4 centre; vec3 bent = rgb(tc, 100.0, 5.0, centre); vec3 col = mix(centre.rgb, bent, sin(time)); gl_FragColor = vec4(col, centre.a); // gl_FragColor = vec4(texture2D(tex, v_texcoord)); } ```

edit: pasted the code directly here since the discord link doesn't last forever

JustSimplyKyle commented 1 year ago

https://github.com/sigma-957/hyprland-shaders/blob/main/crt.frag my modified version based on it, added scanlines and some color corrections crt.txt

loqusion commented 1 year ago

There's a blue light filter and vibrance, both of which are included in https://github.com/loqusion/hyprshade.

paolobettelini commented 1 year ago

I personally think we should have a dedicated place for this, with screenshots and everything. A GitHub issue isn't gonna cut it is it? What do you think?

NotAShelf commented 1 year ago

I personally think we should have a dedicated place for this, with screenshots and everything. A GitHub issue isn't gonna cut it is it? What do you think?

the issue is to collect them, not to store them. as per the purpose of this repository, they will be store in this awesome-hyprland repository with links.

yavko commented 1 year ago

Yeah, I'll create something for them ;)

loqusion commented 1 year ago

I think we should at least store copies of them, in case the original sources get deleted.

yavko commented 1 year ago

Ofc

mekb-turtle commented 1 year ago
simple blur shader ```frag #version 330 core precision mediump float; varying vec2 v_texcoord; uniform sampler2D tex; uniform int blurRadius = 1; void main() { if (blurRadius <= 0) { gl_FragColor = texture(tex, v_texcoord); return; } vec2 invTextureSize = 1.0f / textureSize(tex, 0); float invBlurRadius = 1.0f / float(blurRadius); float samples = 0.0f; vec4 colorSum = vec4(0.0f); for (int x = -blurRadius; x <= blurRadius; ++x) { for (int y = -blurRadius; y <= blurRadius; ++y) { vec2 offset = vec2(x, y) * invTextureSize; float strength = 1 - (length(offset) * invBlurRadius); samples += strength; vec2 coords = v_texcoord + offset; colorSum += texture(tex, coords) * strength; } } colorSum /= samples; gl_FragColor = colorSum; } ```
yavko commented 1 year ago
simple blur shader ```frag #version 330 core precision mediump float; varying vec2 v_texcoord; uniform sampler2D tex; uniform int blurRadius = 1; void main() { if (blurRadius <= 0) { gl_FragColor = texture(tex, v_texcoord); return; } vec2 invTextureSize = 1.0f / textureSize(tex, 0); float invBlurRadius = 1.0f / float(blurRadius); float samples = 0.0f; vec4 colorSum = vec4(0.0f); for (int x = -blurRadius; x <= blurRadius; ++x) { for (int y = -blurRadius; y <= blurRadius; ++y) { vec2 offset = vec2(x, y) * invTextureSize; float strength = 1 - (length(offset) * invBlurRadius); samples += strength; vec2 coords = v_texcoord + offset; colorSum += texture(tex, coords) * strength; } } colorSum /= samples; gl_FragColor = colorSum; } ```

What does this blur exactly, the whole screen?

mekb-turtle commented 1 year ago

What does this blur exactly, the whole screen?

yeah, no need for it though, just thought it'd be cool to make

mekb-turtle commented 1 year ago
also bloom shader ```frag #version 330 core precision mediump float; varying vec2 v_texcoord; uniform sampler2D tex; uniform int bloomRadius = 10; uniform float bloomIntensity = 0.7f; uniform float bloomThreshold = 0.4f; void main() { vec4 color = texture(tex, v_texcoord); vec4 bloomThreshold4 = vec4(bloomThreshold); bloomThreshold4.w = 0.0f; vec2 invTextureSize = 1.0f / textureSize(tex, 0); float invBloomRadius = bloomRadius == 0 ? 1.0f : 1.0f / float(bloomRadius); float invBloomThreshold = 1.0f / (1.0f - bloomThreshold); float samples = 0.0f; vec4 colorSum = vec4(0.0f); for (int x = -bloomRadius; x <= bloomRadius; ++x) { for (int y = -bloomRadius; y <= bloomRadius; ++y) { vec2 offset = vec2(x, y) * invTextureSize; vec2 coords = v_texcoord + offset; vec4 color = texture(tex, coords); color = max(color - bloomThreshold, vec4(0.0f)); float strength = 1 - (length(offset) * invBloomRadius); samples += strength; strength *= max(max(color.x, color.y), color.z) * invBloomThreshold; strength *= bloomIntensity; colorSum += color * strength; } } colorSum /= samples; gl_FragColor = min(color + colorSum, 1.0f); } ```
LamprosPitsillos commented 1 year ago

Can you also post screenshots along with the shader ? Makes browsing this thread easier , thanks!

mekb-turtle commented 1 year ago

i don't know how to with nvidia

LamprosPitsillos commented 1 year ago

i don't know how to with nvidia

https://github.com/hyprland-community/awesome-hyprland#screenshotting

mekb-turtle commented 1 year ago

https://github.com/hyprland-community/awesome-hyprland#screenshotting

sorry, I should've added more detail, screenshotting works fine but the shaders aren't applied to the screenshot

LamprosPitsillos commented 1 year ago

Ohhh didn't know sorry. I imagine you would have to screenshot and theeen apply shader somehow, that's probably why noone posted screenshots

ed-henrique commented 1 year ago
monochromatic shader ```c precision mediump float; varying vec2 v_texcoord; uniform sampler2D tex; void main() { vec4 pixColor = texture2D(tex, v_texcoord); float lum = dot(pixColor.rgb, vec3(0.299, 0.587, 0.114)); // BT.601 // float lum = dot(pixColor.rgb, vec3(0.2126, 0.7152, 0.0722)); // BT.709 // float lum = dot(pixColor.rgb, vec3(0.2627, 0.6780, 0.0593)); // BT.2100 // Check https://en.wikipedia.org/wiki/Grayscale for more information about which one to choose vec4 outCol = vec4(vec3(lum), pixColor.a); gl_FragColor = outCol; } ```
yavko commented 1 year ago

Sick

Euro20179 commented 10 months ago

Don't know if you're still accepting shaders since there is a pull request, but someone said I should put this here: https://github.com/Euro20179/.files/blob/master/.config/hypr/shaders/crt.frag

It's another crt shader, but it's different from the one posted earlier

It's a modified version of this

And since someone wanted screenshots, here's a screenshot screenshot

yavko commented 10 months ago

t from the one posted earlier

It's a modi

sick ill add it

psynyde commented 10 months ago

t from the one posted earlier It's a modi

sick ill add it

I asked him to post it in here cause it doesn't use uniform lowp float time; Shaders without time doesn't require damage_tracking to be disabled.

I think you should add some sort of note which shaders might need damage_tracking to be turned off when you add it.

yavko commented 10 months ago

t from the one posted earlier It's a modi

sick ill add it

I asked him to post it in here cause it doesn't use uniform lowp float time; Shaders without time doesn't require damage_tracking to be disabled.

I think you should add some sort of note which shaders might need damage_tracking to be turned off when you add it.

Oh is that so?