Pixel-Composer/shaders/sh_vignette/sh_vignette.fsh
2024-01-15 19:53:46 +07:00

29 lines
659 B
GLSL

varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float exposure;
uniform float strength;
uniform float amplitude;
uniform float smoothness;
void main() {
vec2 uv = v_vTexcoord;
vec2 _uv = v_vTexcoord - 0.5;
float dist = dot(_uv, _uv);
float ang = atan(_uv.y, _uv.x);
vec2 _sp = 0.5 + vec2(cos(ang), sin(ang)) * dist;
float smt = smoothness / 2.;
uv = mix(uv, _sp, smt);
uv *= 1.0 - uv.yx;
float vig = uv.x * uv.y * exposure;
vig = pow(vig, 0.25 + smt);
vig = clamp(vig, 0., 1.);
vec4 samp = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(samp.rgb * (1. - ((1. - vig) * strength)), samp.a);
}