using System; using UnityEngine; namespace Es.InkPainter { [Serializable] public class Brush : ICloneable { public enum ColorBlendType { UseColor = 0, UseBrush = 1, Neutral = 2, AlphaOnly = 3 } public enum NormalBlendType { UseBrush = 0, Add = 1, Sub = 2, Min = 3, Max = 4 } public enum HeightBlendType { UseBrush = 0, Add = 1, Sub = 2, Min = 3, Max = 4, ColorRGB_HeightA = 5 } [SerializeField] private Texture brushTexture; [SerializeField] private Texture brushNormalTexture; [SerializeField] private Texture brushHeightTexture; [SerializeField] [Range(0f, 1f)] private float brushScale = 0.1f; [SerializeField] [Range(0f, 360f)] private float rotateAngle; [SerializeField] [Range(0f, 1f)] private float brushNormalBlend = 0.1f; [SerializeField] [Range(0f, 1f)] private float brushHeightBlend = 0.1f; [SerializeField] private Color brushColor; [SerializeField] private ColorBlendType colorBlendType; [SerializeField] private NormalBlendType normalBlendType; [SerializeField] private HeightBlendType heightBlendType; public Texture BrushTexture { get { return brushTexture; } set { brushTexture = value; } } public Texture BrushNormalTexture { get { return brushNormalTexture; } set { brushNormalTexture = value; } } public Texture BrushHeightTexture { get { return brushHeightTexture; } set { brushHeightTexture = value; } } public float Scale { get { return Mathf.Clamp01(brushScale); } set { brushScale = Mathf.Clamp01(value); } } public float RotateAngle { get { return rotateAngle; } set { rotateAngle = value; } } public float NormalBlend { get { return Mathf.Clamp01(brushNormalBlend); } set { brushNormalBlend = Mathf.Clamp01(value); } } public float HeightBlend { get { return Mathf.Clamp01(brushHeightBlend); } set { brushHeightBlend = Mathf.Clamp01(value); } } public Color Color { get { return brushColor; } set { brushColor = value; } } public ColorBlendType ColorBlending { get { return colorBlendType; } set { colorBlendType = value; } } public NormalBlendType NormalBlending { get { return normalBlendType; } set { normalBlendType = value; } } public HeightBlendType HeightBlending { get { return heightBlendType; } set { heightBlendType = value; } } public Brush(Texture brushTex, float scale, Color color) { BrushTexture = brushTex; Scale = scale; Color = color; } public Brush(Texture brushTex, float scale, Color color, ColorBlendType colorBlending) : this(brushTex, scale, color) { ColorBlending = colorBlending; } public Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend) : this(brushTex, scale, color) { BrushNormalTexture = normalTex; NormalBlend = normalBlend; } public Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend, ColorBlendType colorBlending, NormalBlendType normalBlending) : this(brushTex, scale, color, normalTex, normalBlend) { ColorBlending = colorBlending; NormalBlending = normalBlending; } public Brush(Texture brushTex, float scale, Color color, Texture normalTex, float normalBlend, Texture heightTex, float heightBlend, ColorBlendType colorBlending, NormalBlendType normalBlending, HeightBlendType heightBlending) : this(brushTex, scale, color, normalTex, normalBlend, colorBlending, normalBlending) { BrushHeightTexture = heightTex; HeightBlend = heightBlend; HeightBlending = heightBlending; } public object Clone() { return MemberwiseClone(); } } }