Pixel-Composer/shaders/sh_vignette/sh_vignette.fsh

33 lines
754 B
Plaintext
Raw Normal View History

2024-01-12 05:03:35 +01:00
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
2024-01-15 13:53:46 +01:00
uniform float exposure;
2024-01-12 05:03:35 +01:00
uniform float strength;
uniform float amplitude;
2024-01-15 13:53:46 +01:00
uniform float smoothness;
2024-08-30 11:08:30 +02:00
uniform int light;
2024-01-12 05:03:35 +01:00
void main() {
vec2 uv = v_vTexcoord;
2024-01-15 13:53:46 +01:00
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;
2024-01-12 05:03:35 +01:00
2024-01-15 13:53:46 +01:00
vig = pow(vig, 0.25 + smt);
2024-01-12 05:03:35 +01:00
vig = clamp(vig, 0., 1.);
vec4 samp = texture2D( gm_BaseTexture, v_vTexcoord );
2024-08-30 11:08:30 +02:00
float str = (1. - ((1. - vig) * strength));
if(light == 1) str = str < 0.001? 10000. : 1. / str;
gl_FragColor = vec4(samp.rgb * str, samp.a);
2024-01-12 05:03:35 +01:00
}