summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolbump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolbump.cpp')
-rw-r--r--indra/newview/lldrawpoolbump.cpp116
1 files changed, 28 insertions, 88 deletions
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 667bd92e92..c206daf89b 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -94,16 +94,7 @@ void LLStandardBumpmap::shutdown()
// static
void LLStandardBumpmap::restoreGL()
{
- addstandard();
-}
-
-// static
-void LLStandardBumpmap::addstandard()
-{
- // can't assert; we destroyGL and restoreGL a lot during *first* startup, which populates this list already, THEN we explicitly init the list as part of *normal* startup. Sigh. So clear the list every time before we (re-)add the standard bumpmaps.
- //llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
- clear();
- llinfos << "Adding standard bumpmaps." << llendl;
+ llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("None"); // BE_NO_BUMP
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Brightness"); // BE_BRIGHTNESS
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness"); // BE_DARKNESS
@@ -166,9 +157,8 @@ void LLStandardBumpmap::addstandard()
}
// static
-void LLStandardBumpmap::clear()
+void LLStandardBumpmap::destroyGL()
{
- llinfos << "Clearing standard bumpmaps." << llendl;
for( U32 i = 0; i < LLStandardBumpmap::sStandardBumpmapCount; i++ )
{
gStandardBumpmapList[i].mLabel.assign("");
@@ -177,12 +167,6 @@ void LLStandardBumpmap::clear()
sStandardBumpmapCount = 0;
}
-// static
-void LLStandardBumpmap::destroyGL()
-{
- clear();
-}
-
////////////////////////////////////////////////////////////////
@@ -635,9 +619,9 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel)
}
//static
-void LLDrawPoolBump::beginBump(U32 pass)
+void LLDrawPoolBump::beginBump()
{
- if (!gPipeline.hasRenderBatches(pass))
+ if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
{
return;
}
@@ -680,9 +664,9 @@ void LLDrawPoolBump::beginBump(U32 pass)
}
//static
-void LLDrawPoolBump::renderBump(U32 pass)
+void LLDrawPoolBump::renderBump()
{
- if (!gPipeline.hasRenderBatches(pass))
+ if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
{
return;
}
@@ -695,13 +679,13 @@ void LLDrawPoolBump::renderBump(U32 pass)
/// Get rid of z-fighting with non-bump pass.
LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -1.0f);
- renderBump(pass, sVertexMask);
+ renderBump(LLRenderPass::PASS_BUMP, sVertexMask);
}
//static
-void LLDrawPoolBump::endBump(U32 pass)
+void LLDrawPoolBump::endBump()
{
- if (!gPipeline.hasRenderBatches(pass))
+ if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
{
return;
}
@@ -718,18 +702,6 @@ void LLDrawPoolBump::endBump(U32 pass)
gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
-S32 LLDrawPoolBump::getNumDeferredPasses()
-{
- if (gSavedSettings.getBOOL("RenderObjectBump"))
- {
- return 1;
- }
- else
- {
- return 0;
- }
-}
-
void LLDrawPoolBump::beginDeferredPass(S32 pass)
{
if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
@@ -784,45 +756,21 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
void LLDrawPoolBump::beginPostDeferredPass(S32 pass)
{
- switch (pass)
- {
- case 0:
- beginFullbrightShiny();
- break;
- case 1:
- beginBump(LLRenderPass::PASS_POST_BUMP);
- break;
- }
+ beginFullbrightShiny();
}
void LLDrawPoolBump::endPostDeferredPass(S32 pass)
{
- switch (pass)
- {
- case 0:
- endFullbrightShiny();
- break;
- case 1:
- endBump(LLRenderPass::PASS_POST_BUMP);
- break;
- }
+ endFullbrightShiny();
}
void LLDrawPoolBump::renderPostDeferred(S32 pass)
{
- switch (pass)
- {
- case 0:
- renderFullbrightShiny();
- break;
- case 1:
- renderBump(LLRenderPass::PASS_POST_BUMP);
- break;
- }
+ renderFullbrightShiny();
}
////////////////////////////////////////////////////////////////
-// List of bump-maps created from other textures.
+// List of one-component bump-maps created from other texures.
//const LLUUID TEST_BUMP_ID("3d33eaf2-459c-6f97-fd76-5fce3fc29447");
@@ -835,32 +783,24 @@ void LLBumpImageList::init()
LLStandardBumpmap::init();
}
-void LLBumpImageList::clear()
+void LLBumpImageList::shutdown()
{
- llinfos << "Clearing dynamic bumpmaps." << llendl;
- // these will be re-populated on-demand
mBrightnessEntries.clear();
mDarknessEntries.clear();
-
- LLStandardBumpmap::clear();
-}
-
-void LLBumpImageList::shutdown()
-{
- clear();
LLStandardBumpmap::shutdown();
}
void LLBumpImageList::destroyGL()
{
- clear();
+ mBrightnessEntries.clear();
+ mDarknessEntries.clear();
LLStandardBumpmap::destroyGL();
}
void LLBumpImageList::restoreGL()
{
- LLStandardBumpmap::restoreGL();
// Images will be recreated as they are needed.
+ LLStandardBumpmap::restoreGL();
}
@@ -912,7 +852,6 @@ void LLBumpImageList::updateImages()
}
}
}
-
for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); )
{
bump_image_map_t::iterator curiter = iter++;
@@ -1065,8 +1004,8 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr
LLVector3 right = LLVector3(norm_scale, 0, (F32) src_data[(j*resX+rX)*src_cmp+src_cmp-1]-cH);
LLVector3 left = LLVector3(-norm_scale, 0, (F32) src_data[(j*resX+lX)*src_cmp+src_cmp-1]-cH);
- LLVector3 up = LLVector3(0, -norm_scale, (F32) src_data[(lY*resX+i)*src_cmp+src_cmp-1]-cH);
- LLVector3 down = LLVector3(0, norm_scale, (F32) src_data[(rY*resX+i)*src_cmp+src_cmp-1]-cH);
+ LLVector3 up = LLVector3(0, -norm_scale, (F32) src_data[(rY*resX+i)*src_cmp+src_cmp-1]-cH);
+ LLVector3 down = LLVector3(0, norm_scale, (F32) src_data[(lY*resX+i)*src_cmp+src_cmp-1]-cH);
LLVector3 norm = right%down + down%left + left%up + up%right;
@@ -1091,7 +1030,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()) // bump not cached yet
+ if (iter != entries_list.end())
{
LLPointer<LLImageRaw> dst_image = new LLImageRaw(src->getWidth(), src->getHeight(), 1);
U8* dst_data = dst_image->getData();
@@ -1176,8 +1115,8 @@ 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: exaggerates the effect in midrange. Disadvantage: clamps at the extremes.
- if (BE_DARKNESS == bump_code)
+ const F32 ARTIFICIAL_SCALE = 2.f; // Advantage: exagerates the effect in midrange. Disadvantage: clamps at the extremes.
+ if( BE_DARKNESS == bump_code )
{
for( i = minimum; i <= maximum; i++ )
{
@@ -1187,6 +1126,7 @@ 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;
@@ -1201,9 +1141,9 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
}
//---------------------------------------------------
- // immediately assign bump to a global smart pointer in case some local smart pointer
- // accidentally releases it.
- LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE );
+ //immediately assign bump to a global smart pointer in case some local smart pointer
+ //accidently releases it.
+ LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE);
if (!LLPipeline::sRenderDeferred)
{
@@ -1212,8 +1152,8 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
}
else
{
- LLPointer<LLImageRaw> nrm_image = new LLImageRaw(dst_image->getWidth(), dst_image->getHeight(), 4);
- generateNormalMapFromAlpha(dst_image, nrm_image);
+ LLPointer<LLImageRaw> nrm_image = new LLImageRaw(src->getWidth(), src->getHeight(), 4);
+ generateNormalMapFromAlpha(src, nrm_image);
bump->setExplicitFormat(GL_RGBA, GL_RGBA);
bump->createGLTexture(0, nrm_image);
}