using UnityEditor.Graphing; using UnityEngine; namespace UnityEditor.ShaderGraph { [Title("Input", "Scene", "Object")] public sealed class ObjectNode : AbstractMaterialNode { const string kOutputSlotName = "Position"; const string kOutputSlot1Name = "Scale"; public const int OutputSlotId = 0; public const int OutputSlot1Id = 1; public ObjectNode() { name = "Object"; UpdateNodeAfterDeserialization(); } public override void UpdateNodeAfterDeserialization() { AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero)); AddSlot(new Vector3MaterialSlot(OutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector3.zero)); RemoveSlotsNameNotMatching(new[] { OutputSlotId, OutputSlot1Id }); } public override string GetVariableNameForSlot(int slotId) { switch (slotId) { case OutputSlot1Id: return @"float3(length(float3(unity_ObjectToWorld[0].x, unity_ObjectToWorld[1].x, unity_ObjectToWorld[2].x)), length(float3(unity_ObjectToWorld[0].y, unity_ObjectToWorld[1].y, unity_ObjectToWorld[2].y)), length(float3(unity_ObjectToWorld[0].z, unity_ObjectToWorld[1].z, unity_ObjectToWorld[2].z)))"; default: return "unity_ObjectToWorld._m03_m13_m23"; } } } }