summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-02-02 14:35:09 -0600
committerDave Parks <davep@lindenlab.com>2023-02-02 14:35:09 -0600
commit93b1da52f56293663d9bfe5272a83a77185f4cff (patch)
tree94a9e3da998bdc38d06cb707d1bb155f1f76b814 /indra
parent627e3d51c61778e07e350689ce68ede24afe61ab (diff)
SL-18908 Make media texture override base color and emissive texture on PBR materials when present.
Diffstat (limited to 'indra')
-rw-r--r--indra/llprimitive/llgltfmaterial.h12
-rw-r--r--indra/llprimitive/llmaterial.cpp8
-rw-r--r--indra/newview/lldrawpool.cpp4
-rw-r--r--indra/newview/lldrawpoolalpha.cpp2
-rw-r--r--indra/newview/llface.cpp2
-rw-r--r--indra/newview/llfetchedgltfmaterial.cpp14
-rw-r--r--indra/newview/llfetchedgltfmaterial.h3
-rw-r--r--indra/newview/llvovolume.cpp5
8 files changed, 26 insertions, 24 deletions
diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h
index dec7b696f8..2bd2d34b53 100644
--- a/indra/llprimitive/llgltfmaterial.h
+++ b/indra/llprimitive/llgltfmaterial.h
@@ -33,7 +33,7 @@
#include "v3color.h"
#include "v2math.h"
#include "lluuid.h"
-#include "llmd5.h"
+#include "hbxxh.h"
#include <string>
@@ -98,12 +98,10 @@ public:
LLUUID getHash() const
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- LLMD5 md5;
- md5.update((unsigned char*)this, sizeof(this));
- md5.finalize();
- LLUUID id;
- md5.raw_digest(id.mData);
- return id;
+ // HACK - hash the bytes of this object but don't include the ref count
+ LLUUID hash;
+ HBXXH128::digest(hash, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32));
+ return hash;
}
enum TextureInfo : U32
diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp
index 0ab97a0df3..a694a666c6 100644
--- a/indra/llprimitive/llmaterial.cpp
+++ b/indra/llprimitive/llmaterial.cpp
@@ -27,7 +27,7 @@
#include "linden_common.h"
#include "llmaterial.h"
-#include "llmd5.h"
+#include "hbxxh.h"
/**
* Materials cap parameters
@@ -479,13 +479,9 @@ U32 LLMaterial::getShaderMask(U32 alpha_mode)
LLUUID LLMaterial::getHash() const
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- LLMD5 md5;
// HACK - hash the bytes of this LLMaterial, but trim off the S32 in LLRefCount
- md5.update((unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32));
- md5.finalize();
LLUUID id;
- md5.raw_digest(id.mData);
- // *TODO: Hash the overrides
+ HBXXH128::digest(id, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32));
return id;
}
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index a5990492b1..e35e889a69 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -458,7 +458,7 @@ void LLRenderPass::pushGLTFBatches(U32 type)
auto& mat = params.mGLTFMaterial;
- mat->bind();
+ mat->bind(params.mTexture);
LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0);
@@ -489,7 +489,7 @@ void LLRenderPass::pushRiggedGLTFBatches(U32 type)
auto& mat = params.mGLTFMaterial;
- mat->bind();
+ mat->bind(params.mTexture);
LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0);
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 4c8d32fad2..d3d5235770 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -679,7 +679,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged)
gPipeline.bindDeferredShaderFast(*target_shader);
}
- params.mGLTFMaterial->bind();
+ params.mGLTFMaterial->bind(params.mTexture);
}
else
{
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 811f475705..45e7709409 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -362,7 +362,7 @@ void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture)
if (ch == LLRender::DIFFUSE_MAP)
{
- getViewerObject()->changeTEImage(mTEOffset, new_texture) ;
+ getViewerObject()->changeTEImage(mTEOffset, new_texture) ;
}
setTexture(ch, new_texture) ;
diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp
index 047f1a4965..003b373e50 100644
--- a/indra/newview/llfetchedgltfmaterial.cpp
+++ b/indra/newview/llfetchedgltfmaterial.cpp
@@ -46,7 +46,7 @@ LLFetchedGLTFMaterial::~LLFetchedGLTFMaterial()
}
-void LLFetchedGLTFMaterial::bind()
+void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex)
{
// glTF 2.0 Specification 3.9.4. Alpha Coverage
// mAlphaCutoff is only valid for LLGLTFMaterial::ALPHA_MODE_MASK
@@ -54,15 +54,19 @@ void LLFetchedGLTFMaterial::bind()
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
+ // override emissive and base color textures with media tex if present
+ LLViewerTexture* baseColorTex = media_tex ? media_tex : mBaseColorTexture;
+ LLViewerTexture* emissiveTex = media_tex ? media_tex : mEmissiveTexture;
+
if (mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK)
{
min_alpha = mAlphaCutoff;
}
shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha);
- if (mBaseColorTexture.notNull())
+ if (baseColorTex != nullptr)
{
- gGL.getTexUnit(0)->bindFast(mBaseColorTexture);
+ gGL.getTexUnit(0)->bindFast(baseColorTex);
}
else
{
@@ -89,9 +93,9 @@ void LLFetchedGLTFMaterial::bind()
shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep);
}
- if (mEmissiveTexture.notNull())
+ if (emissiveTex != nullptr)
{
- shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, mEmissiveTexture); // PBR sRGB Emissive
+ shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, emissiveTex); // PBR sRGB Emissive
}
else
{
diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h
index f784f19c4f..96f7fbea8e 100644
--- a/indra/newview/llfetchedgltfmaterial.h
+++ b/indra/newview/llfetchedgltfmaterial.h
@@ -43,7 +43,8 @@ public:
void onMaterialComplete(std::function<void()> material_complete);
// bind this material for rendering
- void bind();
+ // media_tex - optional media texture that may override the base color texture
+ void bind(LLViewerTexture* media_tex = nullptr);
// Textures used for fetching/rendering
LLPointer<LLViewerFetchedTexture> mBaseColorTexture;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 02d1654878..c9fbe680c7 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -5220,13 +5220,16 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
if (gltf_mat != nullptr)
{
mat_id = gltf_mat->getHash(); // TODO: cache this hash
+ if (!facep->hasMedia())
+ { // no media texture, face texture will be unused
+ tex = nullptr;
+ }
}
else
{
mat = facep->getTextureEntry()->getMaterialParams().get();
if (mat)
{
- //mat_id = facep->getTextureEntry()->getMaterialID().asUUID();
mat_id = facep->getTextureEntry()->getMaterialParams()->getHash();
}
}