-
Notifications
You must be signed in to change notification settings - Fork 3
/
v002.film-vignette.frag
37 lines (27 loc) · 1.05 KB
/
v002.film-vignette.frag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
uniform float vignette;
uniform float vignetteEdge;
uniform float vignetteMix;
// define our rectangular texture samplers
uniform sampler2DRect tex0;
// define our varying texture coordinates
varying vec2 texcoord0;
uniform vec2 dim;
//varying vec2 texcoordLUT;
/// functions
// create a black and white oval about the center of our image for our vignette
vec4 vignetteFucntion(vec2 normalizedTexcoord, float vignetteedge, float vignetteMix)
{
normalizedTexcoord = 2.0 * normalizedTexcoord - 1.0; // - 1.0 to 1.0
float r = length(normalizedTexcoord);
vec4 vignette = (vec4(smoothstep(0.0, 1.0, pow(clamp(r - vignetteMix, 0.0, 1.0), 1.0 + vignetteedge * 10.0))));
return clamp(1.0 - vignette, 0.0, 1.0);
}
void main (void)
{
vec2 normcoord = texcoord0/dim;
// make a vignette around our borders.
vec4 vignetteResult = vignetteFucntion(normcoord, vignetteEdge, vignetteMix);
// sharpen via unsharp mask (subtract image from blured image)
vec4 input0 = texture2DRect(tex0, texcoord0);
gl_FragColor = mix(input0,vignetteResult * input0, vignette);
}