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/newview | |
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/newview')
-rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 17 | ||||
-rw-r--r-- | indra/newview/llvosky.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llvovolume.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llvovolume.h | 1 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 21 |
5 files changed, 35 insertions, 20 deletions
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index e608f6eaf2..7f59852b62 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -503,7 +503,12 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); - sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); + if (LLPipeline::RenderDeferred) { + sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, srgbColor4(color).mV); + } + else { + sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); + } sun_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); LLFacePool::LLOverrideFaceColor color_override(this, color); @@ -554,9 +559,15 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() F32 moon_brightness = (float)psky->getMoonBrightness(); moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness); - moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV); - moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); + if (LLPipeline::RenderDeferred) { + moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, srgbColor4(gSky.mVOSkyp->getMoon().getColor()).mV); + moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, srgbColor4(color).mV); + } + else { + moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV); + moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); + } moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); LLFacePool::LLOverrideFaceColor color_override(this, color); diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 8bcd875d90..954a590682 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -210,6 +210,9 @@ void LLSkyTex::createGLImage(S32 which) if (LLPipeline::RenderDeferred) { mTexture[which]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA); } + else { + mTexture[which]->setExplicitFormat(GL_RGBA8, GL_RGBA); + } mTexture[which]->createGLTexture(0, mImageRaw[which], 0, TRUE, LLGLTexture::LOCAL); mTexture[which]->setAddressMode(LLTexUnit::TAM_CLAMP); } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 4ddd9c4568..85bc1ba845 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3239,6 +3239,19 @@ LLColor3 LLVOVolume::getLightColor() const } } +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]; + } + else + { + return LLColor3(1, 1, 1); + } +} + LLUUID LLVOVolume::getLightTextureID() const { if (getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE)) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 0882fc095d..aeabcda911 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -251,6 +251,7 @@ public: BOOL getIsLight() const; LLColor3 getLightBaseColor() const; // not scaled by intensity LLColor3 getLightColor() const; // scaled by intensity + LLColor3 getLightsRGBColor() const; // Used to get the (cached) light color in sRGB color space. Also scaled by intensity. LLUUID getLightTextureID() const; bool isLightSpotlight() const; LLVector3 getSpotLightParams() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 658410fd3d..2a7cac3eda 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8368,7 +8368,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); shader.uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); - shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, srgbColor4(mMoonDiffuse).mV); LLEnvironment& environment = LLEnvironment::instance(); shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); @@ -8705,7 +8705,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) const F32* c = center.getF32ptr(); F32 s = volume->getLightRadius(); - LLColor3 col = volume->getLightColor(); + LLColor3 col = volume->getLightsRGBColor(); if (col.magVecSquared() < 0.001f) { @@ -8742,10 +8742,6 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) continue; } - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ - LL_RECORD_BLOCK_TIME(FTM_LOCAL_LIGHTS); gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8801,7 +8797,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) setupSpotLight(gDeferredSpotLightProgram, drawablep); - LLColor3 col = volume->getLightColor(); + LLColor3 col = volume->getLightsRGBColor(); /*col.mV[0] = powf(col.mV[0], 2.2f); col.mV[1] = powf(col.mV[1], 2.2f); col.mV[2] = powf(col.mV[2], 2.2f);*/ @@ -8850,12 +8846,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) col[count] = light_colors.front(); light_colors.pop_front(); - /*col[count].mV[0] = powf(col[count].mV[0], 2.2f); - col[count].mV[1] = powf(col[count].mV[1], 2.2f); - col[count].mV[2] = powf(col[count].mV[2], 2.2f);*/ - far_z = llmin(light[count].mV[2]-light[count].mV[3], far_z); - //col[count] = pow4fsrgb(col[count], 2.2f); count++; if (count == max_count || fullscreen_lights.empty()) { @@ -8897,11 +8888,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); - LLColor3 col = volume->getLightColor(); - - /*col.mV[0] = powf(col.mV[0], 2.2f); - col.mV[1] = powf(col.mV[1], 2.2f); - col.mV[2] = powf(col.mV[2], 2.2f);*/ + LLColor3 col = volume->getLightsRGBColor(); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); |