123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System;
- using UnityEngine.Scripting.APIUpdating;
- using UnityEngine.Serialization;
- namespace UnityEngine.Experimental.Rendering.Universal
- {
- [Serializable]
- [MovedFrom("UnityEngine.Experimental.Rendering.LWRP")] public struct Light2DBlendStyle
- {
- internal enum TextureChannel
- {
- None = 0,
- R = 1,
- G = 2,
- B = 3,
- A = 4,
- OneMinusR = 5,
- OneMinusG = 6,
- OneMinusB = 7,
- OneMinusA = 8
- }
- internal struct MaskChannelFilter
- {
- public Vector4 mask { get; private set; }
- public Vector4 inverted { get; private set; }
- public MaskChannelFilter(Vector4 m, Vector4 i)
- {
- mask = m;
- inverted = i;
- }
- }
- internal enum BlendMode
- {
- Additive = 0,
- Multiply = 1,
- Subtractive = 2,
- Custom = 99
- }
- [Serializable]
- internal struct BlendFactors
- {
- public float multiplicative;
- public float additive;
- }
- [System.Obsolete("This field is obsolete. Blend Styles are now automatically enabled/disabled.")]
- public bool enabled;
- public string name;
- [SerializeField]
- internal TextureChannel maskTextureChannel;
- [SerializeField, Range(0.01f, 1.0f)]
- internal float renderTextureScale;
- [SerializeField]
- internal BlendMode blendMode;
- [SerializeField]
- internal BlendFactors customBlendFactors;
- internal Vector2 blendFactors
- {
- get
- {
- var result = new Vector2();
- switch (blendMode)
- {
- case BlendMode.Additive:
- result.x = 0.0f;
- result.y = 1.0f;
- break;
- case BlendMode.Multiply:
- result.x = 1.0f;
- result.y = 0.0f;
- break;
- case BlendMode.Subtractive:
- result.x = 0.0f;
- result.y = -1.0f;
- break;
- case BlendMode.Custom:
- result.x = customBlendFactors.multiplicative;
- result.y = customBlendFactors.additive;
- break;
- default:
- result = Vector2.zero;
- break;
- }
- return result;
- }
- }
- internal MaskChannelFilter maskTextureChannelFilter
- {
- get
- {
- switch (maskTextureChannel)
- {
- case TextureChannel.R:
- return new MaskChannelFilter(new Vector4(1, 0, 0, 0), new Vector4(0, 0, 0, 0));
- case TextureChannel.OneMinusR:
- return new MaskChannelFilter(new Vector4(1, 0, 0, 0), new Vector4(1, 0, 0, 0));
- case TextureChannel.G:
- return new MaskChannelFilter(new Vector4(0, 1, 0, 0), new Vector4(0, 0, 0, 0));
- case TextureChannel.OneMinusG:
- return new MaskChannelFilter(new Vector4(0, 1, 0, 0), new Vector4(0, 1, 0, 0));
- case TextureChannel.B:
- return new MaskChannelFilter(new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 0));
- case TextureChannel.OneMinusB:
- return new MaskChannelFilter(new Vector4(0, 0, 1, 0), new Vector4(0, 0, 1, 0));
- case TextureChannel.A:
- return new MaskChannelFilter(new Vector4(0, 0, 0, 1), new Vector4(0, 0, 0, 0));
- case TextureChannel.OneMinusA:
- return new MaskChannelFilter(new Vector4(0, 0, 0, 1), new Vector4(0, 0, 0, 1));
- case TextureChannel.None:
- default:
- return new MaskChannelFilter(Vector4.zero, Vector4.zero);
- }
- }
- }
- }
- }
|