Determine if to stuff shiny data into alpha component a bit differently. Cuts out a lot of crazy logic and lets us choose based off of target renderpass.

This commit is contained in:
Shyotl
2014-05-14 03:38:16 -05:00
parent 3db9c6a9ff
commit 5805fe636a
4 changed files with 56 additions and 55 deletions

View File

@@ -1878,6 +1878,8 @@ void LLDrawPoolAvatar::addRiggedFace(LLFace* facep, U32 type)
facep->setRiggedIndex(type, mRiggedFace[type].size());
facep->setPool(this);
mRiggedFace[type].push_back(facep);
facep->mShinyInAlpha = type == RIGGED_DEFERRED_SIMPLE || type == RIGGED_DEFERRED_BUMP || type == RIGGED_FULLBRIGHT_SHINY || type == RIGGED_SHINY;
}
void LLDrawPoolAvatar::removeRiggedFace(LLFace* facep)

View File

@@ -166,6 +166,8 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
mBoundingSphereRadius = 0.0f ;
mHasMedia = FALSE ;
mShinyInAlpha = false;
}
void LLFace::destroy()
@@ -1298,53 +1300,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
if (rebuild_color) // FALSE if tep == NULL
{ //decide if shiny goes in alpha channel of color
static const LLCachedControl<bool> alt_batching("SHAltBatching",true);
if (tep &&
((!alt_batching && getPoolType() != LLDrawPool::POOL_ALPHA) ||
(alt_batching && getPoolType() != LLDrawPool::POOL_ALPHA &&
getPoolType() != LLDrawPool::POOL_ALPHA_MASK &&
getPoolType() != LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK && // <--- alpha channel MUST contain transparency, not shiny
(getPoolType() != LLDrawPool::POOL_SIMPLE || LLPipeline::sRenderDeferred)))) // Impostor pass for simple uses alpha masking. Need to be opaque.
if(mShinyInAlpha)
{
LLMaterial* mat = tep->getMaterialParams().get();
bool shiny_in_alpha = alt_batching ? true : false;
if(alt_batching)
{
if (LLPipeline::sRenderDeferred)
{ //store shiny in alpha if we don't have a specular map
if (getPoolType() == LLDrawPool::POOL_MATERIALS && mat->getSpecularID().notNull())
{
shiny_in_alpha = false;
}
}
}
else
{
if (LLPipeline::sRenderDeferred)
{
if (!mat || mat->getSpecularID().isNull())
{
shiny_in_alpha = true;
}
}
else
{
if (!mat || mat->getDiffuseAlphaMode() != LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
{
shiny_in_alpha = true;
}
}
}
if(getPoolType() == LLDrawPool::POOL_FULLBRIGHT)
{
color.mV[3] = 1.f; //Simple fullbright reads alpha for fog contrib, not shiny/transparency, so since opaque, force to 1.
}
else if (shiny_in_alpha)
{
GLfloat alpha[4] =
GLfloat alpha[4] =
{
0.00f,
0.25f,
@@ -1352,9 +1310,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
0.75f
};
llassert(tep->getShiny() <= 3);
color.mV[3] = U8 (alpha[tep->getShiny()] * 255);
}
llassert(tep->getShiny() <= 3);
color.mV[3] = U8 (alpha[tep->getShiny()] * 255);
}
}

View File

@@ -263,6 +263,8 @@ public:
LLMatrix4* mNormalMapMatrix;
LLDrawInfo* mDrawInfo;
bool mShinyInAlpha;
private:
LLPointer<LLVertexBuffer> mVertexBuffer;

View File

@@ -4142,6 +4142,13 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
return;
}
if(!facep->mShinyInAlpha)
facep->mShinyInAlpha = (type == LLRenderPass::PASS_FULLBRIGHT_SHINY) ||
(type == LLRenderPass::PASS_INVISI_SHINY) ||
(type == LLRenderPass::PASS_SHINY) ||
(LLPipeline::sRenderDeferred && type == LLRenderPass::PASS_BUMP) ||
(LLPipeline::sRenderDeferred && type == LLRenderPass::PASS_SIMPLE);
//add face to drawmap
LLSpatialGroup::drawmap_elem_t& draw_vec = group->mDrawMap[type];
@@ -4199,8 +4206,9 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
U32 pool_type = facep->getPoolType();
bool cmp_bump = (type == LLRenderPass::PASS_BUMP) || (type == LLRenderPass::PASS_POST_BUMP);
bool cmp_mat = (!alt_batching) || LLPipeline::sRenderDeferred && /*facep->getTextureEntry()->getColor().mV[3] >= 0.999f &&*/
((pool_type == LLDrawPool::POOL_MATERIALS) || (pool_type == LLDrawPool::POOL_ALPHA));
bool cmp_mat = (!alt_batching) || LLPipeline::sRenderDeferred &&
((pool_type == LLDrawPool::POOL_MATERIALS) || (pool_type == LLDrawPool::POOL_ALPHA)) ||
pool_type == LLDrawPool::POOL_ALPHA_MASK || pool_type == LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK;
bool cmp_shiny = (!alt_batching) ? !!mat : (mat && cmp_mat);
bool cmp_fullbright = !alt_batching || cmp_shiny || pool_type == LLDrawPool::POOL_ALPHA;
@@ -5864,7 +5872,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFac
//for debugging, set last time face was updated vs moved
facep->updateRebuildFlags();
if (!LLPipeline::sDelayVBUpdate)
//Singu Note: Moved to after registerFace calls, as those update LLFace::mShinyInAlpha, which is needed before updating the vertex buffer.
/*if (!LLPipeline::sDelayVBUpdate)
{ //copy face geometry into vertex buffer
LLDrawable* drawablep = facep->getDrawable();
LLVOVolume* vobj = drawablep->getVOVolume();
@@ -5889,11 +5898,10 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFac
{
vobj->updateRelativeXform(false);
}
}
}*/
}
index_offset += facep->getGeomCount();
indices_index += facep->getIndicesCount();
facep->mShinyInAlpha = false;
static const LLCachedControl<bool> alt_batching("SHAltBatching",true);
@@ -6309,6 +6317,37 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFac
registerFace(group, facep, LLRenderPass::PASS_GLOW);
}
}
//Singu Note: LLFace::mShinyInAlpha has been updated by now. We're good to go.
if (!LLPipeline::sDelayVBUpdate)
{ //copy face geometry into vertex buffer
LLDrawable* drawablep = facep->getDrawable();
LLVOVolume* vobj = drawablep->getVOVolume();
LLVolume* volume = vobj->getVolume();
if (drawablep->isState(LLDrawable::ANIMATED_CHILD))
{
vobj->updateRelativeXform(true);
}
U32 te_idx = facep->getTEOffset();
llassert(!facep->isState(LLFace::RIGGED));
if (!facep->getGeometryVolume(*volume, te_idx,
vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true))
{
llwarns << "Failed to get geometry for face!" << llendl;
}
if (drawablep->isState(LLDrawable::ANIMATED_CHILD))
{
vobj->updateRelativeXform(false);
}
}
index_offset += facep->getGeomCount();
indices_index += facep->getIndicesCount();
++face_iter;
}