Guest User

Untitled

a guest
Oct 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor.ShaderGraph;
  3. using System.Reflection;
  4.  
  5. [Title("Utility", "Graph Preview")]
  6. public class GraphPreviewNode : CodeFunctionNode
  7. {
  8. protected override MethodInfo GetFunctionToConvert()
  9. {
  10. return GetType().GetMethod("MyCustomFunction",
  11. BindingFlags.Static | BindingFlags.NonPublic);
  12. }
  13. static string MyCustomFunction(
  14. [Slot(0, Binding.MeshUV0)] Vector2 UV,
  15. [Slot(1, Binding.None)] Vector1 Input,
  16. [Slot(2, Binding.None, 0.018f, 0f, 0f, 0f)] Vector1 LineWidth,
  17. [Slot(3, Binding.None, true)] out ColorRGB OutColor,
  18. [Slot(4, Binding.None)] out Vector1 OutFloat
  19. )
  20. {
  21. return @"{
  22. #define LINE_SIZE LineWidth
  23. #define LINE_COLOR float4(1,1,1,1)
  24. #define BRIGHTNESS 5.0
  25. #define X (Input)
  26. #define Y (UV.y)
  27. #define InvX (1.0 - X)
  28. #define InvY (1.0 - Y)
  29. OutColor = BRIGHTNESS * LINE_COLOR * (
  30. smoothstep(Y - LINE_SIZE, Y + LINE_SIZE, X)
  31. * smoothstep(InvY - LINE_SIZE, InvY + LINE_SIZE, InvX)
  32. );
  33. OutFloat = Input;
  34. }";
  35. }
  36. }
Add Comment
Please, Sign In to add comment