From 57d88a8a98ef8663b9064b12143beb4068e58f86 Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 29 Mar 2019 08:11:56 -0700 Subject: 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. --- indra/llprimitive/llprimitive.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive/llprimitive.h') diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index c138c2ac2b..677606abd1 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -133,6 +133,7 @@ class LLLightParams : public LLNetworkData { protected: LLColor4 mColor; // alpha = intensity + LLColor4 msRGBColor; // Only used in deferred (for now?) F32 mRadius; F32 mFalloff; F32 mCutoff; @@ -150,12 +151,13 @@ public: bool fromLLSD(LLSD& sd); - void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); } + void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); msRGBColor = srgbColor4(mColor); } 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); } LLColor4 getColor() const { return mColor; } + LLColor4 getsRGBColor() const { return msRGBColor; } F32 getRadius() const { return mRadius; } F32 getFalloff() const { return mFalloff; } F32 getCutoff() const { return mCutoff; } -- cgit v1.2.3 From 0272c47e5a31cf972e02fbf14cb2642f86f75d78 Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 29 Mar 2019 11:57:45 -0700 Subject: Tweaked naming a bit, also white space. Will wait for a response from @graham_linden regarding moving the sRGB conversion functions in llmath.h to llrender. --- indra/llprimitive/llprimitive.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llprimitive/llprimitive.h') diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 677606abd1..619a9f8ca5 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -133,7 +133,7 @@ class LLLightParams : public LLNetworkData { protected: LLColor4 mColor; // alpha = intensity - LLColor4 msRGBColor; // Only used in deferred (for now?) + LLColor4 mSRGBColor; // Only used in deferred (for now?) F32 mRadius; F32 mFalloff; F32 mCutoff; @@ -150,14 +150,14 @@ public: operator LLSD() const { return asLLSD(); } bool fromLLSD(LLSD& sd); - - void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); msRGBColor = srgbColor4(mColor); } + + void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); mSRGBColor = srgbColor4(mColor); } 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); } - LLColor4 getColor() const { return mColor; } - LLColor4 getsRGBColor() const { return msRGBColor; } + LLColor4 getColor() const { return mColor; } + LLColor4 getSRGBColor() const { return mSRGBColor; } F32 getRadius() const { return mRadius; } F32 getFalloff() const { return mFalloff; } F32 getCutoff() const { return mCutoff; } -- cgit v1.2.3 From d756e185730f46fd78e88215e0b4b9fd282fd1d7 Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Thu, 26 Mar 2020 16:48:33 -0500 Subject: SL-12902 Fix for doing the technically correct but compatibility wrong thing WRT light color values. --- indra/llprimitive/llprimitive.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive/llprimitive.h') diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 20b5ad8eff..ed89462e5a 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -132,8 +132,7 @@ extern const F32 LIGHT_MAX_CUTOFF; class LLLightParams : public LLNetworkData { protected: - LLColor4 mColor; // alpha = intensity - LLColor4 mSRGBColor; // Only used in deferred (for now?) + LLColor4 mColor; // gamma corrected color (sRGB), alpha = intensity F32 mRadius; F32 mFalloff; F32 mCutoff; @@ -151,13 +150,20 @@ public: bool fromLLSD(LLSD& sd); - void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); mSRGBColor = srgbColor4(mColor); } + // set the color + // color - gamma corrected color value (directly taken from an on-screen color swatch) + void setColor(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; } - LLColor4 getSRGBColor() const { return mSRGBColor; } + // 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); } + F32 getRadius() const { return mRadius; } F32 getFalloff() const { return mFalloff; } F32 getCutoff() const { return mCutoff; } -- cgit v1.2.3 From e468d8018634b51f329eae17485c3358c0a3630b Mon Sep 17 00:00:00 2001 From: Runitai Linden Date: Fri, 27 Mar 2020 17:32:01 -0500 Subject: SL-12902 Better fix for light color values in color swatch not matching light color values inworld. --- indra/llprimitive/llprimitive.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'indra/llprimitive/llprimitive.h') 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; } -- cgit v1.2.3