I’m using the built-in Unity particle system to generate some water effects.
Instead of using the Particles/Alpha Blended Premultiply shader, I use a simple one because of mobile targetting:
Shader "Custom/Tinted Alpha Blend"
{
Properties {
_Color ("Color Tint (A = Opacity)", Color) = (1,1,1,1)
_MainTex ("Texture (A = Transparency)", 2D) = ""
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend One OneMinusSrcAlpha
Cull Off Lighting Off ZWrite Off
Pass {
SetTexture[_MainTex] {Combine texture * constant ConstantColor[_Color]}
}
}
}
This obviously doesn’t include any particle system properties like the “Color over lifetime” property so particles will become transparent at the end of there life. In the Alpha Blended Premultiply shader I found this:
I don’t know much about shaders but when I remove the i.color.a part (last line), the transparency is gone so it looks like this is the crucial part.
Is it possible to implement this feature in the simple shader without including UnityCG.cginc or other advanced shader stuff?
Awesome! One little thing: I’ve changed “Blend SrcAlpha OneMinusSrcAlpha” to “Blend One OneMinusSrcAlpha” because I only have a premultiplied texture, so when using SrcAlpha there is a typical black glow. When I change it to One, the color seems fine but it doesn’t fade entirely.