A game about forced loneliness, made by TACStudios
at master 1.7 kB view raw
1using System; 2using UnityEditor.ShaderGraph.Drawing.Slots; 3using UnityEditor.ShaderGraph.Internal; 4using UnityEngine.UIElements; 5 6namespace UnityEditor.ShaderGraph 7{ 8 [Serializable] 9 class NormalMaterialSlot : SpaceMaterialSlot, IMayRequireNormal 10 { 11 public NormalMaterialSlot() 12 { } 13 14 public NormalMaterialSlot(int slotId, string displayName, string shaderOutputName, CoordinateSpace space, 15 ShaderStageCapability stageCapability = ShaderStageCapability.All, bool hidden = false) 16 : base(slotId, displayName, shaderOutputName, space, stageCapability, hidden) 17 { } 18 19 public override VisualElement InstantiateControl() 20 { 21 return new LabelSlotControlView(space + " Space"); 22 } 23 24 public override string GetDefaultValue(GenerationMode generationMode) 25 { 26 // HACK: we don't define AbsoluteWorldSpaceNormal, but it is the same as WorldSpaceNormal 27 var coordSpace = (space == CoordinateSpace.AbsoluteWorld) ? CoordinateSpace.World : space; 28 return string.Format("IN.{0}", coordSpace.ToVariableName(InterpolatorType.Normal)); 29 } 30 31 public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapability) 32 { 33 if (isConnected) 34 return NeededCoordinateSpace.None; 35 // HACK: we don't define AbsoluteWorldSpaceNormal, but it is the same as WorldSpaceNormal 36 var coordSpace = (space == CoordinateSpace.AbsoluteWorld) ? CoordinateSpace.World : space; 37 return coordSpace.ToNeededCoordinateSpace(); 38 } 39 } 40}