SL-17028 Fix for inconsistent ordering of transparent rigged meshes and removal of glow-only rigged meshes from depth buffer.

master
Dave Parks 2022-03-24 14:48:06 -05:00
parent 1d79d101ec
commit 41cf9fcb05
4 changed files with 36 additions and 30 deletions

View File

@ -215,6 +215,11 @@ void main()
float final_alpha = diffuse_linear.a;
#ifdef USE_VERTEX_COLOR
if (vertex_color.a <= 0.0)
{ // TODO: figure out how to get invisible faces out of
// render batches without breaking glow
discard;
}
final_alpha *= vertex_color.a;
diffuse_srgb.rgb *= vertex_color.rgb;
diffuse_linear.rgb = srgb_to_linear(diffuse_srgb.rgb);
@ -308,7 +313,7 @@ vec3 post_atmo = color.rgb;
#endif // WATER_FOG
#endif
frag_color = color;
}

View File

@ -228,8 +228,8 @@ void LLDrawPoolAlpha::forwardRender(bool rigged)
//enable writing to alpha for emissive effects
gGL.setColorMask(true, true);
bool write_depth = rigged
|| LLDrawPoolWater::sSkipScreenCopy
bool write_depth = rigged ||
LLDrawPoolWater::sSkipScreenCopy
// we want depth written so that rendered alpha will
// contribute to the alpha mask used for impostors
|| LLPipeline::sImpostorRenderAlphaDepthPass;
@ -484,6 +484,7 @@ void LLDrawPoolAlpha::renderEmissives(U32 mask, std::vector<LLDrawInfo*>& emissi
void LLDrawPoolAlpha::renderRiggedEmissives(U32 mask, std::vector<LLDrawInfo*>& emissives)
{
LLGLDepthTest depth(GL_TRUE, GL_FALSE); //disable depth writes since "emissive" is additive so sorting doesn't matter
LLGLSLShader* shader = emissive_shader->mRiggedVariant;
shader->bind();
shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, 1.f);

View File

@ -143,7 +143,7 @@ public:
LLViewerObject* getViewerObject() const { return mVObjp; }
S32 getLOD() const { return mVObjp.notNull() ? mVObjp->getLOD() : 0; }
void setPoolType(U32 type) { mPoolType = type; }
S32 getTEOffset() { return mTEOffset; }
S32 getTEOffset() const { return mTEOffset; }
LLViewerTexture* getTexture(U32 ch = LLRender::DIFFUSE_MAP) const;
void setViewerObject(LLViewerObject* object);
@ -233,6 +233,12 @@ public:
void notifyAboutCreatingTexture(LLViewerTexture *texture);
void notifyAboutMissingAsset(LLViewerTexture *texture);
// used to preserve draw order of faces that are batched together.
// Allows content creators to manipulate linked sets and face ordering
// for consistent alpha sorting results, particularly for rigged attachments
void setDrawOrderIndex(U32 index) { mDrawOrderIndex = index; }
U32 getDrawOrderIndex() const { return mDrawOrderIndex; }
public: //aligned members
LLVector4a mExtents[2];
@ -305,6 +311,7 @@ private:
bool mHasMedia ;
bool mIsMediaAllowed;
U32 mDrawOrderIndex = 0; // see setDrawOrderIndex
protected:
static BOOL sSafeRenderSelect;

View File

@ -5467,6 +5467,7 @@ static inline void add_face(T*** list, U32* count, T* face)
{
if (count[1] < MAX_FACE_COUNT)
{
face->setDrawOrderIndex(count[1]);
list[1][count[1]++] = face;
}
}
@ -5474,6 +5475,7 @@ static inline void add_face(T*** list, U32* count, T* face)
{
if (count[0] < MAX_FACE_COUNT)
{
face->setDrawOrderIndex(count[0]);
list[0][count[0]++] = face;
}
}
@ -6088,7 +6090,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
}
}
struct CompareBatchBreakerModified
struct CompareBatchBreaker
{
bool operator()(const LLFace* const& lhs, const LLFace* const& rhs)
{
@ -6103,18 +6105,23 @@ struct CompareBatchBreakerModified
{
return lte->getFullbright() < rte->getFullbright();
}
else if (LLPipeline::sRenderDeferred && lte->getMaterialParams() != rte->getMaterialParams())
{
return lte->getMaterialParams() < rte->getMaterialParams();
}
else if (LLPipeline::sRenderDeferred && (lte->getMaterialParams() == rte->getMaterialParams()) && (lte->getShiny() != rte->getShiny()))
else if (LLPipeline::sRenderDeferred && lte->getMaterialID() != rte->getMaterialID())
{
return lte->getMaterialID() < rte->getMaterialID();
}
else if (lte->getShiny() != rte->getShiny())
{
return lte->getShiny() < rte->getShiny();
}
else
else if (lhs->getTexture() != rhs->getTexture())
{
return lhs->getTexture() < rhs->getTexture();
}
else
{
// all else being equal, maintain consistent draw order
return lhs->getDrawOrderIndex() < rhs->getDrawOrderIndex();
}
}
};
@ -6122,9 +6129,6 @@ struct CompareBatchBreakerRigged
{
bool operator()(const LLFace* const& lhs, const LLFace* const& rhs)
{
const LLTextureEntry* lte = lhs->getTextureEntry();
const LLTextureEntry* rte = rhs->getTextureEntry();
if (lhs->mAvatar != rhs->mAvatar)
{
return lhs->mAvatar < rhs->mAvatar;
@ -6133,23 +6137,12 @@ struct CompareBatchBreakerRigged
{
return lhs->mSkinInfo->mHash < rhs->mSkinInfo->mHash;
}
else if (lhs->getTexture() != rhs->getTexture())
else
{
return lhs->getTexture() < rhs->getTexture();
// "inherit" non-rigged behavior
CompareBatchBreaker comp;
return comp(lhs, rhs);
}
else if (lte->getBumpmap() != rte->getBumpmap())
{
return lte->getBumpmap() < rte->getBumpmap();
}
else if (LLPipeline::sRenderDeferred && lte->getMaterialID() != rte->getMaterialID())
{
return lte->getMaterialID() < rte->getMaterialID();
}
else // if (LLPipeline::sRenderDeferred && (lte->getMaterialParams() == rte->getMaterialParams()) && (lte->getShiny() != rte->getShiny()))
{
return lte->getShiny() < rte->getShiny();
}
}
};
@ -6198,7 +6191,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
else if (!distance_sort)
{
//sort faces by things that break batches, not including avatar and mesh id
std::sort(faces, faces + face_count, CompareBatchBreakerModified());
std::sort(faces, faces + face_count, CompareBatchBreaker());
}
else
{