Shadertoy-Shaders/Optimized-Bilateral-Filter/Buffer A.glsl

33 lines
651 B
Plaintext
Raw Normal View History

2023-06-03 14:58:20 +00:00
float luminance(in vec3 srgb)
{
return dot(srgb, vec3(0.2126, 0.7152, 0.0722));
}
float falloff(in float lum)
{
float sq = lum * lum;
return sq * sq - 2.0 * sq + 1.0;
}
vec3 mix_with_noise(inout vec3 col, in vec2 uv)
{
vec3 noise = texture(iChannel1, uv).rgb;
float fac = falloff(luminance(col) * 2.0 - 1.0);
return mix(col, noise, fac * 0.2);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord/iResolution.xy;
vec3 imageCol = texture(iChannel0, uv).rgb;
vec3 col = mix_with_noise(imageCol, uv * 2.0);
col = mix_with_noise(col, uv * 0.5);
fragColor = vec4(col, 1.0);
}