mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-15 07:00:10 -05:00
invert texture origin
This commit is contained in:
parent
c4937d5b1e
commit
a5b4e907de
|
|
@ -182,12 +182,16 @@ namespace UniGLTF
|
|||
{
|
||||
if( textureInfo != null && m.HasProperty(propertyName))
|
||||
{
|
||||
var offset = m.GetTextureOffset(propertyName);
|
||||
var scale = m.GetTextureScale(propertyName);
|
||||
offset.y = (offset.y + scale.y - 1) * -1.0f;
|
||||
|
||||
textureInfo.extensions = new glTFTextureInfo_extensions
|
||||
{
|
||||
KHR_texture_transform = new glTF_KHR_texture_transform()
|
||||
{
|
||||
offset = new float[] { m.GetTextureOffset(propertyName).x, m.GetTextureOffset(propertyName).y },
|
||||
scale = new float[] { m.GetTextureScale(propertyName).x, m.GetTextureScale(propertyName).y },
|
||||
offset = new float[] { offset.x, offset.y },
|
||||
scale = new float[] { scale.x, scale.y },
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,16 +293,21 @@ namespace UniGLTF
|
|||
if (textureInfo.extensions != null && textureInfo.extensions.KHR_texture_transform != null)
|
||||
{
|
||||
var textureTransform = textureInfo.extensions.KHR_texture_transform;
|
||||
Vector2 offset = new Vector2(0, 0);
|
||||
Vector2 scale = new Vector2(1, 1);
|
||||
if (textureTransform.offset != null && textureTransform.offset.Length == 2)
|
||||
{
|
||||
material.SetTextureOffset(propertyName,
|
||||
new Vector2(textureTransform.offset[0], textureTransform.offset[1]));
|
||||
offset = new Vector2(textureTransform.offset[0], textureTransform.offset[1]);
|
||||
}
|
||||
if (textureTransform.scale != null && textureTransform.scale.Length == 2)
|
||||
{
|
||||
material.SetTextureScale(propertyName,
|
||||
new Vector2(textureTransform.scale[0], textureTransform.scale[1]));
|
||||
scale = new Vector2(textureTransform.scale[0], textureTransform.scale[1]);
|
||||
}
|
||||
|
||||
offset.y = (offset.y + scale.y - 1.0f) * -1.0f;
|
||||
|
||||
material.SetTextureOffset(propertyName, offset);
|
||||
material.SetTextureScale(propertyName, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user