aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl')
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl42
1 files changed, 42 insertions, 0 deletions
diff --git a/linden/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl b/linden/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl
new file mode 100644
index 0000000..271d5cf
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl
@@ -0,0 +1,42 @@
1/**
2 * @file nightVisionF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect RenderTexture;
9uniform sampler2D NoiseTexture;
10uniform float brightMult;
11uniform float noiseStrength;
12
13float luminance(vec3 color)
14{
15 /// CALCULATING LUMINANCE (Using NTSC lum weights)
16 /// http://en.wikipedia.org/wiki/Luma_%28video%29
17 return dot(color, vec3(0.299, 0.587, 0.114));
18}
19
20void main(void)
21{
22 /// Get scene color
23 vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st));
24
25 /// Extract luminance and scale up by night vision brightness
26 float lum = luminance(color) * brightMult;
27
28 /// Convert into night vision color space
29 /// Newer NVG colors (crisper and more saturated)
30 vec3 outColor = (lum * vec3(0.91, 1.21, 0.9)) + vec3(-0.07, 0.1, -0.12);
31
32 /// Add noise
33 float noiseValue = texture2D(NoiseTexture, gl_TexCoord[1].st).r;
34 noiseValue = (noiseValue - 0.5) * noiseStrength;
35
36 /// Older NVG colors (more muted)
37 // vec3 outColor = (lum * vec3(0.82, 0.75, 0.83)) + vec3(0.05, 0.32, -0.11);
38
39 outColor += noiseValue;
40
41 gl_FragColor = vec4(outColor, 1.0);
42}