Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor.ShaderGraph;
- using System.Reflection;
- [Title("Utility", "Graph Preview")]
- public class GraphPreviewNode : CodeFunctionNode
- {
- protected override MethodInfo GetFunctionToConvert()
- {
- return GetType().GetMethod("MyCustomFunction",
- BindingFlags.Static | BindingFlags.NonPublic);
- }
- static string MyCustomFunction(
- [Slot(0, Binding.MeshUV0)] Vector2 UV,
- [Slot(1, Binding.None)] Vector1 Input,
- [Slot(2, Binding.None, 0.018f, 0f, 0f, 0f)] Vector1 LineWidth,
- [Slot(3, Binding.None, true)] out ColorRGB OutColor,
- [Slot(4, Binding.None)] out Vector1 OutFloat
- )
- {
- return @"{
- #define LINE_SIZE LineWidth
- #define LINE_COLOR float4(1,1,1,1)
- #define BRIGHTNESS 5.0
- #define X (Input)
- #define Y (UV.y)
- #define InvX (1.0 - X)
- #define InvY (1.0 - Y)
- OutColor = BRIGHTNESS * LINE_COLOR * (
- smoothstep(Y - LINE_SIZE, Y + LINE_SIZE, X)
- * smoothstep(InvY - LINE_SIZE, InvY + LINE_SIZE, InvX)
- );
- OutFloat = Input;
- }";
- }
- }
Add Comment
Please, Sign In to add comment