summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl30
1 files changed, 21 insertions, 9 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
index be1003a7e0..c8afacf9bb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
@@ -1,9 +1,9 @@
/**
* @file luminanceF.glsl
*
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $LicenseInfo:firstyear=2023&license=viewerlgpl$
* Second Life Viewer Source Code
- * Copyright (C) 2007, Linden Research, Inc.
+ * Copyright (C) 2023, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -22,19 +22,31 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
+
/*[EXTRA_CODE_HERE]*/
-#ifdef DEFINE_GL_FRAGCOLOR
+// take a luminance sample of diffuseRect and emissiveRect
+
out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-uniform sampler2DRect diffuseMap;
-VARYING vec2 vary_fragcoord;
+in vec2 vary_fragcoord;
+
+uniform sampler2D diffuseRect;
+uniform sampler2D emissiveRect;
+
+float lum(vec3 col)
+{
+ vec3 l = vec3(0.2126, 0.7152, 0.0722);
+ return dot(l, col);
+}
void main()
{
- frag_color = texture2DRect(diffuseMap, vary_fragcoord.xy);
+ vec2 tc = vary_fragcoord*0.6+0.2;
+ tc.y -= 0.1; // HACK - nudge exposure sample down a little bit to favor ground over sky
+ vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb;
+ float L = lum(c);
+ frag_color = vec4(max(L, 0.0));
}
+