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 LogBase
9 {
10 BaseE,
11 Base2,
12 Base10
13 };
14
15 [Title("Math", "Advanced", "Log")]
16 class LogNode : CodeFunctionNode
17 {
18 public LogNode()
19 {
20 name = "Log";
21 }
22
23 [SerializeField]
24 private LogBase m_LogBase = LogBase.BaseE;
25
26 [EnumControl("Base")]
27 public LogBase logBase
28 {
29 get { return m_LogBase; }
30 set
31 {
32 if (m_LogBase == value)
33 return;
34
35 m_LogBase = value;
36 Dirty(ModificationScope.Graph);
37 }
38 }
39
40 protected override MethodInfo GetFunctionToConvert()
41 {
42 switch (m_LogBase)
43 {
44 case LogBase.Base2:
45 return GetType().GetMethod("Unity_Log2", BindingFlags.Static | BindingFlags.NonPublic);
46 case LogBase.Base10:
47 return GetType().GetMethod("Unity_Log10", BindingFlags.Static | BindingFlags.NonPublic);
48 default:
49 return GetType().GetMethod("Unity_Log", BindingFlags.Static | BindingFlags.NonPublic);
50 }
51 }
52
53 static string Unity_Log(
54 [Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
55 [Slot(1, Binding.None)] out DynamicDimensionVector Out)
56 {
57 return
58@"
59{
60 Out = log(In);
61}
62";
63 }
64
65 static string Unity_Log2(
66 [Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
67 [Slot(1, Binding.None)] out DynamicDimensionVector Out)
68 {
69 return
70@"
71{
72 Out = log2(In);
73}
74";
75 }
76
77 static string Unity_Log10(
78 [Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
79 [Slot(1, Binding.None)] out DynamicDimensionVector Out)
80 {
81 return
82@"
83{
84 Out = log10(In);
85}
86";
87 }
88 }
89}