// SPDX-FileCopyrightText: 2023 Unity Technologies and the KTX for Unity authors
// SPDX-License-Identifier: Apache-2.0
namespace KtxUnity
{
///
/// See Section 5.2 in https://registry.khronos.org/KTX/specs/2.0/ktxspec.v2.html#_ktxorientation
///
[System.Flags]
public enum TextureOrientation
{
///
/// KTX defaults to X=right Y=down Z=out
///
KtxDefault = 0x0,
///
/// If present X=left, else X=right
///
XLeft = 0x1,
///
/// If present Y=up, else Y=down
///
YUp = 0x2,
///
/// If present Z=in, else Z=out
///
ZIn = 0x4, // Not used at the moment
///
/// Unity expects GPU textures to be X=right Y=up
///
UnityDefault = YUp,
}
///
/// Extensions to check if a texture's orientation conforms to Unity's default.
///
public static class TextureOrientationExtension
{
///
/// Evaluates if the texture's horizontal orientation conforms to Unity's default.
/// If it's not aligned (=true; =flipped), the texture has to be applied mirrored horizontally.
///
///
/// True if the horizontal orientation is flipped, false otherwise
public static bool IsXFlipped(this TextureOrientation to)
{
// Unity default == X_RIGHT
return (to & TextureOrientation.XLeft) != 0;
}
///
/// Evaluates if the texture's vertical orientation conforms to Unity's default.
/// If it's not aligned (=true; =flipped), the texture has to be applied mirrored vertically.
///
///
/// True if the vertical orientation is flipped, false otherwise
public static bool IsYFlipped(this TextureOrientation to)
{
// Unity default == Y_UP
return (to & TextureOrientation.YUp) == 0;
}
}
}