Tanoda
Brush.cs
Go to the documentation of this file.
1using System;
2using UnityEngine;
3
4namespace Es.InkPainter
5{
9 [Serializable]
10 public class Brush : ICloneable
11 {
15 public enum ColorBlendType
16 {
20 UseColor,
21
25 UseBrush,
26
30 Neutral,
31
35 AlphaOnly
36 }
37
41 public enum NormalBlendType
42 {
46 UseBrush,
47
51 Add,
52
56 Sub,
57
61 Min,
62
66 Max
67 }
68
72 public enum HeightBlendType
73 {
77 UseBrush,
78
82 Add,
83
87 Sub,
88
92 Min,
93
97 Max,
98
102 ColorRGB_HeightA
103 }
104
105 [SerializeField] private Texture brushTexture;
106
107 [SerializeField] private Texture brushNormalTexture;
108
109 [SerializeField] private Texture brushHeightTexture;
110
111 [SerializeField] [Range(0, 1)] private float brushScale = 0.1f;
112
113 [SerializeField] [Range(0, 360)] private float rotateAngle;
114
115 [SerializeField] [Range(0, 1)] private float brushNormalBlend = 0.1f;
116
117 [SerializeField] [Range(0, 1)] private float brushHeightBlend = 0.1f;
118
119 [SerializeField] private Color brushColor;
120
121 [SerializeField] private ColorBlendType colorBlendType;
122
123 [SerializeField] private NormalBlendType normalBlendType;
124
125 [SerializeField] private HeightBlendType heightBlendType;
126
130 public Texture BrushTexture
131 {
132 get => brushTexture;
133 set => brushTexture = value;
134 }
135
139 public Texture BrushNormalTexture
140 {
141 get => brushNormalTexture;
142 set => brushNormalTexture = value;
143 }
144
148 public Texture BrushHeightTexture
149 {
150 get => brushHeightTexture;
151 set => brushHeightTexture = value;
152 }
153
158 public float Scale
159 {
160 get => Mathf.Clamp01(brushScale);
161 set => brushScale = Mathf.Clamp01(value);
162 }
163
167 public float RotateAngle
168 {
169 get => rotateAngle;
170 set => rotateAngle = value;
171 }
172
177 public float NormalBlend
178 {
179 get => Mathf.Clamp01(brushNormalBlend);
180 set => brushNormalBlend = Mathf.Clamp01(value);
181 }
182
187 public float HeightBlend
188 {
189 get => Mathf.Clamp01(brushHeightBlend);
190 set => brushHeightBlend = Mathf.Clamp01(value);
191 }
192
197 {
198 get => brushColor;
199 set => brushColor = value;
200 }
201
206 {
207 get => colorBlendType;
208 set => colorBlendType = value;
209 }
210
215 {
216 get => normalBlendType;
217 set => normalBlendType = value;
218 }
219
224 {
225 get => heightBlendType;
226 set => heightBlendType = value;
227 }
228
229 public Brush(Texture brushTex, float scale, Color color)
230 {
231 BrushTexture = brushTex;
232 Scale = scale;
233 Color = color;
234 }
235
236 public Brush(Texture brushTex, float scale, Color color, ColorBlendType colorBlending)
237 : this(brushTex, scale, color)
238 {
239 ColorBlending = colorBlending;
240 }
241
242 public Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend)
243 : this(brushTex, scale, color)
244 {
245 BrushNormalTexture = normalTex;
246 NormalBlend = normalBlend;
247 }
248
249 public Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend,
250 ColorBlendType colorBlending, NormalBlendType normalBlending)
251 : this(brushTex, scale, color, normalTex, normalBlend)
252 {
253 ColorBlending = colorBlending;
254 NormalBlending = normalBlending;
255 }
256
257 public Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend,
258 Texture heightTex, float heightBlend, ColorBlendType colorBlending, NormalBlendType normalBlending,
259 HeightBlendType heightBlending)
260 : this(brushTex, scale, color, normalTex, normalBlend, colorBlending, normalBlending)
261 {
262 BrushHeightTexture = heightTex;
263 HeightBlend = heightBlend;
264 HeightBlending = heightBlending;
265 }
266
267 public object Clone()
268 {
269 return MemberwiseClone();
270 }
271 }
272}
UnityEngine.Color Color
Definition: TestScript.cs:32
Class managing brush information.
Definition: Brush.cs:11
float RotateAngle
Rotate angle of the brush.
Definition: Brush.cs:168
float Scale
The size of the brush. It takes a range from 0 to 1.
Definition: Brush.cs:159
NormalBlendType
Brush normal information synthesis method.
Definition: Brush.cs:42
Brush(Texture brushTex, float scale, Color color, ColorBlendType colorBlending)
Definition: Brush.cs:236
Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend, Texture heightTex, float heightBlend, ColorBlendType colorBlending, NormalBlendType normalBlending, HeightBlendType heightBlending)
Definition: Brush.cs:257
float HeightBlend
Blending factor of height information. It takes a range from 0 to 1.
Definition: Brush.cs:188
ColorBlendType ColorBlending
Color synthesis method.
Definition: Brush.cs:206
ColorBlendType
Color synthesis method.
Definition: Brush.cs:16
Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend, ColorBlendType colorBlending, NormalBlendType normalBlending)
Definition: Brush.cs:249
HeightBlendType HeightBlending
Brush height information synthesis method.
Definition: Brush.cs:224
Texture BrushHeightTexture
Brush height texture.
Definition: Brush.cs:149
NormalBlendType NormalBlending
Brush normal information synthesis method.
Definition: Brush.cs:215
float NormalBlend
Blending coefficient of normal information. It takes a range from 0 to 1.
Definition: Brush.cs:178
Texture BrushNormalTexture
Brush's normal texture
Definition: Brush.cs:140
Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend)
Definition: Brush.cs:242
HeightBlendType
Brush height information synthesis method.
Definition: Brush.cs:73
Texture BrushTexture
Brush texture.
Definition: Brush.cs:131
object Clone()
Definition: Brush.cs:267
Brush(Texture brushTex, float scale, Color color)
Definition: Brush.cs:229