summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPtolemy <ptolemy@lindenlab.com>2022-06-23 14:43:58 -0700
committerPtolemy <ptolemy@lindenlab.com>2022-06-23 14:43:58 -0700
commitc68e469d88f2817ee49bbf23ffe5207c432e3c45 (patch)
tree19002264566158631bfabb25c0082b449a7e20f3
parentb5867cf5e663f3308a914600d71d09868142dedf (diff)
parentbeb763c4a0b657de40cd7c02734b70babfccc26b (diff)
Merge branch 'DRTVWR-559' of bitbucket.org:lindenlab/viewer into DRTVWR-559
-rw-r--r--indra/llprimitive/CMakeLists.txt1
-rw-r--r--indra/llprimitive/llgltfmaterial.h89
-rw-r--r--indra/newview/pipeline.cpp5
3 files changed, 95 insertions, 0 deletions
diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt
index e131b12371..bb14bb9242 100644
--- a/indra/llprimitive/CMakeLists.txt
+++ b/indra/llprimitive/CMakeLists.txt
@@ -52,6 +52,7 @@ set(llprimitive_HEADER_FILES
CMakeLists.txt
lldaeloader.h
llgltfloader.h
+ llgltfmaterial.h
legacy_object_types.h
llmaterial.h
llmaterialid.h
diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h
new file mode 100644
index 0000000000..2df4883a3c
--- /dev/null
+++ b/indra/llprimitive/llgltfmaterial.h
@@ -0,0 +1,89 @@
+/**
+ * @file llgltfmaterial.h
+ * @brief Material definition
+ *
+ * $LicenseInfo:firstyear=2022&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2022, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#pragma once
+
+#include "llrefcount.h"
+#include "v4color.h"
+#include "v3color.h"
+#include "lluuid.h"
+#include "llmd5.h"
+
+class LLGLTFMaterial : public LLRefCount
+{
+public:
+
+ enum AlphaMode
+ {
+ ALPHA_MODE_OPAQUE = 0,
+ ALPHA_MODE_BLEND,
+ ALPHA_MODE_MASK
+ };
+
+ LLUUID mAlbedoId;
+ LLUUID mNormalId;
+ LLUUID mMetallicRoughnessId;
+ LLUUID mEmissiveId;
+
+ LLColor4 mAlbedoColor = LLColor4(1,1,1,1);
+ LLColor3 mEmissiveColor = LLColor3(0,0,0);
+
+ F32 mMetallicFactor = 0.f;
+ F32 mRoughnessFactor = 0.f;
+ bool mDoubleSided = false;
+ AlphaMode mAlphaMode = ALPHA_MODE_OPAQUE;
+
+ // get a UUID based on a hash of this LLGLTFMaterial
+ LLUUID getHash() const
+ {
+ LLMD5 md5;
+ md5.update((unsigned char*) this, sizeof(this));
+ LLUUID id;
+ md5.raw_digest(id.mData);
+ return id;
+ }
+
+ // set mAlphaMode from string.
+ // Anything otherthan "MASK" or "BLEND" sets mAlphaMode to ALPHA_MODE_OPAQUE
+ void setAlphaMode(const std::string& mode)
+ {
+ if (mode == "MASK")
+ {
+ mAlphaMode = ALPHA_MODE_MASK;
+ }
+ else if (mode == "BLEND")
+ {
+ mAlphaMode = ALPHA_MODE_BLEND;
+ }
+ else
+ {
+ mAlphaMode = ALPHA_MODE_OPAQUE;
+ }
+ }
+};
+
+
+
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 21171701e1..82a5b28576 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1651,6 +1651,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima
}
LLMaterial* mat = te->getMaterialParams().get();
+ LLGLTFMaterial* gltf_mat = te->getGLTFMaterial();
bool color_alpha = te->getColor().mV[3] < 0.999f;
bool alpha = color_alpha;
@@ -1684,6 +1685,10 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima
{
return LLDrawPool::POOL_BUMP;
}
+ else if (gltf_mat && !alpha)
+ {
+ return LLDrawPool::POOL_PBR_OPAQUE;
+ }
else if (mat && !alpha)
{
return LLDrawPool::POOL_MATERIALS;