diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llprimitive/llprimitive.cpp | 6 | ||||
| -rw-r--r-- | indra/llprimitive/llprimitive.h | 25 | ||||
| -rw-r--r-- | indra/newview/llpanelvolume.cpp | 8 | ||||
| -rw-r--r-- | indra/newview/llviewerwindow.cpp | 2 | ||||
| -rw-r--r-- | indra/newview/llvovolume.cpp | 42 | ||||
| -rw-r--r-- | indra/newview/llvovolume.h | 17 | ||||
| -rw-r--r-- | indra/newview/pipeline.cpp | 16 | 
7 files changed, 66 insertions, 50 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; } diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 2b531b6acc..ae727e409f 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -300,7 +300,7 @@ void LLPanelVolume::getState( )  		{  			LightColorSwatch->setEnabled( TRUE );  			LightColorSwatch->setValid( TRUE ); -			LightColorSwatch->set(volobjp->getLightBaseColor()); +			LightColorSwatch->set(volobjp->getLightSRGBBaseColor());  		}  		LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control"); @@ -328,7 +328,7 @@ void LLPanelVolume::getState( )  		getChild<LLUICtrl>("Light Focus")->setValue(params.mV[1]);  		getChild<LLUICtrl>("Light Ambiance")->setValue(params.mV[2]); -		mLightSavedColor = volobjp->getLightColor(); +		mLightSavedColor = volobjp->getLightSRGBColor();  	}  	else  	{ @@ -807,7 +807,7 @@ void LLPanelVolume::onLightSelectColor(const LLSD& data)  	{  		LLColor4	clr = LightColorSwatch->get();  		LLColor3	clr3( clr ); -		volobjp->setLightColor(clr3); +		volobjp->setLightSRGBColor(clr3);  		mLightSavedColor = clr;  	}  } @@ -881,7 +881,7 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )  	if(LightColorSwatch)  	{  		LLColor4	clr = LightColorSwatch->get(); -		volobjp->setLightColor(LLColor3(clr)); +		volobjp->setLightSRGBColor(LLColor3(clr));  	}  	LLTextureCtrl*	LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control"); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index b238256b7f..ae1eec81e0 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3871,7 +3871,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,  						F32 scale = vovolume->getLightRadius();  						gGL.scalef(scale, scale, scale); -						LLColor4 color(vovolume->getLightColor(), .5f); +						LLColor4 color(vovolume->getLightSRGBColor(), .5f);  						gGL.color4fv(color.mV);  						//F32 pixel_area = 100000.f; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 586d3b66b0..bd7ad399f9 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3147,14 +3147,19 @@ void LLVOVolume::setIsLight(BOOL is_light)  	}  } -void LLVOVolume::setLightColor(const LLColor3& color) +void LLVOVolume::setLightSRGBColor(const LLColor3& color) +{ +    setLightLinearColor(linearColor3(color)); +} + +void LLVOVolume::setLightLinearColor(const LLColor3& color)  {  	LLLightParams *param_block = (LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT);  	if (param_block)  	{ -		if (param_block->getColor() != color) +		if (param_block->getLinearColor() != color)  		{ -			param_block->setColor(LLColor4(color, param_block->getColor().mV[3])); +			param_block->setLinearColor(LLColor4(color, param_block->getLinearColor().mV[3]));  			parameterChanged(LLNetworkData::PARAMS_LIGHT, true);  			gPipeline.markTextured(mDrawable);  			mFaceMappingChanged = TRUE; @@ -3167,9 +3172,9 @@ void LLVOVolume::setLightIntensity(F32 intensity)  	LLLightParams *param_block = (LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT);  	if (param_block)  	{ -		if (param_block->getColor().mV[3] != intensity) +		if (param_block->getLinearColor().mV[3] != intensity)  		{ -			param_block->setColor(LLColor4(LLColor3(param_block->getColor()), intensity)); +			param_block->setLinearColor(LLColor4(LLColor3(param_block->getLinearColor()), intensity));  			parameterChanged(LLNetworkData::PARAMS_LIGHT, true);  		}  	} @@ -3221,12 +3226,17 @@ BOOL LLVOVolume::getIsLight() const  	return getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT);  } -LLColor3 LLVOVolume::getLightBaseColor() const +LLColor3 LLVOVolume::getLightSRGBBaseColor() const +{ +    return srgbColor3(getLightLinearColor()); +} + +LLColor3 LLVOVolume::getLightLinearBaseColor() const  {  	const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT);  	if (param_block)  	{ -		return LLColor3(param_block->getColor()); +		return LLColor3(param_block->getLinearColor());  	}  	else  	{ @@ -3236,17 +3246,10 @@ LLColor3 LLVOVolume::getLightBaseColor() const  LLColor3 LLVOVolume::getLightLinearColor() const  { -    LLColor3 ret = getLightSRGBColor(); -    ret = linearColor3(ret); -    return ret; -} - -LLColor3 LLVOVolume::getLightSRGBColor() const -{      const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT);      if (param_block)      { -        return LLColor3(param_block->getSRGBColor()) * param_block->getSRGBColor().mV[3]; +        return LLColor3(param_block->getLinearColor()) * param_block->getLinearColor().mV[3];      }      else      { @@ -3254,6 +3257,13 @@ LLColor3 LLVOVolume::getLightSRGBColor() const      }  } +LLColor3 LLVOVolume::getLightSRGBColor() const +{ +    LLColor3 ret = getLightLinearColor(); +    ret = srgbColor3(ret); +    return ret; +} +  LLUUID LLVOVolume::getLightTextureID() const  {  	if (getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE)) @@ -3345,7 +3355,7 @@ F32 LLVOVolume::getLightIntensity() const  	const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT);  	if (param_block)  	{ -		return param_block->getColor().mV[3]; +		return param_block->getLinearColor().mV[3];  	}  	else  	{ diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index bf19a01d57..776b6a16b0 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -242,7 +242,11 @@ public:  	// For Lights  	void setIsLight(BOOL is_light); -	void setLightColor(const LLColor3& color); +    //set the gamma-corrected (sRGB) color of this light +	void setLightSRGBColor(const LLColor3& color); +    //set the linear color of this light +    void setLightLinearColor(const LLColor3& color); +  	void setLightIntensity(F32 intensity);  	void setLightRadius(F32 radius);  	void setLightFalloff(F32 falloff); @@ -254,12 +258,13 @@ public:      // Get the light color in sRGB color space NOT scaled by intensity. -	LLColor3 getLightBaseColor() const;  -     -    //same as getLightSRGBColor() -    LLColor3 getLightColor() const { return getLightSRGBColor(); } +	LLColor3 getLightSRGBBaseColor() const;  -    // Same as linearColor3(getLightSRGBColor) +    // Get the light color in linear color space NOT scaled by intensity. +    LLColor3 getLightLinearBaseColor() const; +     +    // Get the light color in linear color space scaled by intensity  +    //  this is the value that should be fed into shaders      LLColor3 getLightLinearColor() const;      // Get the light color in sRGB color space scaled by intensity. diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1765ba227f..563b45273e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6325,8 +6325,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)  				mLightMovingMask |= (1<<cur_light);  			} -            //NOTE: for legacy reasons, send sRGB color to light shader for both deferred and non-deferred path -			LLColor4  light_color = light->getLightColor(); +            //send linear light color to shader +			LLColor4  light_color = light->getLightLinearColor();  			light_color.mV[3] = 0.0f;  			F32 fade = iter->fade; @@ -8768,8 +8768,8 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)  					const F32* c = center.getF32ptr();  					F32 s = volume->getLightRadius()*1.5f; -                    //NOTE: for legacy reasons, send sRGB color to light shader -                    LLColor3 col = volume->getLightColor(); +                    //send light color to shader in linear space +                    LLColor3 col = volume->getLightLinearColor();  					if (col.magVecSquared() < 0.001f)  					{ @@ -8861,8 +8861,8 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)  					setupSpotLight(gDeferredSpotLightProgram, drawablep); -                    //NOTE: for legacy reasons, send sRGB color to light shader -                    LLColor3 col = volume->getLightColor(); +                    //send light color to shader in linear space +                    LLColor3 col = volume->getLightLinearColor();  					gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c);  					gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8951,8 +8951,8 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)  					setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); -                    //NOTE: for legacy reasons, send sRGB color to light shader -                    LLColor3 col = volume->getLightColor(); +                    //send light color to shader in linear space +                    LLColor3 col = volume->getLightLinearColor();  					gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v);                      gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); | 
