I’m trying to have a custom cutout shader cast shadows (blue arrow), and allow shadows to be seen through the cutout (red arrow). As you can see, none of that is happening right now.
(Its a cube with the cutout shader intersecting a default cube below, viewed from the top with an orthographic camera)
I need a custom shader because the border cutout detail is stored in a separate detail texture. My shader code is below:
Shader "Custom/TerrainShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_DetailTex ("Detail (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="AlphaTest" "RenderType"="TransparentCutout" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows alphatest:_Cutoff
#pragma target 3.0
sampler2D _MainTex;
sampler2D _DetailTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv2_DetailTex;
};
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color * tex2D(_DetailTex, IN.uv2_DetailTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Transparent/Cutout/Diffuse"
}
It is based on the old Transparent/Cutout/Diffuse shaders, but also samples the detail texture I described.
If I change the Queue to Overlay, it draws on top of the shadow casting and I can see shadows through the cutout (red arrow), but obviously it doesn’t cast its own shadows then. I think I have to alter the shadow pass to make it discard the alpha pixels in the detail texture, but that wouldn’t solve the problem pointed at by the red arrow, I think.
Any ideas?