diff options
author | Dave Parks <davep@lindenlab.com> | 2022-10-10 10:19:36 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-10-10 10:19:36 -0500 |
commit | 0fed3884c21453eac23a4de714bc87cac9e5377e (patch) | |
tree | 81c8f153832f4f637b15a334d180761bce9d50fd /indra/newview/app_settings/shaders/class3 | |
parent | ace892b8f5b12f4c85aec70caa032a13f8d0fd2c (diff) |
SL-18190 Use funky distance based error correction only on water surface (revisit for general use later).
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 46 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class3/environment/waterF.glsl | 4 |
2 files changed, 31 insertions, 19 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index ec9218f00e..925398671c 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -374,7 +374,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, vec3 c, float r2, int i) } } -vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) +vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) { float wsum = 0.0; vec3 col = vec3(0,0,0); @@ -399,12 +399,15 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) { vec3 vi, wi; - vec3 refcol = tapRefMap(pos, dir, vi, wi, lod, refSphere[i].xyz, rr, i); + float atten = 1.0 - max(d2 - r2, 0.0) / (rr - r2); + float w; + vec3 refcol; - float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); + if (errorCorrect && refIndex[i].w >= 0) + { // error correction is on and this probe is a sphere + //take a sample to get depth value, then error correct + refcol = tapRefMap(pos, dir, vi, wi, abs(lod + 2), refSphere[i].xyz, rr, i); - if (refIndex[i].w >= 0) - { //adjust lookup by distance result float d = length(vi - wi); vi += dir * d; @@ -414,16 +417,20 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) vi = env_mat * vi; refcol = textureLod(reflectionProbes, vec4(vi, refIndex[i].x), lod).rgb; + + // weight by vector correctness + vec3 pi = normalize(wi - pos); + w = max(dot(pi, dir), 0.1); + w = pow(w, 32.0); + } + else + { + w = 1.0 / d2; + refcol = tapRefMap(pos, dir, vi, wi, lod, refSphere[i].xyz, rr, i); } - //float w = 1.0 / max(d3, 1.0); - vec3 pi = normalize(wi - pos); - float w = max(dot(pi, dir), 0.1); - w = pow(w, 32.0); - w *= atten; - //w *= p; // boost weight based on priority col += refcol.rgb*w; @@ -431,7 +438,6 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) } } -#if 1 if (probeInfluences < 1) { //edge-of-scene probe or no probe influence, mix in with embiggened version of probes closest to camera for (int idx = 0; idx < 8; ++idx) @@ -455,7 +461,6 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) } } } -#endif if (wsum > 0.0) { @@ -537,7 +542,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir) } void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec3 pos, vec3 norm, float glossiness) + vec3 pos, vec3 norm, float glossiness, bool errorCorrect) { // TODO - don't hard code lods float reflection_lods = 7; @@ -548,7 +553,14 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, ambenv = sampleProbeAmbient(pos, norm); float lod = (1.0-glossiness)*reflection_lods; - glossenv = sampleProbes(pos, normalize(refnormpersp), lod, 1.f); + glossenv = sampleProbes(pos, normalize(refnormpersp), lod, errorCorrect); +} + +void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, + vec3 pos, vec3 norm, float glossiness) +{ + sampleReflectionProbes(ambenv, glossenv, + pos, norm, glossiness, false); } void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, @@ -565,12 +577,12 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout if (glossiness > 0.0) { float lod = (1.0-glossiness)*reflection_lods; - glossenv = sampleProbes(pos, normalize(refnormpersp), lod, 1.f); + glossenv = sampleProbes(pos, normalize(refnormpersp), lod, false); } if (envIntensity > 0.0) { - legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0, 1.f); + legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0, false); } } diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index 4c361884a5..9793a0e786 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -103,7 +103,7 @@ vec3 transform_normal(vec3 vNt) } void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec3 pos, vec3 norm, float glossiness); + vec3 pos, vec3 norm, float glossiness, bool errorCorrect); vec3 getPositionWithNDC(vec3 ndc); @@ -215,7 +215,7 @@ void main() vec3 irradiance = vec3(0); vec3 radiance = vec3(0); - sampleReflectionProbes(irradiance, radiance, pos, refnorm, gloss); + sampleReflectionProbes(irradiance, radiance, pos, refnorm, gloss, true); radiance *= 0.5; irradiance = fb.rgb; |