Simple "Render on Top of Everything" Shader?

Hey guys!,

i’ve been trying with no success to make a simple Render on Top of everything with shadows Shader, i cant figure out how to render on top of the terrain grass, and receive normal geometry shadows… wondering if you guys could turn me into the right direction.

  • *Render on top of everything ( will be used for the Player Hands and
    Weapon’s Mesh materials)
  • *Receive Shadows from geometry around the world
  • *100% Diffuse, am not looking for anything else, plain texture/color
    diffuse, no transparency nor maps.

Where i am at:

  • “Queue” = “AlphaTest+10”
  • ZTest Off

Doing this almost achieves what i need, but it leads me to a weird transparency like problem, where the material dosnt block/cull same material polygons that are behind, its like, am rendering every triangle even on top of others of the same material, so i think it has to do with the ztest? probably? how could i make the shader cull or ztests only on itself?

What i want to achieve:

  • Use only the projection matrix with
    modified znear/zfar (custom
    projection, no inaccuracy issues)
  • Pass 1 – clear the depth buffer
    (renders the mesh, but only clears
    the depth)
  • Pass 2 – render (renders the mesh as
    normal, depth isn’t an issue)

Thanks!

If I understand your problem correctly you need to overlay a texture on top of another? In order to do that you could try combining the color data in one pass but it would be much better and give you better results to simply do two separate passes for each texture. And you said you didn’t want transparency but you’re going to need it if you want anything to show through on the overlaid texture, otherwise it’s just going to show the last texture that was rendered. I just happened to have made an overlay shader recently:

Shader "Custom/TextureOverlay" {
	Properties {
		_MainTex ("Main Texture (RGBA)", 2D) = "white" {}
		_OverlayTex ("Secondary Texture (RGBA)", 2D) = "white" {}
		_Transparency ("Transparency", Range(0,1)) = 0.85
	}
	SubShader {
		CGPROGRAM
		#pragma surface surf Standard fullforwardshadows 
		#pragma target 3.0

		struct Input {
			float2 uv_MainTex;
		};

		sampler2D _MainTex;

		void surf (Input IN, inout SurfaceOutputStandard o) {
			fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
			o.Albedo = c.rgb;
			o.Alpha = c.a;
		}
		ENDCG
		Blend SrcAlpha OneMinusSrcAlpha
		ZWrite Off
		CGPROGRAM
		#pragma surface surf Standard fullforwardshadows alpha
		#pragma target 3.0

		sampler2D _OverlayTex;
		float _Transparency;

		struct Input {
			float2 uv_OverlayTex;
		};

		void surf (Input IN, inout SurfaceOutputStandard o) {
			fixed4 c = tex2D (_OverlayTex, IN.uv_OverlayTex);
			o.Albedo = c.rgb;
			o.Alpha = _Transparency * c.a;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

I’m not sure if that’s what you were after but at least it should get you started in the right direction.