using Newtonsoft.Json; using Siccity.GLTFUtility.Converters; using UnityEngine; using UnityEngine.Scripting; namespace Siccity.GLTFUtility { /// /// KHR_texture_transform textureInfo extension /// glTF extension that enables shifting and scaling UV coordinates on a per-texture basis /// see: https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/schema/KHR_texture_transform.textureInfo.schema.json /// [Preserve] public class KHR_texture_transform : GLTFMaterial.TextureInfo.IExtension { /// /// The offset of the UV coordinate origin as a factor of the texture dimensions. /// [JsonConverter(typeof(Vector2Converter))] public Vector2 offset = Vector2.zero; /// /// Rotate the UVs by this many radians counter-clockwise around the origin. /// public float rotation = 0.0f; /// /// The scale factor applied to the components of the UV coordinates. /// [JsonConverter(typeof(Vector2Converter))] public Vector2 scale = Vector2.one; /// /// Overrides the textureInfo texCoord value if supplied, and if this extension is supported. /// public int texCoord = 0; public void Apply(GLTFMaterial.TextureInfo texInfo, Material material, string textureSamplerName) { material.SetTextureOffset(textureSamplerName, offset); // TODO rotation material.SetTextureScale(textureSamplerName, scale); // TODO texCoord } } }