diff options
author | RunitaiLinden <davep@lindenlab.com> | 2023-09-06 10:31:03 -0500 |
---|---|---|
committer | RunitaiLinden <davep@lindenlab.com> | 2023-09-06 10:31:03 -0500 |
commit | 43cd4e84bc01abcf2820b9557abe761fbf5e8432 (patch) | |
tree | 1306bd620a37f951611a8c36837788e267065ec8 /indra/newview/app_settings/shaders | |
parent | 75a0719ff59118c0a5c6713e952cab4d0640a7d5 (diff) |
SL-19842 WIP -- Change how probe ambiance mixes with sky ambient.
Diffstat (limited to 'indra/newview/app_settings/shaders')
9 files changed, 44 insertions, 44 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 53e4f02314..64e6bc9da2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -105,7 +105,8 @@ vec3 toneMap(vec3 color) color *= exposure * exp_scale; - color = toneMapACES_Hill(color); + // mix ACES and Linear here as a compromise to avoid over-darkening legacy content + color = mix(toneMapACES_Hill(color), color, 0.333); #endif return color; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index da5f997429..3a251af240 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -85,7 +85,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); float getAmbientClamp(); void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent); + vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { @@ -251,7 +251,7 @@ void main() vec3 irradiance; vec3 glossenv; vec3 legacyenv; - sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, frag, pos.xyz, norm.xyz, 0.0, 0.0, true); + sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, frag, pos.xyz, norm.xyz, 0.0, 0.0, true, amblit_linear); float da = dot(norm.xyz, light_dir.xyz); @@ -266,7 +266,7 @@ void main() vec3 sun_contrib = min(final_da, shadow) * sunlit_linear; - color.rgb = max(amblit, irradiance); + color.rgb = irradiance; color.rgb += sun_contrib; diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index e8db856b1f..be66b6feb2 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -92,7 +92,7 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float float calcLegacyDistanceAttenuation(float distance, float falloff); float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent); + vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit_linear); void waterClip(vec3 pos); @@ -224,11 +224,8 @@ void main() float gloss = 1.0 - perceptualRoughness; vec3 irradiance = vec3(0); vec3 radiance = vec3(0); - sampleReflectionProbes(irradiance, radiance, vary_position.xy*0.5+0.5, pos.xyz, norm.xyz, gloss, true); - // 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,irradiance); - + sampleReflectionProbes(irradiance, radiance, vary_position.xy*0.5+0.5, pos.xyz, norm.xyz, gloss, true, amblit); + vec3 diffuseColor; vec3 specularColor; calcDiffuseSpecular(col.rgb, metallic, diffuseColor, specularColor); diff --git a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl index aa6f5a3b62..52e71edcac 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl @@ -34,7 +34,7 @@ uniform mat3 env_mat; vec3 srgb_to_linear(vec3 c); void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent) + vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit_linear) { ambenv = vec3(reflection_probe_ambiance * 0.25); @@ -44,9 +44,9 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, } void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness) + vec2 tc, vec3 pos, vec3 norm, float glossiness, vec3 amblit_linear) { - sampleReflectionProbes(ambenv, glossenv, tc, pos, norm, glossiness, false); + sampleReflectionProbes(ambenv, glossenv, tc, pos, norm, glossiness, false, amblit_linear); } vec4 sampleReflectionProbesDebug(vec3 pos) @@ -56,7 +56,7 @@ vec4 sampleReflectionProbesDebug(vec3 pos) } void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent) + vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear) { ambenv = vec3(reflection_probe_ambiance * 0.25); diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index 1537714bb7..54a887262b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -49,7 +49,7 @@ vec3 srgb_to_linear(vec3 c); // reflection probe interface void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent); + vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear); void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity); @@ -80,7 +80,7 @@ void main() vec3 legacyenv; vec3 norm = normalize(vary_texcoord1.xyz); vec4 spec = vec4(0,0,0,0); - sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, vec2(0), pos.xyz, norm.xyz, spec.a, env_intensity, false); + sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, vec2(0), pos.xyz, norm.xyz, spec.a, env_intensity, false, amblit); color.rgb = legacy_adjust(color.rgb); color.rgb = srgb_to_linear(color.rgb); diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 82e2de0c0f..319f2f25b7 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -60,7 +60,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); #endif void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent); + vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear); void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm); void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity); @@ -339,10 +339,9 @@ void main() vec3 ambenv; vec3 glossenv; vec3 legacyenv; - sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xy*0.5+0.5, pos.xyz, norm.xyz, glossiness, env, true); + sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xy*0.5+0.5, pos.xyz, norm.xyz, glossiness, env, true, amblit_linear); - // use sky settings ambient or irradiance map sample, whichever is brighter - color = max(amblit_linear, ambenv); + color = ambenv; float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); vec3 sun_contrib = min(da, shadow) * sunlit_linear; diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 41821def8e..906e66ecc8 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -530,7 +530,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c, // w - weight of sample (distance and angular attenuation) // dw - weight of sample (distance only) // i - index of probe -vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int i) +vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int i, vec3 amblit) { // parallax adjustment vec3 v; @@ -556,9 +556,12 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int v -= c; v = env_mat * v; - { - return textureLod(irradianceProbes, vec4(v.xyz, refIndex[i].x), 0).rgb * refParams[i].x; - } + + vec3 col = textureLod(irradianceProbes, vec4(v.xyz, refIndex[i].x), 0).rgb * refParams[i].x; + + col = mix(amblit, col, min(refParams[i].x, 1.0)); + + return col; } vec3 sampleProbes(vec3 pos, vec3 dir, float lod) @@ -619,7 +622,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) return col[1]+col[0]; } -vec3 sampleProbeAmbient(vec3 pos, vec3 dir) +vec3 sampleProbeAmbient(vec3 pos, vec3 dir, vec3 amblit) { // modified copy/paste of sampleProbes follows, will likely diverge from sampleProbes further // as irradiance map mixing is tuned independently of radiance map mixing @@ -649,7 +652,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir) float w = 0; float dw = 0; - vec3 refcol = tapIrradianceMap(pos, dir, w, dw, refSphere[i].xyz, i); + vec3 refcol = tapIrradianceMap(pos, dir, w, dw, refSphere[i].xyz, i, amblit); col[p] += refcol*w; wsum[p] += w; @@ -679,14 +682,14 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir) } void doProbeSample(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent) + vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit) { // TODO - don't hard code lods float reflection_lods = max_probe_lod; vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - ambenv = sampleProbeAmbient(pos, norm); + ambenv = sampleProbeAmbient(pos, norm, amblit); float lod = (1.0-glossiness)*reflection_lods; glossenv = sampleProbes(pos, normalize(refnormpersp), lod); @@ -712,14 +715,14 @@ void doProbeSample(inout vec3 ambenv, inout vec3 glossenv, } void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent) + vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit) { preProbeSample(pos); - doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness, transparent); + doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness, transparent, amblit); } void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness) + vec2 tc, vec3 pos, vec3 norm, float glossiness, vec3 amblit) { // don't sample automatic probes for water sample_automatic = false; @@ -728,7 +731,7 @@ void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, // always include void probe on water probeIndex[probeInfluences++] = 0; - doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness, false); + doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness, false, amblit); // fudge factor to get PBR water at a similar luminance ot legacy water glossenv *= 0.4; @@ -783,14 +786,14 @@ vec4 sampleReflectionProbesDebug(vec3 pos) } void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent) + vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit) { float reflection_lods = max_probe_lod; preProbeSample(pos); vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - ambenv = sampleProbeAmbient(pos, norm); + ambenv = sampleProbeAmbient(pos, norm, amblit); if (glossiness > 0.0) { diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 4ef003e0cb..8b0ea23897 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -69,9 +69,9 @@ vec3 scaleSoftClipFragLinear(vec3 l); // reflection probe interface void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent); + vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit_linear); void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent); + vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear); void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm); void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity); float getDepth(vec2 pos_screen); @@ -117,10 +117,10 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, vec3 l); //surface point to light -void adjustIrradiance(inout vec3 irradiance, vec3 amblit_linear, float ambocc) +void adjustIrradiance(inout vec3 irradiance, float ambocc) { // use sky settings ambient or irradiance map sample, whichever is brighter - irradiance = max(amblit_linear, irradiance); + //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); @@ -194,9 +194,9 @@ void main() // PBR IBL float gloss = 1.0 - perceptualRoughness; - sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false); + sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear); - adjustIrradiance(irradiance, amblit_linear, ambocc); + adjustIrradiance(irradiance, ambocc); vec3 diffuseColor; vec3 specularColor; @@ -232,9 +232,9 @@ void main() vec3 glossenv = vec3(0); vec3 legacyenv = vec3(0); - sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false); + sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear); - adjustIrradiance(irradiance, amblit_linear, ambocc); + adjustIrradiance(irradiance, ambocc); // apply lambertian IBL only (see pbrIbl) color.rgb = irradiance; diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index 8fee259933..4f79dd1ac5 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -124,7 +124,7 @@ vec3 transform_normal(vec3 vNt) } void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness); + vec2 tc, vec3 pos, vec3 norm, float glossiness, vec3 amblit_linear); vec3 getPositionWithNDC(vec3 ndc); @@ -237,7 +237,7 @@ void main() vec3 irradiance = vec3(0); vec3 radiance = vec3(0); - sampleReflectionProbesWater(irradiance, radiance, distort2, pos.xyz, wave_ibl.xyz, gloss); + sampleReflectionProbesWater(irradiance, radiance, distort2, pos.xyz, wave_ibl.xyz, gloss, amblit); irradiance = vec3(0); |