GUI atlas alpha blending was working but now doesn't.

Hi,

We’ve been using a GUI atlas for our current project and recently the alpha blending shader has stopped working the way it was a few builds back. I have attached a screen of the issue. If anyone is able to help I’d be very grateful. We have a deadline tomorrow…

We’re using this shader:

Shader "Particles/Alpha Blended Z-enabled" {
Properties {
	_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
	_MainTex ("Particle Texture", 2D) = "white" {}
}

Category {
	Tags { "Queue" = "Transparent" }
	Blend SrcAlpha OneMinusSrcAlpha
	AlphaTest Greater .01
	ColorMask RGB
	Cull Off Lighting Off ZWrite On Fog { Color (0,0,0,0) }
	BindChannels {
		Bind "Color", color
		Bind "Vertex", vertex
		Bind "TexCoord", texcoord
	}
	
	// ---- Dual texture cards
	SubShader {
		Pass {
			SetTexture [_MainTex] {
				constantColor [_TintColor]
				combine constant * primary
			}
			SetTexture [_MainTex] {
				combine texture * previous DOUBLE
			}
		}
	}
	
	// ---- Single texture cards (does not do color tint)
	SubShader {
		Pass {
			SetTexture [_MainTex] {
				combine texture * primary
			}
		}
	}
}
}

Cheers,
Dan.

Doesn’t appear to be a very good shader for the job, though I don’t know all that you need. You need to move the buttons into a later queue than the background image; the rendering order of triangles is random, so they can’t use the same mesh.

Thanks Jessy. The background image is actually just a fill (no image used). I think, though, that all of the GUI elements are using a single mesh. Sounds like that may be our problem.

By “background image”, I meant the brown horizontal stuff behind the round thingies. Also, I meant they can’t use the same mesh with that shader. You can do it with a “decal”-type shader though.

Actually, I’m curious. why would this change? Is it because we’ve added new GUI elements which causes the triangle sorting order to change?

That may have contributed (though it’s not actually sorting anything, as happens per-object in the higher rendering queues). But it’s up to chance. Like I said, the order was always unpredictable. (I’m sure it wasn’t actually “random”, but close enough, to a human, and not a GPU.) In my experience, you tend to get the same results frequently, which can make you think that you’re safe, but you’re not. It used to be that an easy way to check for this, was to throw things into Unity or Unity iPhone, because this kind of rendering almost always behaved differently in each app. Nowadays, I’m not sure if there’s a similar trick. Preparing for the worst, even if you never see it yourself, is generally a good idea when you’re using alpha blending. Assume that your triangles and objects are going to render in a stupid order, and safeguard yourself against it.