SL-19269: For PBR materials, apply texture animation independently of the underlying texture transform
parent
33085b9d83
commit
7a533f3682
|
|
@ -62,13 +62,14 @@ vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf
|
|||
{
|
||||
vec2 texcoord = vertex_texcoord;
|
||||
|
||||
// Apply texture animation first to avoid shearing and other artifacts
|
||||
texcoord = (sl_animation_transform * vec4(texcoord, 0, 1)).xy;
|
||||
// Convert to left-handed coordinate system. The offset of 1 is necessary
|
||||
// for rotations to be applied correctly.
|
||||
texcoord.y = 1.0 - texcoord.y;
|
||||
texcoord = khr_texture_transform(texcoord, khr_gltf_scale, khr_gltf_rotation, khr_gltf_offset);
|
||||
// Convert back to right-handed coordinate system
|
||||
texcoord.y = 1.0 - texcoord.y;
|
||||
texcoord = (sl_animation_transform * vec4(texcoord, 0, 1)).xy;
|
||||
|
||||
// To make things more confusing, all SL image assets are upside-down
|
||||
// We may need an additional sign flip here when we implement a Vulkan backend
|
||||
|
|
|
|||
|
|
@ -625,18 +625,24 @@ void LLVOVolume::animateTextures()
|
|||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
LLGLTFMaterial *gltf_mat = te->getGLTFRenderMaterial();
|
||||
const bool is_pbr = gltf_mat != nullptr;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (!facep->mTextureMatrix)
|
||||
{
|
||||
|
|
@ -645,6 +651,7 @@ void LLVOVolume::animateTextures()
|
|||
|
||||
LLMatrix4& tex_mat = *facep->mTextureMatrix;
|
||||
tex_mat.setIdentity();
|
||||
|
||||
LLVector3 trans ;
|
||||
|
||||
trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f));
|
||||
|
|
|
|||
Loading…
Reference in New Issue