noob blending issue on vertex color transparent shader

Hi,

I’ve got this shader, is a modified version of a vertex color shader found on wiki

Shader "Transparent/VertexLit Colored" {

	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
		_CutOff ("Cutoff", Range (0,1)) = 0.3
	}

	SubShader {
		Alphatest Greater 0
		
		Tags { "Queue" = "Transparent" }
	
		Blend SrcAlpha OneMinusSrcAlpha     // Alpha blending

		ColorMask RGB
		Pass {
			ColorMaterial AmbientAndDiffuse
			Lighting Off
			
			SetTexture [_MainTex] {
				Combine texture * primary
			}

			SetTexture [_MainTex] {
				ConstantColor [_Color]
				Combine previous * constant
			}
		}
	}

	Fallback "Alpha/VertexLit", 1
}

I’m not really into shader programming so don’t know what it can cause the problem, anyway when two texture with this shader overlaps I get some blending issue, a screenshot is better than a thousand words (expecially with my english)… the object in that screenshot have all the same Y component

Hope that some of you gurus can help me to easily find a solution :slight_smile:

Thank you

473316--16641--$blending_issue.jpg

You need to turn of Z writing to make sure your transparent objects don’t block one another:

ZWrite Off

Hi,
thanks it works in that case but on some meshes it gives me some sorting issues.
the first screenshot is with zwrite off, the second one with zwrite on

is it normal?
should I add some more instruction to prevent this?


For billboards like that, you should use a Transparent/Cutout shader (except on telephones).