From 46e04fe273ce88c52c08a6417a01ec89bd4e89e9 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 23 May 2023 16:11:43 -0500 Subject: DRTVWR-559 Remove RenderReflectionProbeCount (which is bugged) and lean on RenderReflectionProbeLevel for preferences (which works). --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 2f3efaa94a..3945e34d7a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -25,9 +25,6 @@ #define FLT_MAX 3.402823466e+38 -#define REFMAP_COUNT 256 -#define REF_SAMPLE_COUNT 64 //maximum number of samples to consider - out vec4 frag_color; uniform sampler2D diffuseRect; -- cgit v1.2.3 From c12712aa9609325ba3247a67354e91e9342106d6 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 25 May 2023 13:09:03 -0500 Subject: DRTVWR-559 Fix for off-color fullbright alpha blinn-phong materials. Scrub some NaNs. --- indra/newview/app_settings/shaders/class3/deferred/materialF.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred') diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 77e3b92385..ba19fe0f19 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -49,6 +49,7 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cs); vec3 legacy_adjust(vec3 c); +vec3 legacy_adjust_fullbright(vec3 c); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) @@ -396,7 +397,7 @@ void main() } #endif - color = mix(color.rgb, diffcol.rgb, emissive); + color = mix(color.rgb, legacy_adjust_fullbright(diffcol.rgb), emissive); if (env > 0.0) { // add environmentmap -- cgit v1.2.3 From cbd17fce86cc30434d6d665338a7d771bddcad8b Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 25 May 2023 16:09:22 -0400 Subject: Fix underwater fog mismatch between opaque and alpha blend when local lights are nearby (#227) * Fix water fog mismatch between alpha blend and opaque when local light is nearby * Add PBR underwater alpha blend shader --- .../app_settings/shaders/class3/deferred/materialF.glsl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred') diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index ba19fe0f19..5fb5647d35 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -38,7 +38,7 @@ uniform float emissive_brightness; // fullbright flag, 1.0 == fullbright, 0.0 o uniform int sun_up_factor; #ifdef WATER_FOG -vec4 applyWaterFogView(vec3 pos, vec4 color); +vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit); #endif vec3 atmosFragLightingLinear(vec3 l, vec3 additive, vec3 atten); @@ -411,6 +411,11 @@ void main() color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); +#ifdef WATER_FOG + vec4 temp = applyWaterFogViewLinear(pos, vec4(color, 0.0), sunlit_linear); + color = temp.rgb; +#endif + vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0, 0, 0); @@ -431,11 +436,6 @@ void main() glare = min(glare, 1.0); float al = max(diffcol.a, glare) * vertex_color.a; -#ifdef WATER_FOG - vec4 temp = applyWaterFogView(pos, vec4(color, 0.0)); - color = temp.rgb; -#endif - frag_color = max(vec4(color, al), vec4(0)); #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer -- cgit v1.2.3 From 50ec54831de88926ca13c9a72d89006ceda6c355 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 1 Jun 2023 19:49:23 -0500 Subject: DRTVWR-559 Revert skies to be very close to release and disable tone mapping when probe ambiance is zero. Hack for desaturating legacy materials has been removed for performance and quality reasons. Adds a new setting for auto adjusting legacy skies. This is the PBR "opt out" button. If disabled, legacy skies will disable tonemapping, automatic probe ambiance, and HDR/exposure. If enabled, legacy skies will behave as if probe ambiance and HDR scale are 1.0, and ambient will be cut in half. HDR scale will act as a sky brightener, but will automatically adjust dynamic exposure so the sky will be properly exposed. If you want relatively even exposure all the time, set HDR Scale to 1.0. If you want a high range of exposures between indoor/dark areas and outdoor/bright areas, increase HDR Scale. Also tuned up SSAO (thanks Rye!). Reviewed with Brad. --- .../shaders/class3/deferred/fullbrightShinyF.glsl | 4 +-- .../shaders/class3/deferred/softenLightF.glsl | 36 ++++++++++++++-------- 2 files changed, 25 insertions(+), 15 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred') diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index 1c79748b49..0d77e88831 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -42,7 +42,7 @@ uniform samplerCube environmentMap; vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 legacy_adjust_fullbright(vec3 c); vec3 legacy_adjust(vec3 c); -void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); vec3 linear_to_srgb(vec3 c); vec3 srgb_to_linear(vec3 c); @@ -71,7 +71,7 @@ void main() vec3 additive; vec3 atten; vec3 pos = vary_position; - calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten); float env_intensity = vertex_color.a; diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 3945e34d7a..53c5b1b801 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -44,9 +44,14 @@ uniform sampler2D lightFunc; uniform float blur_size; uniform float blur_fidelity; +#if defined(HAS_SSAO) +uniform float ssao_irradiance_scale; +uniform float ssao_irradiance_max; +#endif + // Inputs uniform mat3 env_mat; - +uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; uniform int sun_up_factor; @@ -112,6 +117,16 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, vec3 l); //surface point to light +void adjustIrradiance(inout vec3 irradiance, vec3 amblit_linear, float ambocc) +{ + // use sky settings ambient or irradiance map sample, whichever is brighter + irradiance = max(amblit_linear, irradiance); + +#if defined(HAS_SSAO) + irradiance = mix(ssao_effect_mat * min(irradiance.rgb*ssao_irradiance_scale, vec3(ssao_irradiance_max)), irradiance.rgb, ambocc); +#endif +} + void main() { vec2 tc = vary_fragcoord.xy; @@ -173,7 +188,7 @@ void main() vec3 orm = texture(specularRect, tc).rgb; float perceptualRoughness = orm.g; float metallic = orm.b; - float ao = orm.r * ambocc; + float ao = orm.r; vec3 colorEmissive = texture(emissiveRect, tc).rgb; // PBR IBL @@ -181,9 +196,7 @@ void main() sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss); - // Take maximium of legacy ambient vs irradiance sample as irradiance - // NOTE: ao is applied in pbrIbl (see pbrBaseLight), do not apply here - irradiance = max(amblit_linear,irradiance); + adjustIrradiance(irradiance, amblit_linear, ambocc); vec3 diffuseColor; vec3 specularColor; @@ -203,17 +216,15 @@ void main() //should only be true of WL sky, just port over base color value color = texture(emissiveRect, tc).rgb; color = srgb_to_linear(color); - if (sun_up_factor > 0) - { - color *= sky_hdr_scale + 1.0; - } + color *= sky_hdr_scale; } 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); float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); @@ -224,11 +235,10 @@ void main() sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity); - // use sky settings ambient or irradiance map sample, whichever is brighter - irradiance = max(amblit_linear, irradiance); + adjustIrradiance(irradiance, amblit_linear, ambocc); // apply lambertian IBL only (see pbrIbl) - color.rgb = irradiance * ambocc; + color.rgb = irradiance; vec3 sun_contrib = min(da, scol) * sunlit_linear; color.rgb += sun_contrib; -- cgit v1.2.3 From b0540f8189d28da66c143c5de961deaba7a86f17 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 1 Jun 2023 20:15:35 -0500 Subject: DRTVWR-559 Rebalance PBR against Blinn-Phong. --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 53c5b1b801..409b46218b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -203,7 +203,6 @@ void main() calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor); vec3 v = -normalize(pos.xyz); - color = vec3(1,0,1); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); if (do_atmospherics) -- cgit v1.2.3