diff options
author | Dave Parks <davep@lindenlab.com> | 2022-10-19 17:23:54 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-10-19 17:23:54 -0500 |
commit | 8741c05cc10d3f39f272bb4739e7313309539d07 (patch) | |
tree | 871d2340a7e22cce1504948a79a703811a084d5a /indra/llprimitive | |
parent | de4c018499ddaebbe466fb5a8938554a2d4a3b19 (diff) |
SL-18105 Hook up TE override material to render pipe by way of render material.
Diffstat (limited to 'indra/llprimitive')
-rw-r--r-- | indra/llprimitive/llgltfmaterial.cpp | 25 | ||||
-rw-r--r-- | indra/llprimitive/llgltfmaterial.h | 3 | ||||
-rw-r--r-- | indra/llprimitive/lltextureentry.cpp | 19 | ||||
-rw-r--r-- | indra/llprimitive/lltextureentry.h | 13 |
4 files changed, 53 insertions, 7 deletions
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index 19081cd76f..b9ef2de61a 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -446,3 +446,28 @@ void LLGLTFMaterial::writeOverridesToModel(tinygltf::Model& model, S32 mat_index material_out.doubleSided = mDoubleSided; } } + +void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat) +{ + if (override_mat.mBaseColorId != getDefaultBaseColorId()) + { + mBaseColorId = override_mat.mBaseColorId; + } + + if (override_mat.mNormalId != getDefaultNormalId()) + { + mNormalId = override_mat.mNormalId; + } + + if (override_mat.mMetallicRoughnessId != getDefaultMetallicRoughnessId()) + { + mMetallicRoughnessId = override_mat.mMetallicRoughnessId; + } + + if (override_mat.mEmissiveId != getDefaultEmissiveId()) + { + mEmissiveId = override_mat.mEmissiveId; + } + + //TODO -- implement non texture parameters +} diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index 9c82f08805..32695d92f4 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -174,5 +174,8 @@ public: // calculate the fields in this material that differ from a base material and write them out to a given tinygltf::Model void writeOverridesToModel(tinygltf::Model& model, S32 mat_index, LLGLTFMaterial const* base_material) const; + + void applyOverride(const LLGLTFMaterial& override_mat); + }; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 284dfc15f4..e185404ada 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -491,6 +491,25 @@ S32 LLTextureEntry::setBumpShiny(U8 bump_shiny) return TEM_CHANGE_NONE; } +void LLTextureEntry::setGLTFMaterial(LLGLTFMaterial* material) +{ + mGLTFMaterial = material; + if (mGLTFMaterial == nullptr) + { + setGLTFRenderMaterial(nullptr); + } +} + +S32 LLTextureEntry::setGLTFRenderMaterial(LLGLTFMaterial* mat) +{ + if (mGLTFRenderMaterial != mat) + { + mGLTFRenderMaterial = mat; + return TEM_CHANGE_TEXTURE; + } + return TEM_CHANGE_NONE; +} + S32 LLTextureEntry::setMediaFlags(U8 media_flags) { media_flags &= TEM_MEDIA_MASK; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index bb74d258fd..2c932a10df 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -163,8 +163,6 @@ public: const LLMaterialID& getMaterialID() const { return mMaterialID; }; const LLMaterialPtr getMaterialParams() const { return mMaterial; }; - LLGLTFMaterial* getGLTFMaterial() const { return mGLTFMaterial; } - // *NOTE: it is possible for hasMedia() to return true, but getMediaData() to return NULL. // CONVERSELY, it is also possible for hasMedia() to return false, but getMediaData() // to NOT return NULL. @@ -197,16 +195,17 @@ public: enum { MF_NONE = 0x0, MF_HAS_MEDIA = 0x1 }; // GLTF asset - void setGLTFMaterial(LLGLTFMaterial* material) { mGLTFMaterial = material; } - LLGLTFMaterial* getGLTFMaterial() { return mGLTFMaterial; } + void setGLTFMaterial(LLGLTFMaterial* material); + LLGLTFMaterial* getGLTFMaterial() const { return mGLTFMaterial; } // GLTF override LLGLTFMaterial* getGLTFMaterialOverride() { return mGLTFMaterialOverrides; } void setGLTFMaterialOverride(LLGLTFMaterial* mat) { mGLTFMaterialOverrides = mat; } - // GLTF render - LLGLTFMaterial* getGLTFRenderMaterial() { return mGLTFRenderMaterial; } - void setGLTFRenderMaterial(LLGLTFMaterial* mat) { mGLTFRenderMaterial = mat; } + // GLTF render material + // nuanced behavior here -- if there is no render material, fall back to getGLTFMaterial, but ONLY for the getter, not the setter + LLGLTFMaterial* getGLTFRenderMaterial() const { return mGLTFRenderMaterial.notNull() ? mGLTFRenderMaterial : getGLTFMaterial(); } + S32 setGLTFRenderMaterial(LLGLTFMaterial* mat); public: F32 mScaleS; // S, T offset |