Skip to content

CIOSAI/godot-glitch-fade

Repository files navigation

godot-glitch-fade

Download as a zip and import

  • uniform boolean horizontal; (true means horizontal, false means vertical)
  • uniform float distort; (between -1 and 1)
  • uniform sampler2d noise; (noise texture, you can just use opensimplex noise that godot provides)

for horizontal fading I want the pixels in the same y level to share the same noise value

image

now use the flattened uv to get the noise value

image

here you could just distort the image by the noise value linearly, but I find that boring, so instead of a simple distort*noise_val type thing, run the noise value thru this

image

now with distort at 0, it doesn't distort the texture, at 1 it fades the texture away completely, but negative distort currently just does exactly what positive does, we can get the directionality back, by multiplying out result with the sign

image

this, then, is how much to distort, and the direction to distort, put this result in either x or y depending on horizontal or vertical

image

add it onto the uv

image

use the uv to grab the original texture, aaaaand we're done!

image

except, this

image

uv coordinate over 1 or under 0 may result in it, or maybe other result for you, but let's just make it cleaner either

using step() to get 1 if the uv is in legal range(0 to 1) and 0 is its outside(over 1 or under 0), here im using smoothstep(), if you dont have screen_pixel_uv then try 1./resolution.x or something similar, step(val, edge) instead of the normal step(edge, val) gives you essentially 1.-step(edge, vel), i assume we all know this

image

this above would give us 1 if the uv is legal, 0 if not, multiply this back with the original opacity

image

tada!

image

About

glitchy fading shader in godot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published