summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-03-29 13:24:07 -0500
committerDave Parks <davep@lindenlab.com>2023-03-29 13:24:07 -0500
commitb130831106d058f0be5414a9a3bcaa99636c7bc0 (patch)
treef83e82760c4b3a3eeb7186439c8b45d21120ef6e /indra/newview/app_settings/shaders/class1/deferred
parent4f651bceabc721c9c05e58c74583373ec5d9bcba (diff)
DRTVWR-559 Dynamic exposure followup -- stochastic sampling, weight based on luminance and distance to center of screen, rebalance night, don't rely on blending not clamping R16F.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl45
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/skyV.glsl2
3 files changed, 37 insertions, 13 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl
index d0269735fd..689929fe38 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl
@@ -31,12 +31,22 @@ 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()
{
- int samples = 16;
- float step = 1.0/(samples-4);
+ float step = 1.0/32.0;
float start = step;
float end = 1.0-step;
@@ -45,23 +55,38 @@ void main()
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);
- w += 1.0;
- col += texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb;
+ 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;
- // calculate luminance the same way LLColor4::calcHSL does
- float mx = max(max(col.r, col.g), col.b);
- float mn = min(min(col.r, col.g), col.b);
- float lum = (mx + mn) * 0.5;
+ float L = lum(col);
+
+ float s = clamp(0.1/L, 0.5, 4.0);
+
+ float prev = texture(exposureMap, vec2(0.5,0.5)).r;
+ s = mix(prev, s, min(dt*2.0, 0.04));
- frag_color = vec4(lum, lum, lum, dt);
+ 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 834cf9dc43..4ac1ff9368 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
@@ -108,9 +108,8 @@ uniform float gamma;
vec3 toneMap(vec3 color)
{
- float exp_sample = texture(exposureMap, vec2(0.5,0.5)).r;
+ float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r;
- float exp_scale = clamp(0.1/exp_sample, 0.5, 8.0);
color *= exposure * exp_scale;
#ifdef TONEMAP_ACES_NARKOWICZ
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
index 08fbc4bce8..fc6291d438 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -91,7 +91,7 @@ void main()
vary_LightNormPosDot = rel_pos_lightnorm_dot;
// Initialize temp variables
- vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color*0.5;
+ 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