1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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;
- }
- }
- }
|