SurfaceMaterialOptions.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.ShaderGraph
  4. {
  5. [Serializable]
  6. class SurfaceMaterialOptions
  7. {
  8. public enum BlendMode
  9. {
  10. One,
  11. Zero,
  12. SrcColor,
  13. SrcAlpha,
  14. DstColor,
  15. DstAlpha,
  16. OneMinusSrcColor,
  17. OneMinusSrcAlpha,
  18. OneMinusDstColor,
  19. OneMinusDstAlpha,
  20. }
  21. public enum CullMode
  22. {
  23. Back,
  24. Front,
  25. Off
  26. }
  27. public enum ZTest
  28. {
  29. Less,
  30. Greater,
  31. LEqual,
  32. GEqual,
  33. Equal,
  34. NotEqual,
  35. Always
  36. }
  37. public enum ZWrite
  38. {
  39. On,
  40. Off
  41. }
  42. [SerializeField]
  43. private BlendMode m_SrcBlend = BlendMode.One;
  44. [SerializeField]
  45. private BlendMode m_DstBlend = BlendMode.Zero;
  46. [SerializeField]
  47. private BlendMode m_AlphaSrcBlend = BlendMode.One;
  48. [SerializeField]
  49. private BlendMode m_AlphaDstBlend = BlendMode.Zero;
  50. [SerializeField]
  51. private CullMode m_CullMode = CullMode.Back;
  52. [SerializeField]
  53. private ZTest m_ZTest = ZTest.LEqual;
  54. [SerializeField]
  55. private ZWrite m_ZWrite = ZWrite.On;
  56. [SerializeField]
  57. private int m_LOD = 200;
  58. public void Init()
  59. {
  60. srcBlend = BlendMode.One;
  61. dstBlend = BlendMode.Zero;
  62. alphaSrcBlend = BlendMode.One;
  63. alphaDstBlend = BlendMode.Zero;
  64. cullMode = CullMode.Back;
  65. zTest = ZTest.LEqual;
  66. zWrite = ZWrite.On;
  67. lod = 200;
  68. }
  69. public void GetBlend(ShaderStringBuilder builder)
  70. {
  71. builder.AppendLine("Blend {0} {1}, {2} {3}", srcBlend, dstBlend, alphaSrcBlend, alphaDstBlend);
  72. }
  73. public void GetCull(ShaderStringBuilder builder)
  74. {
  75. builder.AppendLine("Cull {0}", cullMode);
  76. }
  77. public void GetDepthWrite(ShaderStringBuilder builder)
  78. {
  79. builder.AppendLine("ZWrite {0}", zWrite);
  80. }
  81. public void GetDepthClip(ShaderStringBuilder builder)
  82. {
  83. builder.AppendLine("ZClip [_ZClip]");
  84. }
  85. public void GetDepthTest(ShaderStringBuilder builder)
  86. {
  87. builder.AppendLine("ZTest {0}", zTest);
  88. }
  89. public BlendMode srcBlend { get { return m_SrcBlend; } set { m_SrcBlend = value; } }
  90. public BlendMode dstBlend { get { return m_DstBlend; } set { m_DstBlend = value; } }
  91. public BlendMode alphaSrcBlend { get { return m_AlphaSrcBlend; } set { m_AlphaSrcBlend = value; } }
  92. public BlendMode alphaDstBlend { get { return m_AlphaDstBlend; } set { m_AlphaDstBlend = value; } }
  93. public CullMode cullMode { get { return m_CullMode; } set { m_CullMode = value; } }
  94. public ZTest zTest { get { return m_ZTest; } set { m_ZTest = value; } }
  95. public ZWrite zWrite { get { return m_ZWrite; } set { m_ZWrite = value; } }
  96. public int lod { get { return m_LOD; } set { m_LOD = value; } }
  97. }
  98. }