Tag Strings

Hi, long time listner first time poster …

I’ve read several posts regarding the use of tags in the render queue and they all sound like something below should be possible.

Shader "Noob Depth Shader" {
Properties {
       _Priority ("Depth", ????) = ?????
	_MainTex ("Base (RGB)", 2D) = "white" {}
}

Category {
	Blend AppSrcAdd AppDstAdd
	Fog { Color [_AddFog] }
	Tags {"Queue" = "Geometry+" + ???? }

The problem is that the shader documentation doesn’t mention any use of strings as properties.

Does this mean I’m going to have to hard code the statement

Tags {"Queue" = "Geometry+1" }

requiring a separate shader for each queue?

Sooo I’ve created a shader based on the standard vertex shader :

Shader "Depth-VertexLit5" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_SpecColor ("Spec Color", Color) = (1,1,1,1)
	_Emission ("Emmisive Color", Color) = (0,0,0,0)
	_Shininess ("Shininess", Range (0.01, 1)) = 0.7
	_MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader {
	// Normal rendering pass
	Pass {
		Tags {"Queue"="Geometry+5"}			
		Material {
			Diffuse [_Color]
			Ambient [_Color]
			Shininess [_Shininess]
			Specular [_SpecColor]
			Emission [_Emission]
		} 
		Lighting On
		SeparateSpecular On
		SetTexture [_MainTex] {
			Combine texture * primary DOUBLE, texture * primary
		} 
	}
etc ...

The picture below shows a blue plane with this shader directly over a yellow plane with the standard vertex shader.

The cameras Near/Far plane is set at 5/40.

Any suggestions?

98089--3808--$zfighting_313.jpg

The RenderQueue will make Unity render the object before or after other objects.

However, in your case the objects seem to be in exactly the same positions, so no matter what order Unity renders them, the graphics card will still determine their visibility based on depth buffer. If you want to “pull” the object slightly towards the viewer when rendering, you could try using “Offset -1,-1” in the shader.

Thanks Aras

Spookily I’ve only just come across that in other posts and in the shader documentation - and I’m experimenting with it now.

Can you give me an explanation of what those rather arcane looking parameters do?

The reason I ask is that I may have more than one object lying in the same place - i.e 3 playing cards on top of each other so can I do:
Card A: Offset 0,0
Card B: Offset -0.5, -0.5
Card C: Offset -1, -1

To make C appear on top of B, B on top of A?