summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolbump.cpp
diff options
context:
space:
mode:
authorRichard Nelson <none@none>2010-07-20 11:31:23 -0700
committerRichard Nelson <none@none>2010-07-20 11:31:23 -0700
commit572e72d8a1cb777b0d60cdfa389f3e397a652da9 (patch)
treec9e7f05654525d3a5ed2d89267462f92b5e8fd6f /indra/newview/lldrawpoolbump.cpp
parent4bd450737bf1f5a74a4857932235d7bcbead1388 (diff)
parent67fb58847981f69cb31c34d7141165ba3f49aef6 (diff)
merge
Diffstat (limited to 'indra/newview/lldrawpoolbump.cpp')
-rw-r--r--indra/newview/lldrawpoolbump.cpp116
1 files changed, 88 insertions, 28 deletions
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index c206daf89b..667bd92e92 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -94,7 +94,16 @@ void LLStandardBumpmap::shutdown()
// static
void LLStandardBumpmap::restoreGL()
{
- llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
+ 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;
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("None"); // BE_NO_BUMP
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Brightness"); // BE_BRIGHTNESS
gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness"); // BE_DARKNESS
@@ -157,8 +166,9 @@ void LLStandardBumpmap::restoreGL()
}
// static
-void LLStandardBumpmap::destroyGL()
+void LLStandardBumpmap::clear()
{
+ llinfos << "Clearing standard bumpmaps." << llendl;
for( U32 i = 0; i < LLStandardBumpmap::sStandardBumpmapCount; i++ )
{
gStandardBumpmapList[i].mLabel.assign("");
@@ -167,6 +177,12 @@ void LLStandardBumpmap::destroyGL()
sStandardBumpmapCount = 0;
}
+// static
+void LLStandardBumpmap::destroyGL()
+{
+ clear();
+}
+
////////////////////////////////////////////////////////////////
@@ -619,9 +635,9 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel)
}
//static
-void LLDrawPoolBump::beginBump()
+void LLDrawPoolBump::beginBump(U32 pass)
{
- if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+ if (!gPipeline.hasRenderBatches(pass))
{
return;
}
@@ -664,9 +680,9 @@ void LLDrawPoolBump::beginBump()
}
//static
-void LLDrawPoolBump::renderBump()
+void LLDrawPoolBump::renderBump(U32 pass)
{
- if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+ if (!gPipeline.hasRenderBatches(pass))
{
return;
}
@@ -679,13 +695,13 @@ void LLDrawPoolBump::renderBump()
/// Get rid of z-fighting with non-bump pass.
LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -1.0f);
- renderBump(LLRenderPass::PASS_BUMP, sVertexMask);
+ renderBump(pass, sVertexMask);
}
//static
-void LLDrawPoolBump::endBump()
+void LLDrawPoolBump::endBump(U32 pass)
{
- if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_BUMP))
+ if (!gPipeline.hasRenderBatches(pass))
{
return;
}
@@ -702,6 +718,18 @@ void LLDrawPoolBump::endBump()
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))
@@ -756,21 +784,45 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
void LLDrawPoolBump::beginPostDeferredPass(S32 pass)
{
- beginFullbrightShiny();
+ switch (pass)
+ {
+ case 0:
+ beginFullbrightShiny();
+ break;
+ case 1:
+ beginBump(LLRenderPass::PASS_POST_BUMP);
+ break;
+ }
}
void LLDrawPoolBump::endPostDeferredPass(S32 pass)
{
- endFullbrightShiny();
+ switch (pass)
+ {
+ case 0:
+ endFullbrightShiny();
+ break;
+ case 1:
+ endBump(LLRenderPass::PASS_POST_BUMP);
+ break;
+ }
}
void LLDrawPoolBump::renderPostDeferred(S32 pass)
{
- renderFullbrightShiny();
+ switch (pass)
+ {
+ case 0:
+ renderFullbrightShiny();
+ break;
+ case 1:
+ renderBump(LLRenderPass::PASS_POST_BUMP);
+ break;
+ }
}
////////////////////////////////////////////////////////////////
-// List of one-component bump-maps created from other texures.
+// List of bump-maps created from other textures.
//const LLUUID TEST_BUMP_ID("3d33eaf2-459c-6f97-fd76-5fce3fc29447");
@@ -783,24 +835,32 @@ void LLBumpImageList::init()
LLStandardBumpmap::init();
}
-void LLBumpImageList::shutdown()
+void LLBumpImageList::clear()
{
+ 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()
{
- mBrightnessEntries.clear();
- mDarknessEntries.clear();
+ clear();
LLStandardBumpmap::destroyGL();
}
void LLBumpImageList::restoreGL()
{
- // Images will be recreated as they are needed.
LLStandardBumpmap::restoreGL();
+ // Images will be recreated as they are needed.
}
@@ -852,6 +912,7 @@ void LLBumpImageList::updateImages()
}
}
}
+
for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); )
{
bump_image_map_t::iterator curiter = iter++;
@@ -1004,8 +1065,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[(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 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 norm = right%down + down%left + left%up + up%right;
@@ -1030,7 +1091,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();
@@ -1115,8 +1176,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: exagerates the effect in midrange. Disadvantage: clamps at the extremes.
- if( BE_DARKNESS == bump_code )
+ const F32 ARTIFICIAL_SCALE = 2.f; // Advantage: exaggerates the effect in midrange. Disadvantage: clamps at the extremes.
+ if (BE_DARKNESS == bump_code)
{
for( i = minimum; i <= maximum; i++ )
{
@@ -1126,7 +1187,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;
@@ -1141,9 +1201,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)
{
@@ -1152,8 +1212,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);
}