Skip to content

Commit

Permalink
added uv channel export
Browse files Browse the repository at this point in the history
  • Loading branch information
pfcDorn committed Aug 10, 2023
1 parent a841b57 commit a15bdb7
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ private void ExportTextureTransform(TextureInfo def, Material mat, string texNam
//var rotationMatrix = mat.GetVector(texName + "Rotation");
//var rotation = -Mathf.Atan2(offset.y, rotationMatrix.x);
var rotProp = texName + "Rotation";
var uvProp = texName + "TexCoord";
var rotation = 0f;
var uvChannel = 0f;

#if UNITY_2021_1_OR_NEWER
if (mat.HasFloat(rotProp))
#else
Expand All @@ -423,6 +426,19 @@ private void ExportTextureTransform(TextureInfo def, Material mat, string texNam
#endif
rotation = mat.GetFloat(rotProp);

#if UNITY_2021_1_OR_NEWER
if (mat.HasFloat(uvProp))
#else
if (mat.HasProperty(uvProp)
#if UNITY_2019_1_OR_NEWER
&& CheckForPropertyInShader(mat.shader, uvProp, ShaderPropertyType.Float)
#endif
)
#endif
uvChannel = mat.GetFloat(uvProp);



if (offset == Vector2.zero && scale == Vector2.one && rotation == 0)
{
var checkForName = texName + "_ST";
Expand Down Expand Up @@ -520,7 +536,7 @@ private void ExportTextureTransform(TextureInfo def, Material mat, string texNam
new GLTF.Math.Vector2(offset.x, 1 - offset.y - scale.y),
rotation,
new GLTF.Math.Vector2(scale.x, scale.y),
0 // TODO: support UV channels
(int)uvChannel
);
}

Expand Down

0 comments on commit a15bdb7

Please sign in to comment.