summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-12-09 23:17:21 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-12-09 23:18:20 +0200
commitd1c88237c5b5d027ee8891c4013ea8580f5f4364 (patch)
treee1c3625ed5ec035c9cbc5648e39ce0bb2619afba /indra/newview
parente538aaabc77deb48b2a724029ccf21ca1eec6694 (diff)
Revert "SL-12069 Issues with bakes-on-mesh and alpha modes"
This reverts commit afd734b5f4ba66204f80f7726aa5fec538fcf1e4. Fix will be updated and moved to DRTVWR-515.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/lldrawpoolavatar.cpp4
-rw-r--r--indra/newview/llface.cpp4
-rw-r--r--indra/newview/llvovolume.cpp295
-rw-r--r--indra/newview/pipeline.cpp2
4 files changed, 211 insertions, 94 deletions
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 17b5fde947..87772d9eb6 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -2120,7 +2120,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
if (mat)
{
- switch (LLMaterial::eDiffuseAlphaMode(mat->getDiffuseAlphaModeRender()))
+ switch (LLMaterial::eDiffuseAlphaMode(mat->getDiffuseAlphaMode()))
{
case LLMaterial::DIFFUSE_ALPHA_MODE_MASK:
{
@@ -2258,7 +2258,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
sVertexProgram->uniform4f(LLShaderMgr::SPECULAR_COLOR, col.mV[0], col.mV[1], col.mV[2], spec);
sVertexProgram->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, env);
- if (mat->getDiffuseAlphaModeRender() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
+ if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
{
F32 cutoff = mat->getAlphaMaskCutoff()/255.f;
sVertexProgram->setMinimumAlpha(cutoff);
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 01d8b6775b..4a802ad9aa 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1165,7 +1165,7 @@ bool LLFace::canRenderAsMask()
}
LLMaterial* mat = te->getMaterialParams();
- if (mat && mat->getDiffuseAlphaModeRender() == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)
+ if (mat && mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)
{
return false;
}
@@ -1412,7 +1412,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
else
{
- if (!mat || mat->getDiffuseAlphaModeRender() != LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
+ if (!mat || mat->getDiffuseAlphaMode() != LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
{
shiny_in_alpha = true;
}
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 9d54b67ec9..95cfe29a80 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2301,34 +2301,51 @@ bool LLVOVolume::notifyAboutCreatingTexture(LLViewerTexture *texture)
std::pair<mmap_UUID_MAP_t::iterator, mmap_UUID_MAP_t::iterator> range = mWaitingTextureInfo.equal_range(texture->getID());
- bool refresh_materials = false;
+ typedef std::map<U8, LLMaterialPtr> map_te_material;
+ map_te_material new_material;
- // RGB textures without alpha channels won't work right with alpha,
- // we provide format to material for material to decide when to drop alpha
- for (mmap_UUID_MAP_t::iterator range_it = range.first; range_it != range.second; ++range_it)
- {
- LLMaterialPtr cur_material = getTEMaterialParams(range_it->second.te);
- if (cur_material.notNull()
- && LLRender::DIFFUSE_MAP == range_it->second.map)
- {
- U32 format = texture->getPrimaryFormat();
- if (format != cur_material->getDiffuseFormatPrimary())
- {
- cur_material->setDiffuseFormatPrimary(format);
- refresh_materials = true;
- }
- }
- } //for
+ for(mmap_UUID_MAP_t::iterator range_it = range.first; range_it != range.second; ++range_it)
+ {
+ LLMaterialPtr cur_material = getTEMaterialParams(range_it->second.te);
- if (refresh_materials)
- {
- LLViewerObject::refreshMaterials();
- }
+ //here we just interesting in DIFFUSE_MAP only!
+ if(NULL != cur_material.get() && LLRender::DIFFUSE_MAP == range_it->second.map && GL_RGBA != texture->getPrimaryFormat())
+ { //ok let's check the diffuse mode
+ switch(cur_material->getDiffuseAlphaMode())
+ {
+ case LLMaterial::DIFFUSE_ALPHA_MODE_BLEND:
+ case LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE:
+ case LLMaterial::DIFFUSE_ALPHA_MODE_MASK:
+ { //uups... we have non 32 bit texture with LLMaterial::DIFFUSE_ALPHA_MODE_* => LLMaterial::DIFFUSE_ALPHA_MODE_NONE
+
+ LLMaterialPtr mat = NULL;
+ map_te_material::iterator it = new_material.find(range_it->second.te);
+ if(new_material.end() == it) {
+ mat = new LLMaterial(cur_material->asLLSD());
+ new_material.insert(map_te_material::value_type(range_it->second.te, mat));
+ } else {
+ mat = it->second;
+ }
+
+ mat->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
+
+ } break;
+ } //switch
+ } //if
+ } //for
+
+ //setup new materials
+ for(map_te_material::const_iterator it = new_material.begin(), end = new_material.end(); it != end; ++it)
+ {
+ // These are placeholder materials, they shouldn't be sent to server
+ LLMaterialMgr::getInstance()->setLocalMaterial(getRegion()->getRegionID(), it->second);
+ LLViewerObject::setTEMaterialParams(it->first, it->second);
+ }
//clear wait-list
- mWaitingTextureInfo.erase(range.first, range.second);
+ mWaitingTextureInfo.erase(range.first, range.second);
- return refresh_materials;
+ return 0 != new_material.size();
}
bool LLVOVolume::notifyAboutMissingAsset(LLViewerTexture *texture)
@@ -2338,84 +2355,184 @@ bool LLVOVolume::notifyAboutMissingAsset(LLViewerTexture *texture)
std::pair<mmap_UUID_MAP_t::iterator, mmap_UUID_MAP_t::iterator> range = mWaitingTextureInfo.equal_range(texture->getID());
if(range.first == range.second) return false;
- bool refresh_materials = false;
-
+ typedef std::map<U8, LLMaterialPtr> map_te_material;
+ map_te_material new_material;
+
for(mmap_UUID_MAP_t::iterator range_it = range.first; range_it != range.second; ++range_it)
{
LLMaterialPtr cur_material = getTEMaterialParams(range_it->second.te);
if (cur_material.isNull())
continue;
- if (range_it->second.map == LLRender::DIFFUSE_MAP)
- {
- LLMaterialPtr cur_material = getTEMaterialParams(range_it->second.te);
- if (cur_material.notNull()
- && LLRender::DIFFUSE_MAP == range_it->second.map)
- {
- if (0 != cur_material->getDiffuseFormatPrimary())
- {
- cur_material->setDiffuseFormatPrimary(0);
- refresh_materials = true;
- }
- }
- }
- } //for
+ switch(range_it->second.map)
+ {
+ case LLRender::DIFFUSE_MAP:
+ {
+ if(LLMaterial::DIFFUSE_ALPHA_MODE_NONE != cur_material->getDiffuseAlphaMode())
+ { //missing texture + !LLMaterial::DIFFUSE_ALPHA_MODE_NONE => LLMaterial::DIFFUSE_ALPHA_MODE_NONE
+ LLMaterialPtr mat = NULL;
+ map_te_material::iterator it = new_material.find(range_it->second.te);
+ if(new_material.end() == it) {
+ mat = new LLMaterial(cur_material->asLLSD());
+ new_material.insert(map_te_material::value_type(range_it->second.te, mat));
+ } else {
+ mat = it->second;
+ }
- if (refresh_materials)
- {
- LLViewerObject::refreshMaterials();
- }
+ mat->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
+ }
+ } break;
+ case LLRender::NORMAL_MAP:
+ { //missing texture => reset material texture id
+ LLMaterialPtr mat = NULL;
+ map_te_material::iterator it = new_material.find(range_it->second.te);
+ if(new_material.end() == it) {
+ mat = new LLMaterial(cur_material->asLLSD());
+ new_material.insert(map_te_material::value_type(range_it->second.te, mat));
+ } else {
+ mat = it->second;
+ }
+
+ mat->setNormalID(LLUUID::null);
+ } break;
+ case LLRender::SPECULAR_MAP:
+ { //missing texture => reset material texture id
+ LLMaterialPtr mat = NULL;
+ map_te_material::iterator it = new_material.find(range_it->second.te);
+ if(new_material.end() == it) {
+ mat = new LLMaterial(cur_material->asLLSD());
+ new_material.insert(map_te_material::value_type(range_it->second.te, mat));
+ } else {
+ mat = it->second;
+ }
+
+ mat->setSpecularID(LLUUID::null);
+ } break;
+ case LLRender::NUM_TEXTURE_CHANNELS:
+ //nothing to do, make compiler happy
+ break;
+ } //switch
+ } //for
+
+ //setup new materials
+ for(map_te_material::const_iterator it = new_material.begin(), end = new_material.end(); it != end; ++it)
+ {
+ LLMaterialMgr::getInstance()->setLocalMaterial(getRegion()->getRegionID(), it->second);
+ LLViewerObject::setTEMaterialParams(it->first, it->second);
+ }
//clear wait-list
mWaitingTextureInfo.erase(range.first, range.second);
- return refresh_materials;
+ return 0 != new_material.size();
}
S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams)
{
- LLMaterialPtr material = pMaterialParams;
+ LLMaterialPtr pMaterial = const_cast<LLMaterialPtr&>(pMaterialParams);
- if (material.notNull())
- {
- LLTextureEntry* tex_entry = getTE(te);
- bool is_baked = tex_entry && LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(tex_entry->getID());
- material->setDiffuseBaked(is_baked);
+ if(pMaterialParams)
+ { //check all of them according to material settings
- LLViewerTexture *img_diffuse = getTEImage(te);
- llassert(NULL != img_diffuse);
+ LLViewerTexture *img_diffuse = getTEImage(te);
+ LLViewerTexture *img_normal = getTENormalMap(te);
+ LLViewerTexture *img_specular = getTESpecularMap(te);
- //diffuse
- if (!is_baked && NULL != img_diffuse)
- {
- if (0 == img_diffuse->getPrimaryFormat() && !img_diffuse->isMissingAsset())
- {
- // we don't have information about this texture, wait for it
- mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(img_diffuse->getID(), material_info(LLRender::DIFFUSE_MAP, te)));
- // Temporary assume RGBA image
- material->setDiffuseFormatPrimary(GL_RGBA);
- }
- else
- {
- if (img_diffuse->isMissingAsset())
- {
- material->setDiffuseFormatPrimary(0);
- }
- else
- {
- material->setDiffuseFormatPrimary(img_diffuse->getPrimaryFormat());
- }
- }
- }
- else
- {
- material->setDiffuseFormatPrimary(0);
- }
+ llassert(NULL != img_diffuse);
+
+ LLMaterialPtr new_material = NULL;
+
+ //diffuse
+ if(NULL != img_diffuse)
+ { //guard
+ if(0 == img_diffuse->getPrimaryFormat() && !img_diffuse->isMissingAsset())
+ { //ok here we don't have information about texture, let's belief and leave material settings
+ //but we remember this case
+ mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(img_diffuse->getID(), material_info(LLRender::DIFFUSE_MAP, te)));
+ }
+ else
+ {
+ bool bSetDiffuseNone = false;
+ if(img_diffuse->isMissingAsset())
+ {
+ bSetDiffuseNone = true;
+ }
+ else
+ {
+ switch(pMaterialParams->getDiffuseAlphaMode())
+ {
+ case LLMaterial::DIFFUSE_ALPHA_MODE_BLEND:
+ case LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE:
+ case LLMaterial::DIFFUSE_ALPHA_MODE_MASK:
+ { //all of them modes available only for 32 bit textures
+ LLTextureEntry* tex_entry = getTE(te);
+ bool bIsBakedImageId = false;
+ if (tex_entry && LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(tex_entry->getID()))
+ {
+ bIsBakedImageId = true;
+ }
+ if (GL_RGBA != img_diffuse->getPrimaryFormat() && !bIsBakedImageId)
+ {
+ bSetDiffuseNone = true;
+ }
+ } break;
+ }
+ } //else
+
+
+ if(bSetDiffuseNone)
+ { //upps... we should substitute this material with LLMaterial::DIFFUSE_ALPHA_MODE_NONE
+ new_material = new LLMaterial(pMaterialParams->asLLSD());
+ new_material->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
+ }
+ }
+ }
+
+ //normal
+ if(LLUUID::null != pMaterialParams->getNormalID())
+ {
+ if(img_normal && img_normal->isMissingAsset() && img_normal->getID() == pMaterialParams->getNormalID())
+ {
+ if(!new_material) {
+ new_material = new LLMaterial(pMaterialParams->asLLSD());
+ }
+ new_material->setNormalID(LLUUID::null);
+ }
+ else if(NULL == img_normal || 0 == img_normal->getPrimaryFormat())
+ { //ok here we don't have information about texture, let's belief and leave material settings
+ //but we remember this case
+ mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(pMaterialParams->getNormalID(), material_info(LLRender::NORMAL_MAP,te)));
+ }
+
+ }
+
+
+ //specular
+ if(LLUUID::null != pMaterialParams->getSpecularID())
+ {
+ if(img_specular && img_specular->isMissingAsset() && img_specular->getID() == pMaterialParams->getSpecularID())
+ {
+ if(!new_material) {
+ new_material = new LLMaterial(pMaterialParams->asLLSD());
+ }
+ new_material->setSpecularID(LLUUID::null);
+ }
+ else if(NULL == img_specular || 0 == img_specular->getPrimaryFormat())
+ { //ok here we don't have information about texture, let's belief and leave material settings
+ //but we remember this case
+ mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(pMaterialParams->getSpecularID(), material_info(LLRender::SPECULAR_MAP, te)));
+ }
+ }
+
+ if(new_material) {
+ pMaterial = new_material;
+ LLMaterialMgr::getInstance()->setLocalMaterial(getRegion()->getRegionID(), pMaterial);
+ }
}
- S32 res = LLViewerObject::setTEMaterialParams(te, material);
+ S32 res = LLViewerObject::setTEMaterialParams(te, pMaterial);
- LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((material) ? material->asLLSD() : LLSD("null")) << " res " << res
+ LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterial) ? pMaterial->asLLSD() : LLSD("null")) << " res " << res
<< ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast<LLVOVolume*>(this), te) ? " selected" : " not selected" )
<< LL_ENDL;
setChanged(ALL_CHANGED);
@@ -4482,7 +4599,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a&
LLMaterial* mat = te->getMaterialParams();
if (mat)
{
- U8 mode = mat->getDiffuseAlphaModeRender();
+ U8 mode = mat->getDiffuseAlphaMode();
if (mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE
|| mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE
@@ -5128,7 +5245,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
}
draw_info->mAlphaMaskCutoff = mat->getAlphaMaskCutoff() * (1.f / 255.f);
- draw_info->mDiffuseAlphaMode = mat->getDiffuseAlphaModeRender();
+ draw_info->mDiffuseAlphaMode = mat->getDiffuseAlphaMode();
draw_info->mNormalMap = facep->getViewerObject()->getTENormalMap(facep->getTEOffset());
}
else
@@ -5490,7 +5607,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
if (mat && LLPipeline::sRenderDeferred)
{
- U8 alpha_mode = mat->getDiffuseAlphaModeRender();
+ U8 alpha_mode = mat->getDiffuseAlphaMode();
bool is_alpha = type == LLDrawPool::POOL_ALPHA &&
(alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND ||
@@ -5519,7 +5636,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
else if (mat)
{
bool is_alpha = type == LLDrawPool::POOL_ALPHA;
- U8 mode = mat->getDiffuseAlphaModeRender();
+ U8 mode = mat->getDiffuseAlphaMode();
bool can_be_shiny = mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE ||
mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE;
@@ -6417,7 +6534,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
bool can_be_shiny = true;
if (mat)
{
- U8 mode = mat->getDiffuseAlphaModeRender();
+ U8 mode = mat->getDiffuseAlphaMode();
can_be_shiny = mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE ||
mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE;
}
@@ -6439,7 +6556,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
//
if (te->getFullbright())
{
- if (mat->getDiffuseAlphaModeRender() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
+ if (mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
{
if (opaque)
{
@@ -6524,7 +6641,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
}
else if (mat)
{
- U8 mode = mat->getDiffuseAlphaModeRender();
+ U8 mode = mat->getDiffuseAlphaMode();
is_alpha = (is_alpha || (mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND));
@@ -6623,7 +6740,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
}
else if (fullbright || bake_sunlight)
{ //fullbright
- if (mat && mat->getDiffuseAlphaModeRender() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
+ if (mat && mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
{
registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK);
}
@@ -6645,7 +6762,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
else
{ //all around simple
llassert(mask & LLVertexBuffer::MAP_NORMAL);
- if (mat && mat->getDiffuseAlphaModeRender() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
+ if (mat && mat->getDiffuseAlphaMode() == LLMaterial::DIFFUSE_ALPHA_MODE_MASK)
{ //material alpha mask can be respected in non-deferred
registerFace(group, facep, LLRenderPass::PASS_ALPHA_MASK);
}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c07a640ddf..15738c618c 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1677,7 +1677,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima
if (alpha && mat)
{
- switch (mat->getDiffuseAlphaModeRender())
+ switch (mat->getDiffuseAlphaMode())
{
case 1:
alpha = true; // Material's alpha mode is set to blend. Toss it into the alpha draw pool.