mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-17 08:10:04 -05:00
48 lines
1.8 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|
|
} |