A game about forced loneliness, made by TACStudios
1using System.Reflection;
2using UnityEngine;
3using UnityEditor.Graphing;
4using UnityEditor.ShaderGraph.Drawing.Controls;
5
6namespace UnityEditor.ShaderGraph
7{
8 enum ExponentialBase
9 {
10 BaseE,
11 Base2
12 };
13
14 [Title("Math", "Advanced", "Exponential")]
15 class ExponentialNode : CodeFunctionNode
16 {
17 public ExponentialNode()
18 {
19 name = "Exponential";
20 }
21
22 [SerializeField]
23 private ExponentialBase m_ExponentialBase = ExponentialBase.BaseE;
24
25 [EnumControl("Base")]
26 public ExponentialBase exponentialBase
27 {
28 get { return m_ExponentialBase; }
29 set
30 {
31 if (m_ExponentialBase == value)
32 return;
33
34 m_ExponentialBase = value;
35 Dirty(ModificationScope.Graph);
36 }
37 }
38
39 protected override MethodInfo GetFunctionToConvert()
40 {
41 switch (m_ExponentialBase)
42 {
43 case ExponentialBase.Base2:
44 return GetType().GetMethod("Unity_Exponential2", BindingFlags.Static | BindingFlags.NonPublic);
45 default:
46 return GetType().GetMethod("Unity_Exponential", BindingFlags.Static | BindingFlags.NonPublic);
47 }
48 }
49
50 static string Unity_Exponential(
51 [Slot(0, Binding.None)] DynamicDimensionVector In,
52 [Slot(1, Binding.None)] out DynamicDimensionVector Out)
53 {
54 return
55@"
56{
57 Out = exp(In);
58}
59";
60 }
61
62 static string Unity_Exponential2(
63 [Slot(0, Binding.None)] DynamicDimensionVector In,
64 [Slot(1, Binding.None)] out DynamicDimensionVector Out)
65 {
66 return
67@"
68{
69 Out = exp2(In);
70}
71";
72 }
73 }
74}