summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
authorRunitai Linden <davep@lindenlab.com>2020-03-27 17:32:01 -0500
committerRunitai Linden <davep@lindenlab.com>2020-03-27 17:32:01 -0500
commite468d8018634b51f329eae17485c3358c0a3630b (patch)
treedc12e082a97f56f422cfdd0655cb64975b986924 /indra/llprimitive
parentd756e185730f46fd78e88215e0b4b9fd282fd1d7 (diff)
SL-12902 Better fix for light color values in color swatch not matching light color values inworld.
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/llprimitive.cpp6
-rw-r--r--indra/llprimitive/llprimitive.h25
2 files changed, 16 insertions, 15 deletions
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index bc5dd62f45..53b83a40d7 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -1659,7 +1659,7 @@ BOOL LLLightParams::unpack(LLDataPacker &dp)
{
LLColor4U color;
dp.unpackColor4U(color, "color");
- setColor(LLColor4(color));
+ setLinearColor(LLColor4(color));
F32 radius;
dp.unpackF32(radius, "radius");
@@ -1707,7 +1707,7 @@ LLSD LLLightParams::asLLSD() const
{
LLSD sd;
- sd["color"] = ll_sd_from_color4(getColor());
+ sd["color"] = ll_sd_from_color4(getLinearColor());
sd["radius"] = getRadius();
sd["falloff"] = getFalloff();
sd["cutoff"] = getCutoff();
@@ -1721,7 +1721,7 @@ bool LLLightParams::fromLLSD(LLSD& sd)
w = "color";
if (sd.has(w))
{
- setColor( ll_color4_from_sd(sd["color"]) );
+ setLinearColor( ll_color4_from_sd(sd["color"]) );
} else goto fail;
w = "radius";
if (sd.has(w))
diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index ed89462e5a..b1f8112223 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -131,8 +131,8 @@ extern const F32 LIGHT_MAX_CUTOFF;
class LLLightParams : public LLNetworkData
{
-protected:
- LLColor4 mColor; // gamma corrected color (sRGB), alpha = intensity
+private:
+ LLColor4 mColor; // linear color (not gamma corrected), alpha = intensity
F32 mRadius;
F32 mFalloff;
F32 mCutoff;
@@ -149,21 +149,22 @@ public:
operator LLSD() const { return asLLSD(); }
bool fromLLSD(LLSD& sd);
-
- // set the color
+ // set the color by gamma corrected color value
// color - gamma corrected color value (directly taken from an on-screen color swatch)
- void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); }
+ void setSRGBColor(const LLColor4& color) { setLinearColor(linearColor4(color)); }
+
+ // set the color by linear color value
+ // color - linear color value (value as it appears in shaders)
+ void setLinearColor(const LLColor4& color) { mColor = color; mColor.clamp(); }
void setRadius(F32 radius) { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); }
void setFalloff(F32 falloff) { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); }
void setCutoff(F32 cutoff) { mCutoff = llclamp(cutoff, LIGHT_MIN_CUTOFF, LIGHT_MAX_CUTOFF); }
- // same as getSRGBColor
- LLColor4 getColor() const { return mColor; }
- // get the sRGB (gamma corrected) color of this light
- LLColor4 getSRGBColor() const { return mColor; }
- // get the linear space color of this light
- LLColor4 getLinearColor() const { return linearColor4(mColor); }
-
+ // get the linear space color of this light. This value can be fed directly to shaders
+ LLColor4 getLinearColor() const { return mColor; }
+ // get the sRGB (gamma corrected) color of this light, this is the value that should be displayed in the UI
+ LLColor4 getSRGBColor() const { return srgbColor4(mColor); }
+
F32 getRadius() const { return mRadius; }
F32 getFalloff() const { return mFalloff; }
F32 getCutoff() const { return mCutoff; }