UI Particle System update from forum thread
parent
d6cfb41bf5
commit
8bd4312c16
|
@ -6,38 +6,36 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
#if UNITY_5_3_OR_NEWER
|
#if UNITY_5_3_OR_NEWER
|
||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
[RequireComponent(typeof(CanvasRenderer))]
|
[RequireComponent(typeof(CanvasRenderer), typeof(ParticleSystem))]
|
||||||
[RequireComponent(typeof(ParticleSystem))]
|
[AddComponentMenu("UI/Effects/Extensions/UIParticleSystem")]
|
||||||
public class UIParticleSystem : MaskableGraphic
|
public class UIParticleSystem : MaskableGraphic
|
||||||
{
|
{
|
||||||
|
[Tooltip("Having this enabled run the system in LateUpdate rather than in Update making it faster but less precise (more clunky)")]
|
||||||
public Texture particleTexture;
|
public bool fixedTime = true;
|
||||||
public Sprite particleSprite;
|
|
||||||
|
|
||||||
private Transform _transform;
|
private Transform _transform;
|
||||||
private ParticleSystem _particleSystem;
|
private ParticleSystem pSystem;
|
||||||
private ParticleSystem.Particle[] _particles;
|
private ParticleSystem.Particle[] particles;
|
||||||
private UIVertex[] _quad = new UIVertex[4];
|
private UIVertex[] _quad = new UIVertex[4];
|
||||||
private Vector4 _uv = Vector4.zero;
|
private Vector4 imageUV = Vector4.zero;
|
||||||
private ParticleSystem.TextureSheetAnimationModule _textureSheetAnimation;
|
private ParticleSystem.TextureSheetAnimationModule textureSheetAnimation;
|
||||||
private int _textureSheetAnimationFrames;
|
private int textureSheetAnimationFrames;
|
||||||
private Vector2 _textureSheedAnimationFrameSize;
|
private Vector2 textureSheetAnimationFrameSize;
|
||||||
|
private ParticleSystemRenderer pRenderer;
|
||||||
|
|
||||||
|
private Material currentMaterial;
|
||||||
|
|
||||||
|
private Texture currentTexture;
|
||||||
|
|
||||||
|
#if UNITY_5_5_OR_NEWER
|
||||||
|
private ParticleSystem.MainModule mainModule;
|
||||||
|
#endif
|
||||||
|
|
||||||
public override Texture mainTexture
|
public override Texture mainTexture
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (particleTexture)
|
return currentTexture;
|
||||||
{
|
|
||||||
return particleTexture;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (particleSprite)
|
|
||||||
{
|
|
||||||
return particleSprite.texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,93 +46,71 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
_transform = transform;
|
_transform = transform;
|
||||||
}
|
}
|
||||||
|
if (pSystem == null)
|
||||||
// prepare particle system
|
|
||||||
ParticleSystemRenderer renderer = GetComponent<ParticleSystemRenderer>();
|
|
||||||
bool setParticleSystemMaterial = false;
|
|
||||||
|
|
||||||
if (_particleSystem == null)
|
|
||||||
{
|
{
|
||||||
_particleSystem = GetComponent<ParticleSystem>();
|
pSystem = GetComponent<ParticleSystem>();
|
||||||
|
|
||||||
if (_particleSystem == null)
|
if (pSystem == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get current particle texture
|
#if UNITY_5_5_OR_NEWER
|
||||||
if (renderer == null)
|
mainModule = pSystem.main;
|
||||||
|
if (pSystem.main.maxParticles > 14000)
|
||||||
{
|
{
|
||||||
renderer = _particleSystem.gameObject.AddComponent<ParticleSystemRenderer>();
|
mainModule.maxParticles = 14000;
|
||||||
}
|
}
|
||||||
Material currentMaterial = renderer.sharedMaterial;
|
#else
|
||||||
|
if (pSystem.maxParticles > 14000)
|
||||||
|
pSystem.maxParticles = 14000;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
|
||||||
|
if (pRenderer != null)
|
||||||
|
pRenderer.enabled = false;
|
||||||
|
|
||||||
|
Shader foundShader = Shader.Find("UI Extensions/Particles/Additive");
|
||||||
|
Material pMaterial = new Material(foundShader);
|
||||||
|
|
||||||
|
if (material == null)
|
||||||
|
material = pMaterial;
|
||||||
|
|
||||||
|
currentMaterial = material;
|
||||||
if (currentMaterial && currentMaterial.HasProperty("_MainTex"))
|
if (currentMaterial && currentMaterial.HasProperty("_MainTex"))
|
||||||
{
|
{
|
||||||
particleTexture = currentMaterial.mainTexture;
|
currentTexture = currentMaterial.mainTexture;
|
||||||
|
if (currentTexture == null)
|
||||||
|
currentTexture = Texture2D.whiteTexture;
|
||||||
}
|
}
|
||||||
|
material = currentMaterial;
|
||||||
// automatically set scaling
|
// automatically set scaling
|
||||||
var main = _particleSystem.main;
|
#if UNITY_5_5_OR_NEWER
|
||||||
main.scalingMode = ParticleSystemScalingMode.Local;
|
mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||||
|
#else
|
||||||
_particles = null;
|
pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||||
setParticleSystemMaterial = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Application.isPlaying)
|
|
||||||
{
|
|
||||||
setParticleSystemMaterial = (renderer.material == null);
|
|
||||||
}
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setParticleSystemMaterial = (renderer.sharedMaterial == null);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
// automatically set material to UI/Particles/Hidden shader, and get previous texture
|
particles = null;
|
||||||
if (setParticleSystemMaterial)
|
}
|
||||||
{
|
#if UNITY_5_5_OR_NEWER
|
||||||
Material material = new Material(Shader.Find("UI/Particles/Hidden"));
|
if (particles == null)
|
||||||
if (Application.isPlaying)
|
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
|
||||||
{
|
#else
|
||||||
renderer.material = material;
|
if (particles == null)
|
||||||
}
|
particles = new ParticleSystem.Particle[pSystem.maxParticles];
|
||||||
#if UNITY_EDITOR
|
|
||||||
else
|
|
||||||
{
|
|
||||||
material.hideFlags = HideFlags.DontSave;
|
|
||||||
renderer.sharedMaterial = material;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
// prepare particles array
|
imageUV = new Vector4(0, 0, 1, 1);
|
||||||
if (_particles == null)
|
|
||||||
{
|
|
||||||
_particles = new ParticleSystem.Particle[_particleSystem.main.maxParticles];
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare uvs
|
|
||||||
if (particleTexture)
|
|
||||||
{
|
|
||||||
_uv = new Vector4(0, 0, 1, 1);
|
|
||||||
}
|
|
||||||
else if (particleSprite)
|
|
||||||
{
|
|
||||||
_uv = UnityEngine.Sprites.DataUtility.GetOuterUV(particleSprite);
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare texture sheet animation
|
// prepare texture sheet animation
|
||||||
_textureSheetAnimation = _particleSystem.textureSheetAnimation;
|
textureSheetAnimation = pSystem.textureSheetAnimation;
|
||||||
_textureSheetAnimationFrames = 0;
|
textureSheetAnimationFrames = 0;
|
||||||
_textureSheedAnimationFrameSize = Vector2.zero;
|
textureSheetAnimationFrameSize = Vector2.zero;
|
||||||
if (_textureSheetAnimation.enabled)
|
if (textureSheetAnimation.enabled)
|
||||||
{
|
{
|
||||||
_textureSheetAnimationFrames = _textureSheetAnimation.numTilesX * _textureSheetAnimation.numTilesY;
|
textureSheetAnimationFrames = textureSheetAnimation.numTilesX * textureSheetAnimation.numTilesY;
|
||||||
_textureSheedAnimationFrameSize = new Vector2(1f / _textureSheetAnimation.numTilesX, 1f / _textureSheetAnimation.numTilesY);
|
textureSheetAnimationFrameSize = new Vector2(1f / textureSheetAnimation.numTilesX, 1f / textureSheetAnimation.numTilesY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -143,13 +119,11 @@ namespace UnityEngine.UI.Extensions
|
||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
|
|
||||||
if (!Initialize())
|
if (!Initialize())
|
||||||
{
|
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void OnPopulateMesh(VertexHelper vh)
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
|
@ -161,7 +135,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// prepare vertices
|
// prepare vertices
|
||||||
vh.Clear();
|
vh.Clear();
|
||||||
|
|
||||||
|
@ -170,96 +143,134 @@ namespace UnityEngine.UI.Extensions
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 temp = Vector2.zero;
|
||||||
|
Vector2 corner1 = Vector2.zero;
|
||||||
|
Vector2 corner2 = Vector2.zero;
|
||||||
// iterate through current particles
|
// iterate through current particles
|
||||||
int count = _particleSystem.GetParticles(_particles);
|
int count = pSystem.GetParticles(particles);
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
ParticleSystem.Particle particle = _particles[i];
|
ParticleSystem.Particle particle = particles[i];
|
||||||
|
|
||||||
// get particle properties
|
// get particle properties
|
||||||
Vector2 position = (_particleSystem.main.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
#if UNITY_5_5_OR_NEWER
|
||||||
|
Vector2 position = (mainModule.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
||||||
|
#else
|
||||||
|
Vector2 position = (pSystem.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
||||||
|
#endif
|
||||||
float rotation = -particle.rotation * Mathf.Deg2Rad;
|
float rotation = -particle.rotation * Mathf.Deg2Rad;
|
||||||
float rotation90 = rotation + Mathf.PI / 2;
|
float rotation90 = rotation + Mathf.PI / 2;
|
||||||
Color32 color = particle.GetCurrentColor(_particleSystem);
|
Color32 color = particle.GetCurrentColor(pSystem);
|
||||||
float size = particle.GetCurrentSize(_particleSystem) * 0.5f;
|
float size = particle.GetCurrentSize(pSystem) * 0.5f;
|
||||||
|
|
||||||
// apply scale
|
// apply scale
|
||||||
if (_particleSystem.main.scalingMode == ParticleSystemScalingMode.Shape)
|
#if UNITY_5_5_OR_NEWER
|
||||||
{
|
if (mainModule.scalingMode == ParticleSystemScalingMode.Shape)
|
||||||
position /= canvas.scaleFactor;
|
position /= canvas.scaleFactor;
|
||||||
}
|
#else
|
||||||
|
if (pSystem.scalingMode == ParticleSystemScalingMode.Shape)
|
||||||
|
position /= canvas.scaleFactor;
|
||||||
|
#endif
|
||||||
|
|
||||||
// apply texture sheet animation
|
// apply texture sheet animation
|
||||||
Vector4 particleUV = _uv;
|
Vector4 particleUV = imageUV;
|
||||||
if (_textureSheetAnimation.enabled)
|
if (textureSheetAnimation.enabled)
|
||||||
{
|
{
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
float frameProgress = 1 - (particle.remainingLifetime / particle.startLifetime);
|
float frameProgress = 1 - (particle.remainingLifetime / particle.startLifetime);
|
||||||
frameProgress = _textureSheetAnimation.frameOverTime.curveMin.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime)); // TODO - once Unity allows MinMaxCurve reading
|
|
||||||
|
if (textureSheetAnimation.frameOverTime.curveMin != null)
|
||||||
|
{
|
||||||
|
frameProgress = textureSheetAnimation.frameOverTime.curveMin.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime));
|
||||||
|
}
|
||||||
|
else if (textureSheetAnimation.frameOverTime.curve != null)
|
||||||
|
{
|
||||||
|
frameProgress = textureSheetAnimation.frameOverTime.curve.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime));
|
||||||
|
}
|
||||||
|
else if (textureSheetAnimation.frameOverTime.constant > 0)
|
||||||
|
{
|
||||||
|
frameProgress = textureSheetAnimation.frameOverTime.constant - (particle.remainingLifetime / particle.startLifetime);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
float frameProgress = 1 - (particle.lifetime / particle.startLifetime);
|
float frameProgress = 1 - (particle.lifetime / particle.startLifetime);
|
||||||
frameProgress = Mathf.Repeat(frameProgress * _textureSheetAnimation.cycleCount, 1);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
frameProgress = Mathf.Repeat(frameProgress * textureSheetAnimation.cycleCount, 1);
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
|
|
||||||
switch (_textureSheetAnimation.animation)
|
switch (textureSheetAnimation.animation)
|
||||||
{
|
{
|
||||||
|
|
||||||
case ParticleSystemAnimationType.WholeSheet:
|
case ParticleSystemAnimationType.WholeSheet:
|
||||||
frame = Mathf.FloorToInt(frameProgress * _textureSheetAnimationFrames);
|
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimationFrames);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ParticleSystemAnimationType.SingleRow:
|
case ParticleSystemAnimationType.SingleRow:
|
||||||
frame = Mathf.FloorToInt(frameProgress * _textureSheetAnimation.numTilesX);
|
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimation.numTilesX);
|
||||||
|
|
||||||
int row = _textureSheetAnimation.rowIndex;
|
int row = textureSheetAnimation.rowIndex;
|
||||||
#if UNITY_5_5_OR_NEWER
|
// if (textureSheetAnimation.useRandomRow) { // FIXME - is this handled internally by rowIndex?
|
||||||
if (_textureSheetAnimation.useRandomRow)
|
// row = Random.Range(0, textureSheetAnimation.numTilesY, using: particle.randomSeed);
|
||||||
{
|
// }
|
||||||
Random.InitState((int)particle.randomSeed);
|
frame += row * textureSheetAnimation.numTilesX;
|
||||||
row = Random.Range(0, _textureSheetAnimation.numTilesY);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
frame += row * _textureSheetAnimation.numTilesX;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frame %= _textureSheetAnimationFrames;
|
frame %= textureSheetAnimationFrames;
|
||||||
|
|
||||||
particleUV.x = (frame % _textureSheetAnimation.numTilesX) * _textureSheedAnimationFrameSize.x;
|
particleUV.x = (frame % textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.x;
|
||||||
particleUV.y = Mathf.FloorToInt(frame / _textureSheetAnimation.numTilesX) * _textureSheedAnimationFrameSize.y;
|
particleUV.y = Mathf.FloorToInt(frame / textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.y;
|
||||||
particleUV.z = particleUV.x + _textureSheedAnimationFrameSize.x;
|
particleUV.z = particleUV.x + textureSheetAnimationFrameSize.x;
|
||||||
particleUV.w = particleUV.y + _textureSheedAnimationFrameSize.y;
|
particleUV.w = particleUV.y + textureSheetAnimationFrameSize.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp.x = particleUV.x;
|
||||||
|
temp.y = particleUV.y;
|
||||||
|
|
||||||
_quad[0] = UIVertex.simpleVert;
|
_quad[0] = UIVertex.simpleVert;
|
||||||
_quad[0].color = color;
|
_quad[0].color = color;
|
||||||
_quad[0].uv0 = new Vector2(particleUV.x, particleUV.y);
|
_quad[0].uv0 = temp;
|
||||||
|
|
||||||
|
temp.x = particleUV.x;
|
||||||
|
temp.y = particleUV.w;
|
||||||
_quad[1] = UIVertex.simpleVert;
|
_quad[1] = UIVertex.simpleVert;
|
||||||
_quad[1].color = color;
|
_quad[1].color = color;
|
||||||
_quad[1].uv0 = new Vector2(particleUV.x, particleUV.w);
|
_quad[1].uv0 = temp;
|
||||||
|
|
||||||
|
temp.x = particleUV.z;
|
||||||
|
temp.y = particleUV.w;
|
||||||
_quad[2] = UIVertex.simpleVert;
|
_quad[2] = UIVertex.simpleVert;
|
||||||
_quad[2].color = color;
|
_quad[2].color = color;
|
||||||
_quad[2].uv0 = new Vector2(particleUV.z, particleUV.w);
|
_quad[2].uv0 = temp;
|
||||||
|
|
||||||
|
temp.x = particleUV.z;
|
||||||
|
temp.y = particleUV.y;
|
||||||
_quad[3] = UIVertex.simpleVert;
|
_quad[3] = UIVertex.simpleVert;
|
||||||
_quad[3].color = color;
|
_quad[3].color = color;
|
||||||
_quad[3].uv0 = new Vector2(particleUV.z, particleUV.y);
|
_quad[3].uv0 = temp;
|
||||||
|
|
||||||
if (rotation == 0)
|
if (rotation == 0)
|
||||||
{
|
{
|
||||||
// no rotation
|
// no rotation
|
||||||
Vector2 corner1 = new Vector2(position.x - size, position.y - size);
|
corner1.x = position.x - size;
|
||||||
Vector2 corner2 = new Vector2(position.x + size, position.y + size);
|
corner1.y = position.y - size;
|
||||||
|
corner2.x = position.x + size;
|
||||||
|
corner2.y = position.y + size;
|
||||||
|
|
||||||
_quad[0].position = new Vector2(corner1.x, corner1.y);
|
temp.x = corner1.x;
|
||||||
_quad[1].position = new Vector2(corner1.x, corner2.y);
|
temp.y = corner1.y;
|
||||||
_quad[2].position = new Vector2(corner2.x, corner2.y);
|
_quad[0].position = temp;
|
||||||
_quad[3].position = new Vector2(corner2.x, corner1.y);
|
temp.x = corner1.x;
|
||||||
|
temp.y = corner2.y;
|
||||||
|
_quad[1].position = temp;
|
||||||
|
temp.x = corner2.x;
|
||||||
|
temp.y = corner2.y;
|
||||||
|
_quad[2].position = temp;
|
||||||
|
temp.x = corner2.x;
|
||||||
|
temp.y = corner1.y;
|
||||||
|
_quad[3].position = temp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -279,24 +290,45 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (Application.isPlaying)
|
if (!fixedTime && Application.isPlaying)
|
||||||
{
|
{
|
||||||
// unscaled animation within UI
|
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
|
||||||
_particleSystem.Simulate(Time.unscaledDeltaTime, false, false);
|
|
||||||
|
|
||||||
SetAllDirty();
|
SetAllDirty();
|
||||||
|
|
||||||
|
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
|
||||||
|
(material != null && currentMaterial != null && material.shader != currentMaterial.shader))
|
||||||
|
{
|
||||||
|
pSystem = null;
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
void LateUpdate()
|
void LateUpdate()
|
||||||
{
|
{
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying)
|
||||||
{
|
{
|
||||||
SetAllDirty();
|
SetAllDirty();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fixedTime)
|
||||||
|
{
|
||||||
|
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
|
||||||
|
SetAllDirty();
|
||||||
|
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
|
||||||
|
(material != null && currentMaterial != null && material.shader != currentMaterial.shader))
|
||||||
|
{
|
||||||
|
pSystem = null;
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (material == currentMaterial)
|
||||||
|
return;
|
||||||
|
pSystem = null;
|
||||||
|
Initialize();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
Shader "UI Extensions/Particles/Additive" {
|
||||||
|
Properties {
|
||||||
|
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Category {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Blend SrcAlpha One
|
||||||
|
ColorMask RGB
|
||||||
|
Cull Off Lighting Off ZWrite Off
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
#pragma multi_compile_particles
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
fixed4 _TintColor;
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_FOG_COORDS(1)
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float4 projPos : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
v2f vert (appdata_t IN)
|
||||||
|
{
|
||||||
|
v2f v;
|
||||||
|
v.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
v.projPos = ComputeScreenPos (v.vertex);
|
||||||
|
COMPUTE_EYEDEPTH(v.projPos.z);
|
||||||
|
#endif
|
||||||
|
v.color = IN.color;
|
||||||
|
v.texcoord = TRANSFORM_TEX(IN.texcoord,_MainTex);
|
||||||
|
UNITY_TRANSFER_FOG(v,v.vertex);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D_float _CameraDepthTexture;
|
||||||
|
float _InvFade;
|
||||||
|
|
||||||
|
fixed4 frag (v2f IN) : SV_Target
|
||||||
|
{
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(IN.projPos)));
|
||||||
|
float partZ = IN.projPos.z;
|
||||||
|
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||||
|
IN.color.a *= fade;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fixed4 col = 2.0f * IN.color * _TintColor * tex2D(_MainTex, IN.texcoord);
|
||||||
|
UNITY_APPLY_FOG_COLOR(IN.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e064104788d94b349ab13141a30b5660
|
||||||
|
timeCreated: 1502443970
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,108 @@
|
||||||
|
Shader "UI Extensions/Particles/~Additive-Multiply" {
|
||||||
|
Properties {
|
||||||
|
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Category {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Blend One OneMinusSrcAlpha
|
||||||
|
ColorMask RGB
|
||||||
|
Cull Off Lighting Off ZWrite Off
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
#pragma multi_compile_particles
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
fixed4 _TintColor;
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_FOG_COORDS(1)
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float4 projPos : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
v2f vert (appdata_t IN)
|
||||||
|
{
|
||||||
|
v2f v;
|
||||||
|
v.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
v.projPos = ComputeScreenPos (v.vertex);
|
||||||
|
COMPUTE_EYEDEPTH(v.projPos.z);
|
||||||
|
#endif
|
||||||
|
v.color = IN.color;
|
||||||
|
v.texcoord = TRANSFORM_TEX(IN.texcoord,_MainTex);
|
||||||
|
UNITY_TRANSFER_FOG(v,v.vertex);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D_float _CameraDepthTexture;
|
||||||
|
float _InvFade;
|
||||||
|
|
||||||
|
fixed4 frag (v2f i) : SV_Target
|
||||||
|
{
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||||
|
float partZ = i.projPos.z;
|
||||||
|
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||||
|
i.color *= fade;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fixed4 tex = tex2D(_MainTex, i.texcoord);
|
||||||
|
fixed4 col;
|
||||||
|
col.rgb = _TintColor.rgb * tex.rgb * i.color.rgb * 2.0f;
|
||||||
|
col.a = (1 - tex.a) * (_TintColor.a * i.color.a * 2.0f);
|
||||||
|
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 088bbfd9222ee044cb4e4699336e9ff1
|
||||||
|
timeCreated: 1502443969
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,104 @@
|
||||||
|
Shader "UI Extensions/Particles/Additive (Soft)" {
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Category {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Blend One OneMinusSrcColor
|
||||||
|
ColorMask RGB
|
||||||
|
Cull Off Lighting Off ZWrite Off
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
#pragma multi_compile_particles
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
fixed4 _TintColor;
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_FOG_COORDS(1)
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float4 projPos : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
v2f vert (appdata_t IN)
|
||||||
|
{
|
||||||
|
v2f v;
|
||||||
|
v.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
v.projPos = ComputeScreenPos (v.vertex);
|
||||||
|
COMPUTE_EYEDEPTH(v.projPos.z);
|
||||||
|
#endif
|
||||||
|
v.color = IN.color;
|
||||||
|
v.texcoord = TRANSFORM_TEX(IN.texcoord,_MainTex);
|
||||||
|
UNITY_TRANSFER_FOG(v,v.vertex);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D_float _CameraDepthTexture;
|
||||||
|
float _InvFade;
|
||||||
|
|
||||||
|
fixed4 frag (v2f i) : SV_Target
|
||||||
|
{
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||||
|
float partZ = i.projPos.z;
|
||||||
|
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||||
|
i.color.a *= fade;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half4 col = i.color * tex2D(_MainTex, i.texcoord);
|
||||||
|
col.rgb *= col.a;
|
||||||
|
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4c2211b120168e44db4a3a8417013615
|
||||||
|
timeCreated: 1502443969
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,104 @@
|
||||||
|
Shader "UI Extensions/Particles/Alpha Blended" {
|
||||||
|
Properties {
|
||||||
|
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Category {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Blend SrcAlpha OneMinusSrcAlpha
|
||||||
|
ColorMask RGB
|
||||||
|
Cull Off Lighting Off ZWrite Off
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
#pragma multi_compile_particles
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
fixed4 _TintColor;
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_FOG_COORDS(1)
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float4 projPos : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
v2f vert (appdata_t IN)
|
||||||
|
{
|
||||||
|
v2f v;
|
||||||
|
v.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
v.projPos = ComputeScreenPos (v.vertex);
|
||||||
|
COMPUTE_EYEDEPTH(v.projPos.z);
|
||||||
|
#endif
|
||||||
|
v.color = IN.color;
|
||||||
|
v.texcoord = TRANSFORM_TEX(IN.texcoord,_MainTex);
|
||||||
|
UNITY_TRANSFER_FOG(v,v.vertex);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D_float _CameraDepthTexture;
|
||||||
|
float _InvFade;
|
||||||
|
|
||||||
|
fixed4 frag (v2f i) : SV_Target
|
||||||
|
{
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||||
|
float partZ = i.projPos.z;
|
||||||
|
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||||
|
i.color.a *= fade;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
|
||||||
|
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c3d7d8d71a91071469ad7019e77864d6
|
||||||
|
timeCreated: 1502443970
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,103 @@
|
||||||
|
Shader "UI Extensions/Particles/Blend" {
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Category {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Blend DstColor One
|
||||||
|
ColorMask RGB
|
||||||
|
Cull Off Lighting Off ZWrite Off
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
#pragma multi_compile_particles
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
fixed4 _TintColor;
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_FOG_COORDS(1)
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float4 projPos : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
v2f vert (appdata_t IN)
|
||||||
|
{
|
||||||
|
v2f v;
|
||||||
|
v.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
v.projPos = ComputeScreenPos (v.vertex);
|
||||||
|
COMPUTE_EYEDEPTH(v.projPos.z);
|
||||||
|
#endif
|
||||||
|
v.color = IN.color;
|
||||||
|
v.texcoord = TRANSFORM_TEX(IN.texcoord,_MainTex);
|
||||||
|
UNITY_TRANSFER_FOG(v,v.vertex);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D_float _CameraDepthTexture;
|
||||||
|
float _InvFade;
|
||||||
|
|
||||||
|
fixed4 frag (v2f i) : SV_Target
|
||||||
|
{
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||||
|
float partZ = i.projPos.z;
|
||||||
|
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||||
|
i.color *= fade;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fixed4 col = i.color * tex2D(_MainTex, i.texcoord);
|
||||||
|
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 98fed5ba500a9a04a80325266b9911bb
|
||||||
|
timeCreated: 1502443970
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,103 @@
|
||||||
|
Shader "UI Extensions/Particles/Multiply" {
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Category {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Blend Zero SrcColor
|
||||||
|
Cull Off Lighting Off ZWrite Off
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
#pragma multi_compile_particles
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
fixed4 _TintColor;
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_FOG_COORDS(1)
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float4 projPos : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
v2f vert (appdata_t IN)
|
||||||
|
{
|
||||||
|
v2f v;
|
||||||
|
v.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
v.projPos = ComputeScreenPos (v.vertex);
|
||||||
|
COMPUTE_EYEDEPTH(v.projPos.z);
|
||||||
|
#endif
|
||||||
|
v.color = IN.color;
|
||||||
|
v.texcoord = TRANSFORM_TEX(IN.texcoord,_MainTex);
|
||||||
|
UNITY_TRANSFER_FOG(v,v.vertex);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D_float _CameraDepthTexture;
|
||||||
|
float _InvFade;
|
||||||
|
|
||||||
|
fixed4 frag (v2f i) : SV_Target
|
||||||
|
{
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||||
|
float partZ = i.projPos.z;
|
||||||
|
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||||
|
i.color.a *= fade;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half4 prev = i.color * tex2D(_MainTex, i.texcoord);
|
||||||
|
fixed4 col = lerp(half4(1,1,1,1), prev, prev.a);
|
||||||
|
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(1,1,1,1)); // fog towards white due to our blend mode
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 320f6bb7bde369b4a85c9d89a9ba5268
|
||||||
|
timeCreated: 1502443969
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,107 @@
|
||||||
|
Shader "UI Extensions/Particles/Multiply (Double)" {
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Category {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Blend DstColor SrcColor
|
||||||
|
ColorMask RGB
|
||||||
|
Cull Off Lighting Off ZWrite Off
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
#pragma multi_compile_particles
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
fixed4 _TintColor;
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_FOG_COORDS(1)
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float4 projPos : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
v2f vert (appdata_t IN)
|
||||||
|
{
|
||||||
|
v2f v;
|
||||||
|
v.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
v.projPos = ComputeScreenPos (v.vertex);
|
||||||
|
COMPUTE_EYEDEPTH(v.projPos.z);
|
||||||
|
#endif
|
||||||
|
v.color = IN.color;
|
||||||
|
v.texcoord = TRANSFORM_TEX(IN.texcoord,_MainTex);
|
||||||
|
UNITY_TRANSFER_FOG(v,v.vertex);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D_float _CameraDepthTexture;
|
||||||
|
float _InvFade;
|
||||||
|
|
||||||
|
fixed4 frag (v2f i) : SV_Target
|
||||||
|
{
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||||
|
float partZ = i.projPos.z;
|
||||||
|
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||||
|
i.color.a *= fade;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fixed4 col;
|
||||||
|
fixed4 tex = tex2D(_MainTex, i.texcoord);
|
||||||
|
col.rgb = tex.rgb * i.color.rgb * 2;
|
||||||
|
col.a = i.color.a * tex.a;
|
||||||
|
col = lerp(fixed4(0.5f,0.5f,0.5f,0.5f), col, col.a);
|
||||||
|
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0.5,0.5,0.5,0.5)); // fog towards gray due to our blend mode
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0765ecef58833c3429346a1fee45e4e0
|
||||||
|
timeCreated: 1502443969
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,104 @@
|
||||||
|
Shader "UI Extensions/Particles/Alpha Blended Premultiply" {
|
||||||
|
Properties {
|
||||||
|
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Category {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Blend One OneMinusSrcAlpha
|
||||||
|
ColorMask RGB
|
||||||
|
Cull Off Lighting Off ZWrite Off
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
#pragma multi_compile_particles
|
||||||
|
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
fixed4 _TintColor;
|
||||||
|
|
||||||
|
struct appdata_t {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float4 projPos : TEXCOORD1;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
v2f vert (appdata_t IN)
|
||||||
|
{
|
||||||
|
v2f v;
|
||||||
|
v.vertex = UnityObjectToClipPos(IN.vertex);
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
v.projPos = ComputeScreenPos (v.vertex);
|
||||||
|
COMPUTE_EYEDEPTH(v.projPos.z);
|
||||||
|
#endif
|
||||||
|
v.color = IN.color;
|
||||||
|
v.texcoord = TRANSFORM_TEX(IN.texcoord,_MainTex);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampler2D_float _CameraDepthTexture;
|
||||||
|
float _InvFade;
|
||||||
|
|
||||||
|
fixed4 frag (v2f IN) : SV_Target
|
||||||
|
{
|
||||||
|
#ifdef SOFTPARTICLES_ON
|
||||||
|
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(IN.projPos)));
|
||||||
|
float partZ = IN.projPos.z;
|
||||||
|
float fade = saturate (_InvFade * (sceneZ-partZ));
|
||||||
|
IN.color.a *= fade;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return IN.color * tex2D(_MainTex, IN.texcoord) * IN.color.a;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0596a6838d78f624397b642817cf20bc
|
||||||
|
timeCreated: 1502443969
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,42 @@
|
||||||
|
Shader "UI Extensions/Particles/VertexLit Blended" {
|
||||||
|
Properties {
|
||||||
|
_EmisColor ("Emissive Color", Color) = (.2,.2,.2,0)
|
||||||
|
_MainTex ("Particle Texture", 2D) = "white" {}
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||||
|
Tags { "LightMode" = "Vertex" }
|
||||||
|
Cull Off
|
||||||
|
Lighting On
|
||||||
|
Material { Emission [_EmisColor] }
|
||||||
|
ColorMaterial AmbientAndDiffuse
|
||||||
|
ZWrite Off
|
||||||
|
ColorMask RGB
|
||||||
|
Blend SrcAlpha OneMinusSrcAlpha
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
|
||||||
|
SetTexture [_MainTex] { combine primary * texture }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65bbb789ada58ab44aaedbe09687f089
|
||||||
|
timeCreated: 1502443969
|
||||||
|
licenseType: Free
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue