updated chromatic aberration shader to general function
This commit is contained in:
parent
5c8966fbd7
commit
262c83223b
|
@ -2,23 +2,29 @@
|
||||||
const float Samples = 4.;
|
const float Samples = 4.;
|
||||||
const float Strength = 0.085; // 2.5%
|
const float Strength = 0.085; // 2.5%
|
||||||
|
|
||||||
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
vec3 chromatic_aberration(in sampler2D tex, in vec2 uv)
|
||||||
{
|
{
|
||||||
vec2 uv = fragCoord/iResolution.xy-.5;
|
|
||||||
vec3 col = vec3(0);
|
vec3 col = vec3(0);
|
||||||
|
|
||||||
|
uv -= .5;
|
||||||
|
|
||||||
vec3 f = 1. - length(uv) * Strength*vec3(2.,1.,0.);
|
vec3 f = 1. - length(uv) * Strength*vec3(2.,1.,0.);
|
||||||
|
|
||||||
for (float i = 0.; i < Samples; i++)
|
for (float i = 0.; i < Samples; i++)
|
||||||
{
|
{
|
||||||
vec3 fs = mix(f, vec3(1), i/Samples);
|
vec3 fs = mix(f, vec3(1), i/Samples);
|
||||||
col += vec3(
|
col += vec3(
|
||||||
texture(iChannel0, uv * fs.x+.5).r,
|
texture(tex, uv * fs.x+.5).r,
|
||||||
texture(iChannel0, uv * fs.y+.5).g,
|
texture(tex, uv * fs.y+.5).g,
|
||||||
texture(iChannel0, uv * fs.z+.5).b
|
texture(tex, uv * fs.z+.5).b
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
col /= Samples;
|
return col / Samples;
|
||||||
|
}
|
||||||
fragColor = vec4(col,1.0);
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord/iResolution.xy;
|
||||||
|
|
||||||
|
fragColor = vec4(chromatic_aberration(iChannel0, uv),1.0);
|
||||||
}
|
}
|
Loading…
Reference in New Issue