v4k-git-backup/demos/art/fx/fxGrain.fs

15 lines
503 B
Forth
Raw Normal View History

2023-09-27 06:49:59 +00:00
uniform float intensity; /// set:16 max:32
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 uv = fragCoord.xy / iResolution.xy;
vec4 color = texture(iChannel0, uv), outcolor;
float x = (uv.x + 4.0 ) * (uv.y + 4.0 ) * (iTime * 10.0);
vec4 grain = vec4(mod((mod(x, 13.0) + 1.0) * (mod(x, 123.0) + 1.0), 0.01)-0.005) * intensity;
outcolor = color + grain; // method 1
// outcolor = color * (1.0 - grain); // method 2
FRAGCOLOR = vec4(outcolor.rgb, color.a);
}