summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolbump.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-05-12 19:35:02 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-05-12 19:35:02 +0100
commit261f2d60548c7ca784840ac5cafe7826dc311f74 (patch)
treeccead60398d1f1e148358bb120993f0879bc1544 /indra/newview/lldrawpoolbump.cpp
parent3d39634cbd3abe4df7b9ce8d229e59c3087de713 (diff)
EXT-7154 : FIXED : darkness bumpmap looks like lightness bumpmap when deferred rendering is enabled
Diffstat (limited to 'indra/newview/lldrawpoolbump.cpp')
-rw-r--r--indra/newview/lldrawpoolbump.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 08c9f7fe15..a3b236fcb9 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -818,17 +818,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();
}
@@ -1065,7 +1070,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();
@@ -1150,8 +1155,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++ )
{
@@ -1161,7 +1169,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;
@@ -1176,9 +1183,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)
{
@@ -1187,8 +1194,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);
}