I have a texture which is generated procedurally at runtime. This texture is then applied to a procedurally created quad for use as a particle in my own particle system I am developing.
The quad mesh has vertex colors set by code. And when combined with this simple shader (below) it works as expected, if I make all the vertex colors red, I get a red texture.
What is frustrating is that I cannot get BLACK particles to show up! Like smoke, even though the alpha is set to 1 (255) in my vertex colors, the black RGB vertex colors cause the whole thing to become transparent…
Shader "Particles/Custom"{
Properties{
_MainTex ("Particle Texture", 2D) = "white" {}
}
Category{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
Blend SrcAlpha One
Cull Off Lighting Off ZWrite Off Fog {Color (0,0,0,0)}
BindChannels{
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
SubShader{
Pass{
SetTexture [_MainTex]{
combine texture * primary
}
}
}
}
}
I think what I need to do is read the alpha information from _MainTex.a and multiply _MainTex.rgb with my vertex colors, but shaders have never been my strong point! If anyone could throw me a bone here that would be great.
I don’t want to use the other built in shaders like multiply, that’s not the result i’m looking for. In the end I want to use the vertex colors to fake lighting effects…
It states in the documentation:
"Separate Alpha Color computation By default, the combiner formula is used for calculating both the RGB and alpha component of the color. Optionally, you can specify a separate formula for the alpha calculation. This looks like this:
SetTexture [_MainTex] { combine previous * texture, previous + texture }
Here, we multiply the RGB colors and add the alpha."
I changed my combiner line to this but it hasn’t really helped, then again, I have no idea what I’m doing…