X-Git-Url: http://git.tdb.fi/?p=libs%2Fdemoscene.git;a=blobdiff_plain;f=data%2Fvignette.glsl;fp=data%2Fvignette.glsl;h=58822c482b92c0c2a97e84b886d1e8a26a9d6527;hp=0000000000000000000000000000000000000000;hb=1e3954a988c6d6d946260019f25a4ad3262e01c4;hpb=b8e89ca72ec17461c6d91bf107a7e4b08cf9eff1 diff --git a/data/vignette.glsl b/data/vignette.glsl new file mode 100644 index 0000000..58822c4 --- /dev/null +++ b/data/vignette.glsl @@ -0,0 +1,32 @@ +import postprocess; + +uniform Vignette +{ + vec2 coord_scale; + vec4 optical; + vec2 optical_range; + float natural; +}; + +#pragma MSP stage(fragment) +void main() +{ + vec4 incoming = texture(source, texcoord); + vec2 r = vertex.xy*coord_scale; + float r_sq = dot(r, r); + + float vignette = 1.0; + if(r_sq>=optical_range.y) + vignette = 0.0; + else if(r_sq>=optical_range.x) + { + float r = sqrt(r_sq)-optical.x; + float v = (optical.z*acos(r/optical.y)-sqrt(optical.z-r*r)*r); + vignette = v/optical.w; + } + + float c_sq = 1/(1+r_sq*natural); + vignette *= c_sq*c_sq; + + frag_color = vec4(incoming.rgb*vignette, incoming.a); +}