No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RGBANodeOutput.cs 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Linq;
  2. using UnityEngine;
  3. using UnityEditor.Graphing;
  4. using UnityEditor.ShaderGraph.Drawing.Controls;
  5. using UnityEditor.ShaderGraph.Internal;
  6. namespace UnityEditor.ShaderGraph
  7. {
  8. internal struct RGBANodeOutput
  9. {
  10. const string kRGBAName = "RGBA";
  11. const string kRName = "R";
  12. const string kGName = "G";
  13. const string kBName = "B";
  14. const string kAName = "A";
  15. public int rgbaOutput;
  16. public int rOutput;
  17. public int gOutput;
  18. public int bOutput;
  19. public int aOutput;
  20. public MaterialSlot rgba;
  21. public MaterialSlot r;
  22. public MaterialSlot g;
  23. public MaterialSlot b;
  24. public MaterialSlot a;
  25. public ShaderStageCapability capabilities;
  26. public static RGBANodeOutput NewDefault()
  27. {
  28. return new RGBANodeOutput()
  29. {
  30. rgba = null,
  31. r = null,
  32. g = null,
  33. b = null,
  34. a = null,
  35. capabilities = ShaderStageCapability.None
  36. };
  37. }
  38. public void CreateNodes(AbstractMaterialNode node, ShaderStageCapability newCapabilities, int rgbaSlot, int rSlot, int gSlot, int bSlot, int aSlot)
  39. {
  40. capabilities = newCapabilities;
  41. rgbaOutput = rgbaSlot;
  42. rOutput = rSlot;
  43. gOutput = gSlot;
  44. bOutput = bSlot;
  45. aOutput = aSlot;
  46. rgba = node.AddSlot(new Vector4MaterialSlot(rgbaOutput, kRGBAName, kRGBAName, SlotType.Output, Vector4.zero, capabilities));
  47. r = node.AddSlot(new Vector1MaterialSlot(rOutput, kRName, kRName, SlotType.Output, 0.0f, capabilities));
  48. g = node.AddSlot(new Vector1MaterialSlot(gOutput, kGName, kGName, SlotType.Output, 0.0f, capabilities));
  49. b = node.AddSlot(new Vector1MaterialSlot(bOutput, kBName, kBName, SlotType.Output, 0.0f, capabilities));
  50. a = node.AddSlot(new Vector1MaterialSlot(aOutput, kAName, kAName, SlotType.Output, 0.0f, capabilities));
  51. }
  52. public void SetCapabilities(ShaderStageCapability newCapabilities)
  53. {
  54. if (newCapabilities == capabilities)
  55. return;
  56. capabilities = newCapabilities;
  57. rgba.stageCapability = capabilities;
  58. r.stageCapability = capabilities;
  59. g.stageCapability = capabilities;
  60. b.stageCapability = capabilities;
  61. a.stageCapability = capabilities;
  62. }
  63. }
  64. }