From 2b2154f0217758b27b544d066024d922ba234d51 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 11 Apr 2023 15:09:58 -0500 Subject: SL-19564 Rebalance exposure and sky. Hack legacy diffuse map saturation and brightness to allow ACES Hill all the time. --- indra/newview/app_settings/settings.xml | 19 +++----------- .../shaders/class1/deferred/exposureF.glsl | 7 ++++-- .../shaders/class1/deferred/fullbrightF.glsl | 2 ++ .../shaders/class1/deferred/luminanceF.glsl | 2 +- .../class1/deferred/postDeferredGammaCorrect.glsl | 22 ++++++---------- .../shaders/class1/environment/srgbF.glsl | 29 +++++++++++++++++++++- .../shaders/class2/deferred/alphaF.glsl | 2 ++ .../shaders/class2/windlight/atmosphericsF.glsl | 4 +-- .../class2/windlight/atmosphericsFuncs.glsl | 8 +++--- .../shaders/class3/deferred/multiPointLightF.glsl | 2 ++ .../shaders/class3/deferred/multiSpotLightF.glsl | 3 ++- .../shaders/class3/deferred/pointLightF.glsl | 3 ++- .../shaders/class3/deferred/softenLightF.glsl | 13 ++++++++-- .../shaders/class3/deferred/spotLightF.glsl | 2 ++ 14 files changed, 73 insertions(+), 45 deletions(-) (limited to 'indra/newview/app_settings') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 7d15214ccb..3d8cbc9527 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10358,17 +10358,6 @@ Value 128 - RenderTonemapper - - Comment - Which tone mapping function to use (0 - Linear, 1 - ACES Narkowicz, 2 - ACES Hill) - Persist - 1 - Type - U32 - Value - 2 - RenderExposure Comment @@ -10456,7 +10445,7 @@ Type F32 Value - 3.0 + 1.25 RenderReflectionProbeMaxLocalLightAmbiance @@ -10478,7 +10467,7 @@ Type F32 Value - 0.125 + 0.6 RenderDynamicExposureMax @@ -10489,7 +10478,7 @@ Type F32 Value - 1.3 + 1.5 RenderDynamicExposureCoefficient @@ -10500,7 +10489,7 @@ Type F32 Value - 0.175 + 0.3 RenderShaderLODThreshold diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl index 7ed8e4c8ce..81f1e9aed0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -48,8 +48,11 @@ void main() vec2 tc = vec2(0.5,0.5); float L = textureLod(emissiveRect, tc, 8).r; - - float s = clamp(dynamic_exposure_params.x/L, dynamic_exposure_params.y, dynamic_exposure_params.z); + float max_L = dynamic_exposure_params.x; + L = clamp(L, 0.0, max_L); + L /= max_L; + L = pow(L, 2.0); + float s = mix(dynamic_exposure_params.z, dynamic_exposure_params.y, L); float prev = texture(exposureMap, vec2(0.5,0.5)).r; diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index b5eae3a1d5..11532135dd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -42,6 +42,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); #endif vec3 srgb_to_linear(vec3 cs); +vec3 legacy_adjust(vec3 c); vec3 linear_to_srgb(vec3 cl); vec3 fullbrightAtmosTransport(vec3 light); @@ -87,6 +88,7 @@ void main() #endif #ifndef IS_HUD + color.rgb = legacy_adjust(color.rgb); color.rgb = srgb_to_linear(color.rgb); color.rgb = fullbrightAtmosTransport(color.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl index e63e666778..e0eb91480e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl @@ -44,9 +44,9 @@ float lum(vec3 col) void main() { vec2 tc = vary_fragcoord*0.6+0.2; + tc.y -= 0.1; vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; float L = lum(c); - frag_color = vec4(L); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index ae6bdbba95..de766d6bc7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -105,29 +105,21 @@ vec3 toneMapACES_Hill(vec3 color) uniform float exposure; uniform float gamma; +vec3 legacy_adjust_post(vec3 c); + vec3 toneMap(vec3 color, float gs) { float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r; color *= exposure * exp_scale * gs; -#ifdef TONEMAP_ACES_NARKOWICZ - color = toneMapACES_Narkowicz(color); -#endif - -#ifdef TONEMAP_ACES_HILL color = toneMapACES_Hill(color); -#endif -#ifdef TONEMAP_ACES_HILL_EXPOSURE_BOOST - // boost exposure as discussed in https://github.com/mrdoob/three.js/pull/19621 - // this factor is based on the exposure correction of Krzysztof Narkowicz in his - // implemetation of ACES tone mapping - color *= 1.0/0.6; - color = toneMapACES_Hill(color); -#endif + color = linear_to_srgb(color); - return linear_to_srgb(color); + color = legacy_adjust_post(color); + + return color; } //=============================================================== @@ -181,7 +173,7 @@ vec3 legacyGamma(vec3 color) float legacyGammaApprox() { - //TODO -- figure out how to plumb this in as a uniform + //TODO -- figure out how to plumb this in as a uniform float c = 0.5; float gc = 1.0-pow(c, gamma); diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl index 4a8b892c3a..a3b48e0898 100644 --- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl @@ -72,7 +72,7 @@ vec3 rgb2hsv(vec3 c) vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); - float e = 1.0e-10; + float e = 1.0e-3; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } @@ -82,3 +82,30 @@ vec3 hsv2rgb(vec3 c) vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } + +vec3 legacy_adjust_no_brighten(vec3 c) +{ + vec3 desat = rgb2hsv(c.rgb); + desat.g *= 0.75; + desat.rgb = hsv2rgb(desat); + return desat; +} + +vec3 legacy_adjust(vec3 c) +{ +#if 1 + vec3 desat = rgb2hsv(c.rgb); + desat.g *= 1.0-(1.0-desat.b)*0.5; + //desat.g = max(desat.g-0.1*c.b-0.1, 0.0); + desat.b += (1.0-desat.b)*0.1f; + desat.rgb = hsv2rgb(desat); + return desat; +#else + return c; +#endif +} + +vec3 legacy_adjust_post(vec3 c) +{ + return c; +} diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 53552870ae..f4d6eff69e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -77,6 +77,7 @@ vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit); vec3 srgb_to_linear(vec3 c); vec3 linear_to_srgb(vec3 c); +vec3 legacy_adjust(vec3 c); vec2 encode_normal (vec3 n); vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten); @@ -239,6 +240,7 @@ void main() } diffuse_srgb.rgb *= vertex_color.rgb; + diffuse_srgb.rgb = legacy_adjust(diffuse_srgb.rgb); diffuse_linear.rgb = srgb_to_linear(diffuse_srgb.rgb); #endif // USE_VERTEX_COLOR diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 49ff49fdd8..e314555ef9 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -36,9 +36,9 @@ vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) { light *= atten.r; additive = srgb_to_linear(additive*2.0); - // magic 3.0 here is to match the default RenderSkyHDRScale -- this parameter needs to be plumbed into sky settings or something + // magic 1.25 here is to match the default RenderSkyHDRScale -- this parameter needs to be plumbed into sky settings or something // so it's available to all shaders that call atmosFragLighting instead of just softenLightF.glsl - additive *= sun_up_factor*3.0 + 1.0; + additive *= sun_up_factor*1.25 + 1.0; light += additive; return light; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 14ce33f81f..22db9dce03 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -139,10 +139,8 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou // brightness of surface both sunlight and ambient - // fudge sunlit and amblit to get consistent lighting compared to legacy - // midday before PBR was a thing - sunlit = sunlight.rgb * (1.0+sun_up_factor*0.2); - amblit = tmpAmbient.rgb * 0.25; + sunlit = sunlight.rgb; + amblit = vec3(1,0,1); //should no longer be used, filled in by calcAtmosphericVarsLinear additive *= vec3(1.0 - combined_haze); } @@ -172,7 +170,7 @@ void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, ou sunlit *= 2.0; // squash ambient to approximate whatever weirdness legacy atmospherics were doing - amblit = ambient_color * 0.5 * (1.0+sun_up_factor*0.3); + amblit = ambient_color; // * (1.0+sun_up_factor*0.3); amblit *= ambientLighting(norm, light_dir); amblit = srgb_to_linear(amblit); diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 23ba95949a..5a2924afe5 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -58,6 +58,7 @@ vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensi vec2 getScreenXY(vec4 clip); vec2 getScreenCoord(vec4 clip); vec3 srgb_to_linear(vec3 c); +vec3 legacy_adjust(vec3 c); // Util vec3 hue_to_rgb(float hue); @@ -131,6 +132,7 @@ void main() } else { + diffuse.rgb = legacy_adjust(diffuse.rgb); diffuse = srgb_to_linear(diffuse); spec.rgb = srgb_to_linear(spec.rgb); diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index 30b7895157..33e5b2346c 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -83,6 +83,7 @@ vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n); vec2 getScreenXY(vec4 clip); vec2 getScreenCoord(vec4 clip); vec3 srgb_to_linear(vec3 cs); +vec3 legacy_adjust(vec3 c); vec4 texture2DLodSpecular(vec2 tc, float lod); vec4 getPosition(vec2 pos_screen); @@ -182,7 +183,7 @@ void main() } else { - + diffuse = legacy_adjust(diffuse); diffuse = srgb_to_linear(diffuse); spec.rgb = srgb_to_linear(spec.rgb); diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl index 30b96ce8dc..471e5e7fd3 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl @@ -63,6 +63,7 @@ vec4 getPosition(vec2 pos_screen); vec2 getScreenXY(vec4 clip); vec2 getScreenCoord(vec4 clip); vec3 srgb_to_linear(vec3 c); +vec3 legacy_adjust(vec3 c); float getDepth(vec2 tc); vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, @@ -121,7 +122,7 @@ void main() { discard; } - + diffuse = legacy_adjust(diffuse); diffuse = srgb_to_linear(diffuse); spec.rgb = srgb_to_linear(spec.rgb); diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index e1206cc844..8f5bd6141a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -83,9 +83,12 @@ float getDepth(vec2 pos_screen); vec3 linear_to_srgb(vec3 c); vec3 srgb_to_linear(vec3 c); +vec3 legacy_adjust(vec3 c); uniform vec4 waterPlane; +uniform int cube_snapshot; + #ifdef WATER_FOG vec4 applyWaterFogViewLinear(vec3 pos, vec4 color); #endif @@ -207,12 +210,18 @@ void main() else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { //should only be true of WL sky, just port over base color value - color = srgb_to_linear(texture2D(emissiveRect, tc).rgb); - color *= sun_up_factor * sky_hdr_scale + 1.0; + color = texture2D(emissiveRect, tc).rgb; + color = srgb_to_linear(color); + if (sun_up_factor > 0) + { + color *= sky_hdr_scale + 1.0; + } } else { // legacy shaders are still writng sRGB to gbuffer + baseColor.rgb = legacy_adjust(baseColor.rgb); + baseColor.rgb = srgb_to_linear(baseColor.rgb); spec.rgb = srgb_to_linear(spec.rgb); diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 33ea2129cf..3d06bb27a5 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -91,6 +91,7 @@ vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n); vec2 getScreenXY(vec4 clip_point); vec2 getScreenCoord(vec4 clip_point); vec3 srgb_to_linear(vec3 c); +vec3 legacy_adjust(vec3 c); vec4 texture2DLodSpecular(vec2 tc, float lod); vec4 getPosition(vec2 pos_screen); @@ -189,6 +190,7 @@ void main() } else { + diffuse = legacy_adjust(diffuse); diffuse = srgb_to_linear(diffuse); spec.rgb = srgb_to_linear(spec.rgb); -- cgit v1.2.3