summaryrefslogtreecommitdiff
path: root/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
authorcosmic-linden <111533034+cosmic-linden@users.noreply.github.com>2023-03-03 11:04:41 -0800
committerGitHub <noreply@github.com>2023-03-03 11:04:41 -0800
commit2020201ba6890feb9a31168c40e1ed14727fa719 (patch)
tree0341cbafdc5ac60ba1df02cb79152b1e0a9c19e3 /indra/newview/llvovolume.cpp
parentf92dddcf1fbf5e7c8e71afa783f2712d08b652cd (diff)
parent69f9e41019e424a9193164623fbc4f12407f1ca6 (diff)
Merge pull request #104 from secondlife/SL-19293
SL-19293: Use Blinn-Phong texture transform as hint for texture animation direction on PBR materials
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-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