summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl92
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/skyV.glsl10
5 files changed, 107 insertions, 7 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
index 5ca210863e..3a7552d23e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
@@ -114,7 +114,7 @@ void main()
float rel_pos_len = length(rel_pos);
// Initialize temp variables
- vec3 sunlight = sunlight_color;
+ vec3 sunlight = sunlight_color*2.0;
vec3 light_atten;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl
new file mode 100644
index 0000000000..ff37f9e4b3
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl
@@ -0,0 +1,92 @@
+/**
+ * @file exposureF.glsl
+ *
+ * $LicenseInfo:firstyear=2023&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * 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
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+/*[EXTRA_CODE_HERE]*/
+
+out vec4 frag_color;
+
+uniform sampler2D diffuseRect;
+uniform sampler2D emissiveRect;
+uniform sampler2D exposureMap;
+
+uniform float dt;
+uniform vec2 noiseVec;
+
+// calculate luminance the same way LLColor4::calcHSL does
+float lum(vec3 col)
+{
+ float mx = max(max(col.r, col.g), col.b);
+ float mn = min(min(col.r, col.g), col.b);
+ return (mx + mn) * 0.5;
+}
+
+void main()
+{
+ float step = 1.0/32.0;
+
+ float start = step;
+ float end = 1.0-step;
+
+ float w = 0.0;
+
+ vec3 col;
+
+ vec2 nz = noiseVec * step * 0.5;
+
+ for (float x = start; x <= end; x += step)
+ {
+ for (float y = start; y <= end; y += step)
+ {
+ vec2 tc = vec2(x,y) + nz;
+ vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb;
+ float L = max(lum(c), 0.25);
+
+ float d = length(vec2(0.5)-tc);
+ d = 1.0-d;
+ d *= d;
+ d *= d;
+ d *= d;
+ L *= d;
+
+ w += L;
+
+ col += c * L;
+ }
+ }
+
+ col /= w;
+
+ float L = lum(col);
+
+ float s = clamp(0.1/L, 0.5, 2.0);
+
+ float prev = texture(exposureMap, vec2(0.5,0.5)).r;
+ s = mix(prev, s, min(dt*2.0, 0.04));
+
+ frag_color = vec4(s, s, s, dt);
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
index 87324bca7f..4ac1ff9368 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
@@ -35,6 +35,7 @@ out vec4 frag_color;
uniform sampler2D diffuseRect;
uniform sampler2D emissiveRect;
+uniform sampler2D exposureMap;
uniform vec2 screen_res;
VARYING vec2 vary_fragcoord;
@@ -107,7 +108,9 @@ uniform float gamma;
vec3 toneMap(vec3 color)
{
- color *= exposure;
+ float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r;
+
+ color *= exposure * exp_scale;
#ifdef TONEMAP_ACES_NARKOWICZ
color = toneMapACES_Narkowicz(color);
@@ -190,6 +193,9 @@ void main()
vec3 nz = vec3(noise(seed.rg), noise(seed.gb), noise(seed.rb));
diff.rgb += nz*0.003;
//diff.rgb = nz;
+
+ //float exp_sample = texture(exposureMap, vec2(0.5,0.5)).r;
+ //diff.g = exp_sample;
frag_color = diff;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
index 4d24b4de9a..8b4cac3e64 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
@@ -33,6 +33,6 @@ void main()
{
//transform vertex
vec4 pos = vec4(position.xyz, 1.0);
- gl_Position = pos;
+ gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
index 1424b57d6f..fc6291d438 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -32,8 +32,8 @@ ATTRIBUTE vec3 position;
///////////////////////////////////////////////////////////////////////////////
// Output parameters
-VARYING vec3 vary_HazeColor;
-VARYING float vary_LightNormPosDot;
+out vec3 vary_HazeColor;
+out float vary_LightNormPosDot;
// Inputs
uniform vec3 camPosLocal;
@@ -56,6 +56,8 @@ uniform float max_y;
uniform vec3 glow;
uniform float sun_moon_glow_factor;
+uniform int cube_snapshot;
+
// NOTE: Keep these in sync!
// indra\newview\app_settings\shaders\class1\deferred\skyV.glsl
// indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl
@@ -89,8 +91,8 @@ void main()
vary_LightNormPosDot = rel_pos_lightnorm_dot;
// Initialize temp variables
- vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
-
+ vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color*0.75;
+
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y);