2 using System.Collections.Generic;
3 using UnityEditor.Graphing;
4 using UnityEditor.ShaderGraph.Drawing.Slots;
6 using UnityEngine.UIElements;
8 namespace UnityEditor.ShaderGraph
11 class Matrix3MaterialSlot : MaterialSlot, IMaterialSlotHasValue<Matrix4x4>
14 private Matrix4x4 m_Value = Matrix4x4.identity;
17 private Matrix4x4 m_DefaultValue = Matrix4x4.identity;
19 public Matrix3MaterialSlot()
23 public Matrix3MaterialSlot(
26 string shaderOutputName,
28 ShaderStageCapability stageCapability = ShaderStageCapability.All,
30 : base(slotId, displayName, shaderOutputName, slotType, stageCapability, hidden)
34 public override VisualElement InstantiateControl()
36 return new LabelSlotControlView("Identity");
39 public Matrix4x4 defaultValue { get { return m_DefaultValue; } }
41 public Matrix4x4 value
43 get { return m_Value; }
44 set { m_Value = value; }
47 protected override string ConcreteSlotValueAsVariable()
49 return "$precision3x3 (1,0,0,0,1,0,0,0,1)";
52 public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)
54 if (!generationMode.IsPreview())
57 var matOwner = owner as AbstractMaterialNode;
59 throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode)));
61 var property = new Matrix3ShaderProperty()
63 overrideReferenceName = matOwner.GetVariableNameForSlot(id),
64 generatePropertyBlock = false,
67 properties.AddShaderProperty(property);
70 public override void GetPreviewProperties(List<PreviewProperty> properties, string name)
72 var pp = new PreviewProperty(PropertyType.Matrix3)
80 public override SlotValueType valueType { get { return SlotValueType.Matrix3; } }
81 public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Matrix3; } }
83 public override void CopyValuesFrom(MaterialSlot foundSlot)
85 var slot = foundSlot as Matrix3MaterialSlot;