summaryrefslogtreecommitdiff
path: root/indra/newview/gltf/primitive.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2024-06-10 16:57:31 -0500
committerGitHub <noreply@github.com>2024-06-10 16:57:31 -0500
commit4522f33d2bad2cc0f67e10a0b0ad3cc7c1b43fbd (patch)
treef2e020507f3240208e8d0b105f7e100a1e7aaf36 /indra/newview/gltf/primitive.cpp
parent4705362a332a2347510c81c8d00a1f607ad88af8 (diff)
#1677 Add GLTF extensions serialization and support for KHR_materials_unlit (#1686)
Diffstat (limited to 'indra/newview/gltf/primitive.cpp')
-rw-r--r--indra/newview/gltf/primitive.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/indra/newview/gltf/primitive.cpp b/indra/newview/gltf/primitive.cpp
index 8d9880951b..bc333aff69 100644
--- a/indra/newview/gltf/primitive.cpp
+++ b/indra/newview/gltf/primitive.cpp
@@ -313,6 +313,10 @@ bool Primitive::prep(Asset& asset)
// TODO: support colorless vertex buffers
mask |= LLVertexBuffer::MAP_COLOR;
+ mShaderVariant = 0;
+
+ bool unlit = false;
+
// bake material basecolor into color array
if (mMaterial != INVALID_INDEX)
{
@@ -322,11 +326,15 @@ bool Primitive::prep(Asset& asset)
{
dst = LLColor4U(baseColor * LLColor4(dst));
}
- }
- mShaderVariant = 0;
+ if (material.mUnlit.mPresent)
+ { // material uses KHR_materials_unlit
+ mShaderVariant |= LLGLSLShader::GLTFVariant::UNLIT;
+ unlit = true;
+ }
+ }
- if (mNormals.empty())
+ if (mNormals.empty() && !unlit)
{
mTangents.clear();
@@ -334,6 +342,7 @@ bool Primitive::prep(Asset& asset)
{ //no normals and no surfaces, this primitive is unlit
mTangents.clear();
mShaderVariant |= LLGLSLShader::GLTFVariant::UNLIT;
+ unlit = true;
}
else
{
@@ -350,8 +359,6 @@ bool Primitive::prep(Asset& asset)
}
}
- bool unlit = (mShaderVariant & LLGLSLShader::GLTFVariant::UNLIT) != 0;
-
if (mTangents.empty() && !unlit)
{ // NOTE: must be done last because tangent generation rewrites the other arrays
// adapted from usage of Mikktspace in llvolume.cpp
@@ -388,10 +395,13 @@ bool Primitive::prep(Asset& asset)
}
}
-
- if (!unlit)
+ if (!mNormals.empty())
{
mask |= LLVertexBuffer::MAP_NORMAL;
+ }
+
+ if (!mTangents.empty())
+ {
mask |= LLVertexBuffer::MAP_TANGENT;
}