Trouble with ZWrite

Hi,

I’m trying to create a simple shader that draws its geometry on top of everything else. Here’s where I am.

Shader "Custom/Unlit ZtestAlways" {
	Properties {
		_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
	}
	SubShader {
		Tags { "Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Transparent"}
		LOD 200
		ZTest Always
		
		CGPROGRAM
		#pragma surface surf Lambert

		sampler2D _MainTex;

		struct Input {
			float2 uv_MainTex;
		};

		void surf (Input IN, inout SurfaceOutput o) {
			half4 c = tex2D (_MainTex, IN.uv_MainTex);
			o.Albedo = c.rgb;
			o.Alpha = c.a;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

I have it in the overlay queue, so the rest of the scene (terrain) should be rendered already, I would have though. ZTest is set to Always. The geometry using this shader still gets obscured by the landscape. Note that i’ve not put any Alpha blending in yet as I am just testing the ztest.

Must be something dead obvious, does anyone have any thoughts?

Thanks,

/Mike

Surely you want ZTest Off? Otherwise it will ZTest it and then occlude your geo by what’s already in the ZBuffer?

Hehe, yes, you are correct - I was thinking that “Always” always passed the test.

Thanks:)

That doesn’t exist.

No. Always does always pass the test.

Your shader is not “unlit”. I can’t tell you why it’s failing, unless the landscape is also in the overlay queue and this mesh is behind the landscape.

Ah, my bad :stuck_out_tongue: