From 85470fc4d29cb2fd7d168debdeed3544778592b8 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 4 Oct 2023 16:56:49 -0700 Subject: SL-20396: Apply blinn-phong rotation to texture translation animations for GLTF materials, for more consistent behavior --- indra/newview/llvovolume.cpp | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 468943423a..f1d4d9039b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -666,7 +666,25 @@ void LLVOVolume::animateTextures() { if (!(result & LLViewerTextureAnim::ROTATE)) { - rot = 0.0f; + if (result & LLViewerTextureAnim::TRANSLATE) + { + // The current LSL texture animation system is + // based on Blinn-Phong texture transforms, which + // is incompatible with the GLTF texture + // transforms. As a compromise, apply Blinn-Phong + // texture rotation on top of the GLTF texture + // transforms during a translation animation. This + // ensures that the animation loops for trivial + // GLTF texture transforms, when it would for + // similar Blinn-Phong animations. This is not + // guaranteed to loop for nontrivial GLTF texture + // transforms. + te->getRotation(&rot); + } + else + { + rot = 0.0f; + } } if (!(result & LLViewerTextureAnim::TRANSLATE)) { @@ -679,29 +697,20 @@ void LLVOVolume::animateTextures() scale_t = 1.0f; } - // 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); + tex_mat.rotate(quat); LLMatrix4 mat; - LLVector3 scale(scale_s, scale_t, 1.f); + 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); - tex_mat.translate(LLVector3(0.5f, 0.5f, 0.f)); + LLVector3 trans; + trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); + tex_mat.translate(trans); } } } -- cgit v1.2.3 From 7297f0270473c1c42dcd44741eb38b4d1e8c6ac6 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 6 Oct 2023 11:08:44 -0700 Subject: SL-20396: On second thought, just apply the whole Blinn-Phong transform stack to PBR, but only during texture animations --- indra/newview/llvovolume.cpp | 107 ++++++++++--------------------------------- 1 file changed, 25 insertions(+), 82 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index f1d4d9039b..ec2f490742 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -619,8 +619,18 @@ void LLVOVolume::animateTextures() continue; } - LLGLTFMaterial *gltf_mat = te->getGLTFRenderMaterial(); - const bool is_pbr = gltf_mat != nullptr; + if (!(result & LLViewerTextureAnim::ROTATE)) + { + te->getRotation(&rot); + } + if (!(result & LLViewerTextureAnim::TRANSLATE)) + { + te->getOffset(&off_s,&off_t); + } + if (!(result & LLViewerTextureAnim::SCALE)) + { + te->getScale(&scale_s, &scale_t); + } if (!facep->mTextureMatrix) { @@ -629,89 +639,22 @@ void LLVOVolume::animateTextures() LLMatrix4& tex_mat = *facep->mTextureMatrix; tex_mat.setIdentity(); + LLVector3 trans ; - if (!is_pbr) - { - if (!(result & LLViewerTextureAnim::ROTATE)) - { - te->getRotation(&rot); - } - if (!(result & LLViewerTextureAnim::TRANSLATE)) - { - te->getOffset(&off_s,&off_t); - } - if (!(result & LLViewerTextureAnim::SCALE)) - { - te->getScale(&scale_s, &scale_t); - } - - 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)); - - 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 - { - if (!(result & LLViewerTextureAnim::ROTATE)) - { - if (result & LLViewerTextureAnim::TRANSLATE) - { - // The current LSL texture animation system is - // based on Blinn-Phong texture transforms, which - // is incompatible with the GLTF texture - // transforms. As a compromise, apply Blinn-Phong - // texture rotation on top of the GLTF texture - // transforms during a translation animation. This - // ensures that the animation loops for trivial - // GLTF texture transforms, when it would for - // similar Blinn-Phong animations. This is not - // guaranteed to loop for nontrivial GLTF texture - // transforms. - te->getRotation(&rot); - } - else - { - rot = 0.0f; - } - } - if (!(result & LLViewerTextureAnim::TRANSLATE)) - { - off_s = 0.0f; - off_t = 0.0f; - } - if (!(result & LLViewerTextureAnim::SCALE)) - { - scale_s = 1.0f; - scale_t = 1.0f; - } - - 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)); - 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 scale(scale_s, scale_t, 1.f); + LLQuaternion quat; + quat.setQuat(rot, 0, 0, -1.f); + + tex_mat.rotate(quat); - LLVector3 trans; - trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f)); - tex_mat.translate(trans); - } + LLMatrix4 mat; + mat.initAll(scale, LLQuaternion(), LLVector3()); + tex_mat *= mat; + + tex_mat.translate(trans); } } else -- cgit v1.2.3