TangentMaterialSlot.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using UnityEditor.ShaderGraph.Drawing.Slots;
  3. using UnityEditor.ShaderGraph.Internal;
  4. using UnityEngine.UIElements;
  5. namespace UnityEditor.ShaderGraph
  6. {
  7. [Serializable]
  8. class TangentMaterialSlot : SpaceMaterialSlot, IMayRequireTangent
  9. {
  10. public TangentMaterialSlot()
  11. {}
  12. public TangentMaterialSlot(int slotId, string displayName, string shaderOutputName, CoordinateSpace space,
  13. ShaderStageCapability stageCapability = ShaderStageCapability.All, bool hidden = false)
  14. : base(slotId, displayName, shaderOutputName, space, stageCapability, hidden)
  15. {}
  16. public override VisualElement InstantiateControl()
  17. {
  18. return new LabelSlotControlView(space + " Space");
  19. }
  20. public override string GetDefaultValue(GenerationMode generationMode)
  21. {
  22. return string.Format("IN.{0}", space.ToVariableName(InterpolatorType.Tangent));
  23. }
  24. public NeededCoordinateSpace RequiresTangent(ShaderStageCapability stageCapability)
  25. {
  26. if (isConnected)
  27. return NeededCoordinateSpace.None;
  28. return space.ToNeededCoordinateSpace();
  29. }
  30. }
  31. }