- Home /
How to: vertex colored mesh shader that doesn't break Sprite Manager.
So I'm using this shader to display a mesh that just renders based on its vertex colors, with transparency:
Shader "Vertex color alpha" {
Category {
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
}
SubShader {
Blend SrcAlpha OneMinusSrcAlpha
Pass {}
}
}
}
I don't really understand shaders, but I managed to cook it up by looking at some vertex colored shaders people had written, and then adding some stuff.
Everything was working great, and stuff that was underneath the mesh (just stuff with colored material with a generic Diffuse) shader was rendering correctly. But now I'm starting to use Sprite Manager to render some of the stuff below the mesh, and it won't render correctly anymore.
Basically anything that should be rendered with sprites by Sprite Manager doesn't render at all, if it's on the other side of this mesh. How can I change my mesh shader so that it still works the same way, but sprites on the other side will still render?
For reference, here's the Sprite Cutout shader that Sprite Manager uses:
Shader "Sprite Cutout"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
Category
{
SubShader
{
Pass
{
ColorMaterial AmbientAndDiffuse
Lighting Off
ZWrite On
Alphatest Greater .3
Cull Off
SeparateSpecular Off
//Blend SrcAlpha OneMinusSrcAlpha
SetTexture [_MainTex]
{
//constantColor [_Color]
Combine texture * primary, texture * primary
//Combine texture * constant DOUBLE, texture * constant
}
}
}
}
}
Any help would be greatly appreciated. Thanks!
Answer by Xroft666 · Oct 23, 2012 at 12:33 AM
I am not sure if I've gotten the problem.. But! As I understood, you have a mesh with your shader which is not rendered when you look at it from its back. If it is so, then here you are: a modified piece of your shader. I could give some explanations about it if it is necessary.
SubShader {
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
ZWrite Off
Pass {}
}
No, the problem is that when I have a Sprite $$anonymous$$anager sprite on the other side of the mesh, the sprite isn't rendered.
Thanks for the answer though
okay, random thouth:
Add also "ZWrite Off"
All transparents must not write to z buffer