I have a bit of a problem with Z-ordering on my shader here.
If i have the shader alone with a blank background i see it clearly, however if something comes behind it, it will be put ontop of the object with the shader on.
if i take the #pragma and remove the alpha part the Z-ordering issue is fixed but offcause sadly also disables transparency.
Can anyone point out what i am missing to get the Z-ordering back in place?
Shader "Example/Displacement" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_DisplaceTex ("Displacement", 2D) = "white" {}
_Amount ("Extrusion Amount", Range(-1,1)) = 0.5
}
SubShader {
Tags { "RenderType" = "Transparent" }
CGPROGRAM
//REMOVING "alpha" from the following statement will fix the zorder issue
#pragma surface surf Lambert alpha vertex:vert
uniform float4 _DisplaceTex_ST;
struct Input {
float2 uv_MainTex;
};
float _Amount;
sampler2D _DisplaceTex;
void vert (inout appdata_full v) {
float2 sh_uv = v.texcoord.xy * _DisplaceTex_ST.xy + _DisplaceTex_ST.zw;
float4 sh_tex = tex2Dlod(_DisplaceTex, float4(fmod(sh_uv.x,0.999999f),sh_uv.y,0,0));
v.vertex.xyz += v.normal * _Amount * sh_tex.y;
}
sampler2D _MainTex;
void surf (Input IN, inout SurfaceOutput o) {
o.Emission = tex2D (_MainTex, IN.uv_MainTex).rgb;
o.Alpha = 1.0f; //tex2D (_MainTex, IN.uv_MainTex).w;
}
ENDCG
}
Fallback "Diffuse"
}