SawtoothWaveNode.cs 716 B

12345678910111213141516171819202122232425262728293031
  1. using System.Reflection;
  2. namespace UnityEditor.ShaderGraph
  3. {
  4. [Title("Math", "Wave", "Sawtooth Wave")]
  5. class SawtoothWaveNode : CodeFunctionNode
  6. {
  7. public SawtoothWaveNode()
  8. {
  9. name = "Sawtooth Wave";
  10. }
  11. protected override MethodInfo GetFunctionToConvert()
  12. {
  13. return GetType().GetMethod("SawtoothWave", BindingFlags.Static | BindingFlags.NonPublic);
  14. }
  15. static string SawtoothWave(
  16. [Slot(0, Binding.None)] DynamicDimensionVector In,
  17. [Slot(1, Binding.None)] out DynamicDimensionVector Out)
  18. {
  19. return
  20. @"
  21. {
  22. Out = 2 * (In - floor(0.5 + In));
  23. }
  24. ";
  25. }
  26. }
  27. }