From 4b92ee1716f9023e482c90b372f50c8b29eb5f42 Mon Sep 17 00:00:00 2001 From: samuncle Date: Mon, 3 Mar 2014 14:12:56 +0100 Subject: [PATCH] Add a vignette to simulate a real camera --- data/shaders/color_levels.frag | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/data/shaders/color_levels.frag b/data/shaders/color_levels.frag index a803c8a5e..6ea375292 100644 --- a/data/shaders/color_levels.frag +++ b/data/shaders/color_levels.frag @@ -14,13 +14,13 @@ varying vec2 uv; void main() { - vec2 texc = uv; - //texc.y = 1.0 - texc.y; + vec4 col = texture(tex, uv); - - vec4 col = texture(tex, texc); - - //col = col / (1 - col); + // Compute the vignette + vec2 inside = uv - 0.5; + float vignette = 1 - dot(inside, inside); + vignette = clamp(pow(vignette, 0.8), 0, 1); + vignette = vignette + vignette - 0.5; float inBlack = inlevel.x; float inWhite = inlevel.z; @@ -32,5 +32,5 @@ void main() col.rgb = (pow(((col.rgb * 255.0) - inBlack) / (inWhite - inBlack), vec3(1.0 / inGamma)) * (outWhite - outBlack) + outBlack) / 255.0; - FragColor = vec4(col.rgb, 1.0); + FragColor = vec4(col.rgb * vignette, 1.0); }