summaryrefslogtreecommitdiff
path: root/indra/llinventory/llsettingswater.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2023-06-01 09:57:57 -0400
committerNat Goodspeed <nat@lindenlab.com>2023-06-01 09:57:57 -0400
commitd844da2a6c5fc1a75e606150bb070fdb787698d3 (patch)
tree349ecda36a5a561d6e564e2cc3db39121fd8946b /indra/llinventory/llsettingswater.cpp
parent8a74efa38ba631be5400c4912a6339310968c9d7 (diff)
parent7d05ade3f10563e8c202106e00cb3d273ab13338 (diff)
SL-18330: Merge branch 'xcode-14.3' into fix-monterey
to pick up new merge from main.
Diffstat (limited to 'indra/llinventory/llsettingswater.cpp')
-rw-r--r--indra/llinventory/llsettingswater.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp
index f19beb5be5..d732032a6c 100644
--- a/indra/llinventory/llsettingswater.cpp
+++ b/indra/llinventory/llsettingswater.cpp
@@ -286,6 +286,19 @@ F32 LLSettingsWater::getModifiedWaterFogDensity(bool underwater) const
if (underwater && underwater_fog_mod > 0.0f)
{
underwater_fog_mod = llclamp(underwater_fog_mod, 0.0f, 10.0f);
+ // BUG-233797/BUG-233798 -ve underwater fog density can cause (unrecoverable) blackout.
+ // raising a negative number to a non-integral power results in a non-real result (which is NaN for our purposes)
+ // Two methods were tested, number 2 is being used:
+ // 1) Force the fog_mod to be integral. The effect is unlikely to be nice, but it is better than blackness.
+ // In this method a few of the combinations are "usable" but the water colour is effectively inverted (blue becomes yellow)
+ // this seems to be unlikely to be a desirable use case for the majority.
+ // 2) Force density to be an arbitrary non-negative (i.e. 1) when underwater and modifier is not an integer (1 was aribtrarily chosen as it gives at least some notion of fog in the transition)
+ // This is more restrictive, effectively forcing a density under certain conditions, but allowing the range of #1 and avoiding blackness in other cases
+ // at the cost of overriding the fog density.
+ if(fog_density < 0.0f && underwater_fog_mod != (F32)llround(underwater_fog_mod) )
+ {
+ fog_density = 1.0f;
+ }
fog_density = pow(fog_density, underwater_fog_mod);
}
return fog_density;