暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

NormalMaterialSlot.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 NormalMaterialSlot : SpaceMaterialSlot, IMayRequireNormal
  9. {
  10. public NormalMaterialSlot()
  11. { }
  12. public NormalMaterialSlot(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. // HACK: we don't define AbsoluteWorldSpaceNormal, but it is the same as WorldSpaceNormal
  23. var coordSpace = (space == CoordinateSpace.AbsoluteWorld) ? CoordinateSpace.World : space;
  24. return string.Format("IN.{0}", coordSpace.ToVariableName(InterpolatorType.Normal));
  25. }
  26. public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapability)
  27. {
  28. if (isConnected)
  29. return NeededCoordinateSpace.None;
  30. // HACK: we don't define AbsoluteWorldSpaceNormal, but it is the same as WorldSpaceNormal
  31. var coordSpace = (space == CoordinateSpace.AbsoluteWorld) ? CoordinateSpace.World : space;
  32. return coordSpace.ToNeededCoordinateSpace();
  33. }
  34. }
  35. }