A game about forced loneliness, made by TACStudios
1using UnityEngine;
2using UnityEditor.ShaderGraph.Internal;
3
4namespace UnityEditor.ShaderGraph
5{
6 // This whole file is regrettable.
7 // However, right now we need an abstraction for MaterialSlot for use with BlockFieldDescriptors.
8 // MaterialSlot is very leaky, so we cant make it public but we need BlockFieldDescriptor to be public.
9 // All MaterialSlot types required by a BlockFieldDescriptor need a matching Control here.
10 // We also need a corresponding case in BlockNode.AddSlot for each control.
11
12 public interface IControl
13 {
14 ShaderGraphRequirements GetRequirements();
15 }
16
17 public class PositionControl : IControl
18 {
19 public CoordinateSpace space { get; private set; }
20
21 public PositionControl(CoordinateSpace space)
22 {
23 this.space = space;
24 }
25
26 public ShaderGraphRequirements GetRequirements()
27 {
28 return new ShaderGraphRequirements() { requiresPosition = space.ToNeededCoordinateSpace() };
29 }
30 }
31
32 public class NormalControl : IControl
33 {
34 public CoordinateSpace space { get; private set; }
35
36 public NormalControl(CoordinateSpace space)
37 {
38 this.space = space;
39 }
40
41 public ShaderGraphRequirements GetRequirements()
42 {
43 return new ShaderGraphRequirements() { requiresNormal = space.ToNeededCoordinateSpace() };
44 }
45 }
46
47 public class TangentControl : IControl
48 {
49 public CoordinateSpace space { get; private set; }
50
51 public TangentControl(CoordinateSpace space)
52 {
53 this.space = space;
54 }
55
56 public ShaderGraphRequirements GetRequirements()
57 {
58 return new ShaderGraphRequirements() { requiresTangent = space.ToNeededCoordinateSpace() };
59 }
60 }
61
62 public class ColorControl : IControl
63 {
64 public Color value { get; private set; }
65 public bool hdr { get; private set; }
66
67 public ColorControl(Color value, bool hdr)
68 {
69 this.value = value;
70 this.hdr = hdr;
71 }
72
73 public ShaderGraphRequirements GetRequirements()
74 {
75 return ShaderGraphRequirements.none;
76 }
77 }
78
79 public class ColorRGBAControl : IControl
80 {
81 public Color value { get; private set; }
82
83 public ColorRGBAControl(Color value)
84 {
85 this.value = value;
86 }
87
88 public ShaderGraphRequirements GetRequirements()
89 {
90 return ShaderGraphRequirements.none;
91 }
92 }
93
94 public class FloatControl : IControl
95 {
96 public float value { get; private set; }
97
98 public FloatControl(float value)
99 {
100 this.value = value;
101 }
102
103 public ShaderGraphRequirements GetRequirements()
104 {
105 return ShaderGraphRequirements.none;
106 }
107 }
108
109 public class Vector2Control : IControl
110 {
111 public Vector2 value { get; private set; }
112
113 public Vector2Control(Vector2 value)
114 {
115 this.value = value;
116 }
117
118 public ShaderGraphRequirements GetRequirements()
119 {
120 return ShaderGraphRequirements.none;
121 }
122 }
123
124 public class Vector3Control : IControl
125 {
126 public Vector3 value { get; private set; }
127
128 public Vector3Control(Vector3 value)
129 {
130 this.value = value;
131 }
132
133 public ShaderGraphRequirements GetRequirements()
134 {
135 return ShaderGraphRequirements.none;
136 }
137 }
138
139 public class Vector4Control : IControl
140 {
141 public Vector4 value { get; private set; }
142
143 public Vector4Control(Vector4 value)
144 {
145 this.value = value;
146 }
147
148 public ShaderGraphRequirements GetRequirements()
149 {
150 return ShaderGraphRequirements.none;
151 }
152 }
153
154 public class VertexColorControl : IControl
155 {
156 public Color value { get; private set; }
157
158 public VertexColorControl(Color value)
159 {
160 this.value = value;
161 }
162
163 public ShaderGraphRequirements GetRequirements()
164 {
165 return new ShaderGraphRequirements() { requiresVertexColor = true };
166 }
167 }
168}