diff options
author | Geenz <geenz@geenzo.com> | 2019-03-29 08:11:56 -0700 |
---|---|---|
committer | Geenz <geenz@geenzo.com> | 2019-03-29 08:11:56 -0700 |
commit | 57d88a8a98ef8663b9064b12143beb4068e58f86 (patch) | |
tree | 8b37cf56aa5e6d0882caee2bcd79b22c90f5350b /indra/llmath | |
parent | 3fa8b844c39311a2e4e319a8d4f7ab2c848ae140 (diff) |
Gamma correction pass 2:
Make sure lights are in the correct color space.
Bonus: cache the sRGB color in setLightColor on point and spot lights. Frees up a pow and some multiplies on the CPU every frame.
Diffstat (limited to 'indra/llmath')
-rw-r--r-- | indra/llmath/v3color.h | 8 | ||||
-rw-r--r-- | indra/llmath/v4color.h | 11 | ||||
-rw-r--r-- | indra/llmath/v4math.h | 12 |
3 files changed, 31 insertions, 0 deletions
diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index 43910a1bbe..ac78197510 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -475,5 +475,13 @@ inline LLColor3 lerp(const LLColor3 &a, const LLColor3 &b, F32 u) a.mV[VZ] + (b.mV[VZ] - a.mV[VZ]) * u); } +inline const LLColor3 srgbColor3(const LLColor3 &a) { + LLColor3 srgbColor; + srgbColor.mV[0] = linearTosRGB(a.mV[0]); + srgbColor.mV[1] = linearTosRGB(a.mV[1]); + srgbColor.mV[2] = linearTosRGB(a.mV[2]); + + return srgbColor; +} #endif diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index 614cdc9f3e..d9dd28ec54 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -656,5 +656,16 @@ void LLColor4::clamp() } } +inline const LLColor4 srgbColor4(const LLColor4 &a) { + LLColor4 srgbColor; + + srgbColor.mV[0] = linearTosRGB(a.mV[0]); + srgbColor.mV[1] = linearTosRGB(a.mV[1]); + srgbColor.mV[2] = linearTosRGB(a.mV[2]); + srgbColor.mV[3] = a.mV[3]; + + return srgbColor; +} + #endif diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h index 3f6d480ed9..00baeefa5c 100644 --- a/indra/llmath/v4math.h +++ b/indra/llmath/v4math.h @@ -534,6 +534,18 @@ inline F32 LLVector4::normVec(void) return (mag); } +// Because apparently some parts of the viewer use this for color info. +inline const LLVector4 srgbVector4(const LLVector4 &a) { + LLVector4 srgbColor; + + srgbColor.mV[0] = linearTosRGB(a.mV[0]); + srgbColor.mV[1] = linearTosRGB(a.mV[1]); + srgbColor.mV[2] = linearTosRGB(a.mV[2]); + srgbColor.mV[3] = a.mV[3]; + + return srgbColor; +} + #endif |