UniVRM/Assets/VRMShaders/GLTF/IO/Runtime/TextureExportParam.cs
Masataka SUMI 2ad014f11c Rename
2021-06-24 15:13:05 +09:00

48 lines
1.8 KiB
C#

using System;
using UnityEngine;
namespace VRMShaders
{
internal sealed class TextureExportParam
{
public TextureExportTypes ExportType { get; }
public ColorSpace ExportColorSpace { get; }
public Texture PrimaryTexture { get; }
public Texture SecondaryTexture { get; }
public float OptionFactor { get; }
public bool NeedsAlpha { get; set; }
public Func<Texture2D> Creator { get; set; }
public TextureExportParam(TextureExportTypes exportType, ColorSpace exportColorSpace, Texture primaryTexture, Texture secondaryTexture, float optionFactor, bool needsAlpha, Func<Texture2D> creator)
{
ExportType = exportType;
ExportColorSpace = exportColorSpace;
PrimaryTexture = primaryTexture;
SecondaryTexture = secondaryTexture;
OptionFactor = optionFactor;
NeedsAlpha = needsAlpha;
Creator = creator;
}
public bool EqualsAsKey(TextureExportParam other)
{
if (ExportType != other.ExportType) return false;
switch (ExportType)
{
case TextureExportTypes.Srgb:
case TextureExportTypes.Linear:
case TextureExportTypes.Normal:
return PrimaryTexture == other.PrimaryTexture;
case TextureExportTypes.OcclusionMetallicRoughness:
var primaryDifference = PrimaryTexture != other.PrimaryTexture ? 1 : 0;
var secondaryDifference = SecondaryTexture != other.SecondaryTexture ? 1 : 0;
var difference = primaryDifference + secondaryDifference;
return difference < 2;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}