您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
86 行
2.4 KiB
86 行
2.4 KiB
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.ShaderGraph.Internal
|
|
{
|
|
[Serializable]
|
|
public abstract class AbstractShaderProperty : ShaderInput
|
|
{
|
|
public abstract PropertyType propertyType { get; }
|
|
|
|
internal override ConcreteSlotValueType concreteShaderValueType => propertyType.ToConcreteShaderValueType();
|
|
|
|
[SerializeField]
|
|
Precision m_Precision = Precision.Inherit;
|
|
|
|
[SerializeField]
|
|
private bool m_GPUInstanced = false;
|
|
|
|
public bool gpuInstanced
|
|
{
|
|
get { return m_GPUInstanced; }
|
|
set { m_GPUInstanced = value; }
|
|
}
|
|
|
|
ConcretePrecision m_ConcretePrecision = ConcretePrecision.Float;
|
|
|
|
internal Precision precision
|
|
{
|
|
get => m_Precision;
|
|
set => m_Precision = value;
|
|
}
|
|
|
|
public ConcretePrecision concretePrecision => m_ConcretePrecision;
|
|
|
|
internal void ValidateConcretePrecision(ConcretePrecision graphPrecision)
|
|
{
|
|
m_ConcretePrecision = (precision == Precision.Inherit) ? graphPrecision : precision.ToConcrete();
|
|
}
|
|
|
|
internal abstract bool isBatchable { get; }
|
|
|
|
[SerializeField]
|
|
bool m_Hidden = false;
|
|
|
|
public bool hidden
|
|
{
|
|
get => m_Hidden;
|
|
set => m_Hidden = value;
|
|
}
|
|
|
|
internal string hideTagString => hidden ? "[HideInInspector]" : "";
|
|
|
|
internal virtual string GetPropertyBlockString()
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
internal virtual string GetPropertyDeclarationString(string delimiter = ";")
|
|
{
|
|
SlotValueType type = ConcreteSlotValueType.Vector4.ToSlotValueType();
|
|
return $"{concreteShaderValueType.ToShaderString(concretePrecision.ToShaderString())} {referenceName}{delimiter}";
|
|
}
|
|
|
|
internal virtual string GetPropertyAsArgumentString()
|
|
{
|
|
return GetPropertyDeclarationString(string.Empty);
|
|
}
|
|
|
|
internal abstract AbstractMaterialNode ToConcreteNode();
|
|
internal abstract PreviewProperty GetPreviewMaterialProperty();
|
|
internal virtual bool isGpuInstanceable => false;
|
|
}
|
|
|
|
[Serializable]
|
|
public abstract class AbstractShaderProperty<T> : AbstractShaderProperty
|
|
{
|
|
[SerializeField]
|
|
T m_Value;
|
|
|
|
public virtual T value
|
|
{
|
|
get => m_Value;
|
|
set => m_Value = value;
|
|
}
|
|
}
|
|
}
|