summaryrefslogtreecommitdiff
path: root/indra/newview/llfetchedgltfmaterial.cpp
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/newview/llfetchedgltfmaterial.cpp
parent627e3d51c61778e07e350689ce68ede24afe61ab (diff)
SL-18908 Make media texture override base color and emissive texture on PBR materials when present.
Diffstat (limited to 'indra/newview/llfetchedgltfmaterial.cpp')
-rw-r--r--indra/newview/llfetchedgltfmaterial.cpp14
1 files changed, 9 insertions, 5 deletions
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
{