SO MUCH SCUFFEDNESS
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceOutputDescription
|
||||
{
|
||||
[UnityEngine.SerializeField]
|
||||
public string Identifier;
|
||||
|
||||
[UnityEngine.SerializeField]
|
||||
public string Label;
|
||||
|
||||
[UnityEngine.SerializeField]
|
||||
public int Index;
|
||||
|
||||
[UnityEngine.SerializeField]
|
||||
public SubstanceValueType Type;
|
||||
|
||||
[UnityEngine.SerializeField]
|
||||
public string Channel;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Identifier: {Identifier}\n" +
|
||||
$"Label:{Label}\n" +
|
||||
$"Index:{Index}\n" +
|
||||
$"Type:{Type}\n" +
|
||||
$"Channel{Channel}\n";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06fa5ea573078b642bf69b2798e26884
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceOutputTexture
|
||||
{
|
||||
[SerializeField]
|
||||
public int Index;
|
||||
|
||||
[SerializeField]
|
||||
public int VirtualOutputIndex;
|
||||
|
||||
[SerializeField]
|
||||
public SubstanceOutputDescription Description;
|
||||
|
||||
[SerializeField]
|
||||
public Texture2D OutputTexture;
|
||||
|
||||
[SerializeField]
|
||||
public bool sRGB;
|
||||
|
||||
[SerializeField]
|
||||
public bool IsVirtual;
|
||||
|
||||
[SerializeField]
|
||||
public bool IsAlphaAssignable;
|
||||
|
||||
[SerializeField]
|
||||
public string AlphaChannel;
|
||||
|
||||
[SerializeField]
|
||||
public bool InvertAssignedAlpha;
|
||||
|
||||
[SerializeField]
|
||||
public uint Flags = 0;
|
||||
|
||||
[SerializeField]
|
||||
public string MaterialTextureTarget;
|
||||
|
||||
public SubstanceOutputTexture(SubstanceOutputDescription description, string unityTextureName)
|
||||
{
|
||||
Index = description.Index;
|
||||
Description = description;
|
||||
MaterialTextureTarget = unityTextureName;
|
||||
|
||||
if (!string.IsNullOrEmpty(description.Channel))
|
||||
IsAlphaAssignable = !string.Equals(description.Channel, "normal", System.StringComparison.OrdinalIgnoreCase);
|
||||
else
|
||||
IsAlphaAssignable = false;
|
||||
|
||||
IsVirtual = false;
|
||||
sRGB = false;
|
||||
OutputTexture = null;
|
||||
AlphaChannel = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4eb2b73a785c95a4c87339cd11964fb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,102 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
public class SubstanceVirtualOutputChannelInfo
|
||||
{
|
||||
public uint ChannelSource { get; }
|
||||
|
||||
public ShuffleIndex Index { get; }
|
||||
|
||||
public bool Invert { get; }
|
||||
|
||||
private const uint SBSARIO_USE_DEFAULT = ~0u;
|
||||
|
||||
private const uint SBSARIO_COMPONENT_EMPTY = 0;
|
||||
|
||||
public SubstanceVirtualOutputChannelInfo(uint outputUID, ShuffleIndex index = ShuffleIndex.Red, bool invert = false)
|
||||
{
|
||||
ChannelSource = outputUID;
|
||||
Index = index;
|
||||
Invert = invert;
|
||||
}
|
||||
|
||||
internal NativeOutputFormatComponent CreateNativeComponent()
|
||||
{
|
||||
return new NativeOutputFormatComponent()
|
||||
{
|
||||
levelMax = Invert ? 0 : 1,
|
||||
levelMin = Invert ? 1 : 0,
|
||||
outputIndex = ChannelSource,
|
||||
ShuffleIndex = Index
|
||||
};
|
||||
}
|
||||
|
||||
public readonly static SubstanceVirtualOutputChannelInfo Default = new SubstanceVirtualOutputChannelInfo(SBSARIO_USE_DEFAULT);
|
||||
|
||||
public readonly static SubstanceVirtualOutputChannelInfo Black = new SubstanceVirtualOutputChannelInfo(SBSARIO_COMPONENT_EMPTY, ShuffleIndex.Red);
|
||||
|
||||
public static SubstanceVirtualOutputChannelInfo White = new SubstanceVirtualOutputChannelInfo(SBSARIO_COMPONENT_EMPTY, ShuffleIndex.Red, true);
|
||||
}
|
||||
|
||||
public class SubstanceVirtualOutputCreateInfo
|
||||
{
|
||||
public TextureFormat Format { get; }
|
||||
|
||||
public string Label { get; }
|
||||
|
||||
public TextureFlip FlipOption { get; }
|
||||
|
||||
public SubstanceVirtualOutputChannelInfo RedChannelSource { get; }
|
||||
|
||||
public SubstanceVirtualOutputChannelInfo GreenChannelSource { get; }
|
||||
|
||||
public SubstanceVirtualOutputChannelInfo BlueChannelSource { get; }
|
||||
|
||||
public SubstanceVirtualOutputChannelInfo AlphaChannelSource { get; }
|
||||
|
||||
public SubstanceVirtualOutputCreateInfo(TextureFormat format,
|
||||
string name,
|
||||
TextureFlip flip = TextureFlip.None,
|
||||
params SubstanceVirtualOutputChannelInfo[] channels)
|
||||
{
|
||||
Format = format;
|
||||
Label = name;
|
||||
FlipOption = flip;
|
||||
RedChannelSource = channels.Length > 0 ? channels[0] : SubstanceVirtualOutputChannelInfo.Default;
|
||||
GreenChannelSource = channels.Length > 1 ? channels[1] : SubstanceVirtualOutputChannelInfo.Default;
|
||||
BlueChannelSource = channels.Length > 2 ? channels[2] : SubstanceVirtualOutputChannelInfo.Default;
|
||||
AlphaChannelSource = channels.Length > 3 ? channels[3] : SubstanceVirtualOutputChannelInfo.Default;
|
||||
}
|
||||
|
||||
internal NativeOutputDesc CreateOutputDesc()
|
||||
{
|
||||
var labelPtr = Marshal.StringToHGlobalAnsi(Label);
|
||||
|
||||
return new NativeOutputDesc()
|
||||
{
|
||||
mLabel = labelPtr,
|
||||
mIdentifier = labelPtr,
|
||||
mValueType = ValueType.SBSARIO_VALUE_IMAGE,
|
||||
};
|
||||
}
|
||||
|
||||
internal NativeOutputFormat CreateOutputFormat()
|
||||
{
|
||||
var format = new NativeOutputFormat
|
||||
{
|
||||
hvFlip = FlipOption.ToSubstance(),
|
||||
format = (uint)Format.ToSubstance()
|
||||
};
|
||||
|
||||
format.ChannelComponent0 = RedChannelSource.CreateNativeComponent();
|
||||
format.ChannelComponent1 = GreenChannelSource.CreateNativeComponent();
|
||||
format.ChannelComponent2 = BlueChannelSource.CreateNativeComponent();
|
||||
format.ChannelComponent3 = AlphaChannelSource.CreateNativeComponent();
|
||||
return format;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9be437653642a947898654bbb857e27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user