BakedGINode.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Reflection;
  2. using UnityEngine;
  3. using UnityEditor.Graphing;
  4. using UnityEditor.ShaderGraph.Drawing.Controls;
  5. namespace UnityEditor.ShaderGraph
  6. {
  7. [FormerName("UnityEditor.ShaderGraph.BakedGAbstractMaterialNode")]
  8. [FormerName("UnityEditor.ShaderGraph.LightProbeNode")]
  9. [Title("Input", "Lighting", "Baked GI")]
  10. class BakedGINode : CodeFunctionNode
  11. {
  12. public override bool hasPreview { get { return false; } }
  13. public BakedGINode()
  14. {
  15. name = "Baked GI";
  16. }
  17. protected override MethodInfo GetFunctionToConvert()
  18. {
  19. if(applyScaling.isOn)
  20. return GetType().GetMethod("Unity_BakedGIScale", BindingFlags.Static | BindingFlags.NonPublic);
  21. else
  22. return GetType().GetMethod("Unity_BakedGI", BindingFlags.Static | BindingFlags.NonPublic);
  23. }
  24. [SerializeField]
  25. private bool m_ApplyScaling = true;
  26. [ToggleControl("Apply Lightmap Scaling")]
  27. public ToggleData applyScaling
  28. {
  29. get { return new ToggleData(m_ApplyScaling); }
  30. set
  31. {
  32. if (m_ApplyScaling == value.isOn)
  33. return;
  34. m_ApplyScaling = value.isOn;
  35. Dirty(ModificationScope.Node);
  36. }
  37. }
  38. static string Unity_BakedGI(
  39. [Slot(2, Binding.WorldSpacePosition)] Vector3 Position,
  40. [Slot(0, Binding.WorldSpaceNormal)] Vector3 Normal,
  41. [Slot(3, Binding.MeshUV1)] Vector2 StaticUV,
  42. [Slot(4, Binding.MeshUV2)] Vector2 DynamicUV,
  43. [Slot(1, Binding.None)] out Vector3 Out)
  44. {
  45. Out = Vector3.one;
  46. return
  47. @"
  48. {
  49. Out = SHADERGRAPH_BAKED_GI(Position, Normal, StaticUV, DynamicUV, false);
  50. }
  51. ";
  52. }
  53. static string Unity_BakedGIScale(
  54. [Slot(2, Binding.WorldSpacePosition)] Vector3 Position,
  55. [Slot(0, Binding.WorldSpaceNormal)] Vector3 Normal,
  56. [Slot(3, Binding.MeshUV1)] Vector2 StaticUV,
  57. [Slot(4, Binding.MeshUV2)] Vector2 DynamicUV,
  58. [Slot(1, Binding.None)] out Vector3 Out)
  59. {
  60. Out = Vector3.one;
  61. return
  62. @"
  63. {
  64. Out = SHADERGRAPH_BAKED_GI(Position, Normal, StaticUV, DynamicUV, true);
  65. }
  66. ";
  67. }
  68. }
  69. }