From 03bd681564f0b0a630f6330ab9c61daa4856e5fe Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 14 Apr 2023 19:24:21 -0500 Subject: DRTVWR-559 Balance night scenes against release, nudge glow down a smidge, remove exposure correction from legacy fullbright balance PBR materials against legacy. --- .../shaders/class1/deferred/deferredUtil.glsl | 4 +-- .../shaders/class1/deferred/emissiveF.glsl | 9 ++--- .../shaders/class1/deferred/fullbrightF.glsl | 3 +- .../app_settings/shaders/class1/deferred/skyV.glsl | 2 +- .../shaders/class1/environment/srgbF.glsl | 39 +++++++++++++++++++--- 5 files changed, 42 insertions(+), 15 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1') diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index aa61e10c7f..8797f89e4c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -387,7 +387,7 @@ vec3 pbrIbl(vec3 diffuseColor, { // retrieve a scale and bias to F0. See [1], Figure 3 vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0-perceptualRough); - vec3 diffuseLight = irradiance; + vec3 diffuseLight = irradiance*1.25; //magic 1.25 to balance with legacy materials vec3 specularLight = radiance; vec3 diffuse = diffuseLight * diffuseColor; @@ -563,7 +563,7 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, vec3 ibl_spec; color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness, ibl_spec); - color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), specContrib) * sunlit * 2.75 * scol; + color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), specContrib) * sunlit * 3.9 * scol; //magic number to balance with legacy materials specContrib *= sunlit * 2.75 * scol; specContrib += ibl_spec; diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl index 17e24a2bf2..3c51a8e44c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl @@ -36,11 +36,8 @@ VARYING vec2 vary_texcoord0; void main() { - float shadow = 1.0; - - vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color; - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = max(color, vec4(0)); + // NOTE: when this shader is used, only alpha is being written to + float a = diffuseLookup(vary_texcoord0.xy).a*vertex_color.a; + frag_color = vec4(0, 0, 0, a); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 11532135dd..5515d8e2a3 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_fullbright(vec3 c); vec3 legacy_adjust(vec3 c); vec3 linear_to_srgb(vec3 cl); vec3 fullbrightAtmosTransport(vec3 light); @@ -90,8 +91,8 @@ void main() #ifndef IS_HUD color.rgb = legacy_adjust(color.rgb); color.rgb = srgb_to_linear(color.rgb); + color.rgb = legacy_adjust_fullbright(color.rgb); color.rgb = fullbrightAtmosTransport(color.rgb); - #endif frag_color = max(color, vec4(0)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 62d134188c..4fa9ae3633 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 : moonlight_color; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color * 0.7; //magic 0.7 to match legacy color // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl index 3cca84ca14..35f2395ef1 100644 --- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl @@ -23,6 +23,8 @@ * $/LicenseInfo$ */ + uniform sampler2D exposureMap; + vec3 srgb_to_linear(vec3 cs) { vec3 low_range = cs / vec3(12.92); @@ -83,12 +85,32 @@ vec3 hsv2rgb(vec3 c) return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } -vec3 legacy_adjust_no_brighten(vec3 c) +const mat3 inv_ACESOutputMat = mat3(0.643038, 0.0592687, 0.0059619, 0.311187, 0.931436, 0.063929, 0.0457755, 0.00929492, 0.930118 ); + +const mat3 inv_ACESInputMat = mat3( 1.76474, -0.147028, -0.0363368, -0.675778, 1.16025, -0.162436, -0.0889633, -0.0132237, 1.19877 ); + +vec3 inv_RRTAndODTFit(vec3 x) { - vec3 desat = rgb2hsv(c.rgb); - desat.g *= 0.75; - desat.rgb = hsv2rgb(desat); - return desat; + float A = 0.0245786; + float B = 0.000090537; + float C = 0.983729; + float D = 0.4329510; + float E = 0.238081; + + return (A - D * x)/(2.0 * (C * x - 1.0)) - sqrt(pow(D * x - A, vec3(2.0)) - 4.0 * (C * x - 1.0) * (B + E * x))/(2.0 * (C * x - 1.0)); +} + +// experimental inverse of ACES Hill tonemapping +vec3 inv_toneMapACES_Hill(vec3 color) +{ + color = inv_ACESOutputMat * color; + + // Apply RRT and ODT + color = inv_RRTAndODTFit(color); + + color = inv_ACESInputMat * color; + + return color; } vec3 legacy_adjust(vec3 c) @@ -100,6 +122,13 @@ vec3 legacy_adjust(vec3 c) return desat; } +vec3 legacy_adjust_fullbright(vec3 c) +{ + float exp_scale = texture(exposureMap, vec2(0.5, 0.5)).r; + return c / exp_scale * 1.34; +} + + vec3 legacy_adjust_post(vec3 c) { return c; -- cgit v1.2.3