I’m creating a mesh that consists of a bunch of cubes. I want to make the cubes transparent based on the alpha channel. I’ve tried a bunch of different things, but I have been have some weird issues. I haven’t found a whole lot of documentation that deals with this, but I’m also fairly new to shaders, so any help would be appreciated!
I’ve set the alpha channel to 1 (fully opaque), yet the color of some background cubes still appears on top of foreground cubes. This behavior appears to be inconsistent.
I’ve circled two regions in the above screenshot. The one on the lower-left shows a foreground cube that properly occludes background cubes. The one in the upper-middle shows a foreground cube that does not properly occlude background cubes.

This is shader I am using currently, but have tried a bunch of different iterations (taking lines out, etc.):
Shader "Custom/Vertex Transparent" {
Properties{
_Color("Color", Color) = (0,0,0,1)
_MainTex("Base (RGB)", 2D) = "white" {}
}
SubShader{
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent" "AllowProjectors" = "False" }
Blend One OneMinusSrcAlpha
CGPROGRAM
#pragma surface surf Standard alpha:fade
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
float4 color : COLOR;
};
void surf(Input IN, inout SurfaceOutputStandard o)
{
half4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = IN.color.rgb;
o.Alpha = IN.color.a;
}
ENDCG
}
}
Any idea where I’m going wrong?