diff options
author | Dave Parks <davep@lindenlab.com> | 2020-03-27 22:33:57 +0000 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2020-03-27 22:33:57 +0000 |
commit | c28852bd9aef0d3f69dd1fb76b8208666af68613 (patch) | |
tree | 6b3baf227dbd5b998309f48f983bc15c5a66253b /indra/newview | |
parent | f61474fe5b3bd616fdd2d92fbb3478891bb60fb1 (diff) | |
parent | e468d8018634b51f329eae17485c3358c0a3630b (diff) |
Merged in davep/DRTVWR-440 (pull request #52)
SL-12902 Better fix for light color values in color swatch not matching light color values inworld.
Diffstat (limited to 'indra/newview')
-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 |
5 files changed, 50 insertions, 35 deletions
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); |