Shadertoy-Shaders/blur-filter/Buffer A.glsl

32 lines
661 B
Plaintext
Raw Normal View History

2023-06-03 15:01:52 +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.5) * pow(noise, vec3(0.2));
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord/iResolution.xy;
vec3 imageCol = texture(iChannel0, uv).rgb;
vec3 col = pow(imageCol * mix_with_noise(imageCol, uv * 2.0), vec3(0.5));
fragColor = vec4(col, 1.0);
}