summaryrefslogtreecommitdiff
path: root/indra/newview/llfetchedgltfmaterial.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-01-08 21:33:06 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-01-08 21:33:06 +0200
commitafe91b7eb68da65687beef451bd094ff0091b717 (patch)
tree5bdb9e5b5a78a16a8c1362c33717a6931fb40458 /indra/newview/llfetchedgltfmaterial.cpp
parent6e6df8c31e09e6ba69156150ecd37cc4ac4ea0e6 (diff)
parent77395eddc911e0801e50fd693f7bbaee8046aa95 (diff)
Merge main (DRTVWR-596 GLTF Materials Maint) into DRTVWR-591-maint-X
# Conflicts: # indra/newview/VIEWER_VERSION.txt
Diffstat (limited to 'indra/newview/llfetchedgltfmaterial.cpp')
-rw-r--r--indra/newview/llfetchedgltfmaterial.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp
index 1a47293523..46b9dffae9 100644
--- a/indra/newview/llfetchedgltfmaterial.cpp
+++ b/indra/newview/llfetchedgltfmaterial.cpp
@@ -29,6 +29,8 @@
#include "llviewertexturelist.h"
#include "llavatarappearancedefines.h"
+#include "llviewerobject.h"
+#include "llselectmgr.h"
#include "llshadermgr.h"
#include "pipeline.h"
@@ -252,3 +254,55 @@ void LLFetchedGLTFMaterial::materialComplete()
materialCompleteCallbacks.clear();
materialCompleteCallbacks.shrink_to_fit();
}
+
+LLPointer<LLViewerFetchedTexture> LLFetchedGLTFMaterial::getUITexture()
+{
+ if (mFetching)
+ {
+ return nullptr;
+ }
+
+ auto fetch_texture_for_ui = [](LLPointer<LLViewerFetchedTexture>& img, const LLUUID& id)
+ {
+ if (id.notNull())
+ {
+ if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(id))
+ {
+ LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
+ if (obj)
+ {
+ LLViewerTexture* viewerTexture = obj->getBakedTextureForMagicId(id);
+ img = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : NULL;
+ }
+
+ }
+ else
+ {
+ img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
+ }
+ }
+ if (img)
+ {
+ img->setBoostLevel(LLGLTexture::BOOST_PREVIEW);
+ img->forceToSaveRawImage(0);
+ }
+ };
+
+ fetch_texture_for_ui(mBaseColorTexture, mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR]);
+ fetch_texture_for_ui(mNormalTexture, mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL]);
+ fetch_texture_for_ui(mMetallicRoughnessTexture, mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS]);
+ fetch_texture_for_ui(mEmissiveTexture, mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE]);
+
+ if ((mBaseColorTexture && (mBaseColorTexture->getRawImageLevel() != 0)) ||
+ (mNormalTexture && (mNormalTexture->getRawImageLevel() != 0)) ||
+ (mMetallicRoughnessTexture && (mMetallicRoughnessTexture->getRawImageLevel() != 0)) ||
+ (mEmissiveTexture && (mEmissiveTexture->getRawImageLevel() != 0)))
+ {
+ return nullptr;
+ }
+
+ // *HACK: Use one of the PBR texture components as the preview texture for now
+ mPreviewTexture = mBaseColorTexture;
+
+ return mPreviewTexture;
+}