summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2023-03-02 16:22:46 -0800
committerCosmic Linden <cosmic@lindenlab.com>2023-03-02 16:22:46 -0800
commit69f9e41019e424a9193164623fbc4f12407f1ca6 (patch)
tree4381b5633408e18e02428011c12f639a4f6296cf /indra
parentdc7ad02aa577bb572e8bf9d7f39a55de5cd2adef (diff)
SL-19293: Use Blinn-Phong texture transform as hint for texture animation direction on PBR materials
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llvovolume.cpp68
1 files changed, 47 insertions, 21 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 2eb3db6765..853c580964 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -628,6 +628,14 @@ void LLVOVolume::animateTextures()
LLGLTFMaterial *gltf_mat = te->getGLTFRenderMaterial();
const bool is_pbr = gltf_mat != nullptr;
+ if (!facep->mTextureMatrix)
+ {
+ facep->mTextureMatrix = new LLMatrix4();
+ }
+
+ LLMatrix4& tex_mat = *facep->mTextureMatrix;
+ tex_mat.setIdentity();
+
if (!is_pbr)
{
if (!(result & LLViewerTextureAnim::ROTATE))
@@ -642,32 +650,50 @@ void LLVOVolume::animateTextures()
{
te->getScale(&scale_s, &scale_t);
}
- }
- if (!facep->mTextureMatrix)
- {
- facep->mTextureMatrix = new LLMatrix4();
- }
+ LLVector3 trans ;
- LLMatrix4& tex_mat = *facep->mTextureMatrix;
- tex_mat.setIdentity();
-
- LLVector3 trans ;
+ trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f));
+ tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f));
- trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f));
- tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f));
+ LLVector3 scale(scale_s, scale_t, 1.f);
+ LLQuaternion quat;
+ quat.setQuat(rot, 0, 0, -1.f);
+
+ tex_mat.rotate(quat);
- LLVector3 scale(scale_s, scale_t, 1.f);
- LLQuaternion quat;
- quat.setQuat(rot, 0, 0, -1.f);
-
- tex_mat.rotate(quat);
+ LLMatrix4 mat;
+ mat.initAll(scale, LLQuaternion(), LLVector3());
+ tex_mat *= mat;
+
+ tex_mat.translate(trans);
+ }
+ else
+ {
+ // For PBR materials, use Blinn-Phong rotation as hint for
+ // translation direction. In a Blinn-Phong material, the
+ // translation direction would be a byproduct the texture
+ // transform.
+ F32 rot_frame;
+ te->getRotation(&rot_frame);
+
+ tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f));
+
+ LLQuaternion quat;
+ quat.setQuat(rot, 0, 0, -1.f);
+ tex_mat.rotate(quat);
+
+ LLMatrix4 mat;
+ LLVector3 scale(scale_s, scale_t, 1.f);
+ mat.initAll(scale, LLQuaternion(), LLVector3());
+ tex_mat *= mat;
+
+ LLVector3 off(off_s, off_t, 0.f);
+ off.rotVec(rot_frame, 0, 0, 1.f);
+ tex_mat.translate(off);
- LLMatrix4 mat;
- mat.initAll(scale, LLQuaternion(), LLVector3());
- tex_mat *= mat;
-
- tex_mat.translate(trans);
+ tex_mat.translate(LLVector3(0.5f, 0.5f, 0.f));
+ }
}
}
else