summaryrefslogtreecommitdiff
path: root/indra/llprimitive/llgltfmaterial.cpp
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2022-10-31 09:42:27 -0700
committerCosmic Linden <cosmic@lindenlab.com>2022-11-02 12:55:18 -0700
commit9e7b725c15ea0bfea5246eb81dd7a100b7ac5b6b (patch)
treebbc065c955992f45933c0f9d83d61761121d589f /indra/llprimitive/llgltfmaterial.cpp
parentd042ad67ed4db72bf0265804e26610e565f15cf2 (diff)
SL-18485: Render GLTF materials with extension KHR_texture_transform with approprate texture transforms
Diffstat (limited to 'indra/llprimitive/llgltfmaterial.cpp')
-rw-r--r--indra/llprimitive/llgltfmaterial.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp
index 172cbdb7ce..649d4dbe8f 100644
--- a/indra/llprimitive/llgltfmaterial.cpp
+++ b/indra/llprimitive/llgltfmaterial.cpp
@@ -39,6 +39,28 @@ const char* GLTF_FILE_EXTENSION_TRANSFORM_ROTATION = "rotation";
// special UUID that indicates a null UUID in override data
static const LLUUID GLTF_OVERRIDE_NULL_UUID = LLUUID("ffffffff-ffff-ffff-ffff-ffffffffffff");
+// https://github.com/KhronosGroup/glTF/tree/main/extensions/3.0/Khronos/KHR_texture_transform
+LLMatrix3 LLGLTFMaterial::TextureTransform::asMatrix()
+{
+ LLMatrix3 scale;
+ scale.mMatrix[0][0] = mScale[0];
+ scale.mMatrix[1][1] = mScale[1];
+
+ LLMatrix3 rotation;
+ const F32 cos_r = cos(mRotation);
+ const F32 sin_r = sin(mRotation);
+ rotation.mMatrix[0][0] = cos_r;
+ rotation.mMatrix[0][1] = sin_r;
+ rotation.mMatrix[1][0] = -sin_r;
+ rotation.mMatrix[1][1] = cos_r;
+
+ LLMatrix3 offset;
+ offset.mMatrix[2][0] = mOffset[0];
+ offset.mMatrix[2][1] = mOffset[1];
+
+ return offset * rotation * scale;
+}
+
LLGLTFMaterial::LLGLTFMaterial(const LLGLTFMaterial& rhs)
{
*this = rhs;