diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-05-12 19:35:02 +0100 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-05-12 19:35:02 +0100 |
commit | 3ad81349acccc9af2531121d5d6d89ad4e6ec0b2 (patch) | |
tree | 6a8327eb0c4b65a2b629992d933ad1d598153b48 | |
parent | 7efb59f6b1f6484d094c8db588a54cd62b6ace7c (diff) |
EXT-7154 : FIXED : darkness bumpmap looks like lightness bumpmap when deferred rendering is enabled
(transplanted from 569666ad2d30d83cab0eec1eb206f7e91e89d398)
-rw-r--r-- | indra/newview/lldrawpoolbump.cpp | 31 | ||||
-rw-r--r-- | indra/newview/lldrawpoolbump.h | 1 | ||||
-rw-r--r-- | indra/newview/llviewercontrol.cpp | 4 |
3 files changed, 24 insertions, 12 deletions
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 967ce3fc5c..ac8bd4dc41 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -859,17 +859,22 @@ void LLBumpImageList::init() LLStandardBumpmap::init(); } -void LLBumpImageList::shutdown() +void LLBumpImageList::clear() { + // these will be re-populated on-demand mBrightnessEntries.clear(); mDarknessEntries.clear(); +} + +void LLBumpImageList::shutdown() +{ + clear(); LLStandardBumpmap::shutdown(); } void LLBumpImageList::destroyGL() { - mBrightnessEntries.clear(); - mDarknessEntries.clear(); + clear(); LLStandardBumpmap::destroyGL(); } @@ -1106,7 +1111,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI { bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries ); bump_image_map_t::iterator iter = entries_list.find(source_asset_id); - if (iter != entries_list.end()) + if (iter != entries_list.end()) // bump not cached yet { LLPointer<LLImageRaw> dst_image = new LLImageRaw(src->getWidth(), src->getHeight(), 1); U8* dst_data = dst_image->getData(); @@ -1191,8 +1196,11 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI F32 twice_one_over_range = 2.f / (maximum - minimum); S32 i; - const F32 ARTIFICIAL_SCALE = 2.f; // Advantage: exagerates the effect in midrange. Disadvantage: clamps at the extremes. - if( BE_DARKNESS == bump_code ) + bool bump_polarity_negative = LLPipeline::sRenderDeferred ? + (BE_BRIGHTNESS == bump_code) : (BE_DARKNESS == bump_code); // deferred mode likes its normal map values inverted + + const F32 ARTIFICIAL_SCALE = 2.f; // Advantage: exaggerates the effect in midrange. Disadvantage: clamps at the extremes. + if (bump_polarity_negative) { for( i = minimum; i <= maximum; i++ ) { @@ -1202,7 +1210,6 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI } else { - // BE_LIGHTNESS for( i = minimum; i <= maximum; i++ ) { F32 minus_one_to_one = F32(i - minimum) * twice_one_over_range - 1.f; @@ -1217,9 +1224,9 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI } //--------------------------------------------------- - //immediately assign bump to a global smart pointer in case some local smart pointer - //accidently releases it. - LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE); + // immediately assign bump to a global smart pointer in case some local smart pointer + // accidentally releases it. + LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE ); if (!LLPipeline::sRenderDeferred) { @@ -1228,8 +1235,8 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI } else { - LLPointer<LLImageRaw> nrm_image = new LLImageRaw(src->getWidth(), src->getHeight(), 4); - generateNormalMapFromAlpha(src, nrm_image); + LLPointer<LLImageRaw> nrm_image = new LLImageRaw(dst_image->getWidth(), dst_image->getHeight(), 4); + generateNormalMapFromAlpha(dst_image, nrm_image); bump->setExplicitFormat(GL_RGBA, GL_RGBA); bump->createGLTexture(0, nrm_image); } diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index a75653e68e..ceb72309d8 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -145,6 +145,7 @@ public: void init(); void shutdown(); + void clear(); void destroyGL(); void restoreGL(); void updateImages(); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 701df86de4..54323a4fad 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -43,6 +43,7 @@ #include "llagent.h" #include "llagentcamera.h" #include "llconsole.h" +#include "lldrawpoolbump.h" #include "lldrawpoolterrain.h" #include "llflexibleobject.h" #include "llfeaturemanager.h" @@ -118,6 +119,9 @@ static bool handleTerrainDetailChanged(const LLSD& newvalue) static bool handleSetShaderChanged(const LLSD& newvalue) { + // changing shader level may invalidate existing cached ad-hoc bump maps, as the shader type determines the format of the bump map it expectes - clear the bump cache + gBumpImageList.clear(); + LLViewerShaderMgr::instance()->setShaders(); return true; } |