Hi all,
To simplify, I am creating a Minecraft-like game that is using a single texture file to display each blocks in each chunk (10x10x200 blocks). The texture file contains both opaque and semi-transparent textures for different types of blocks. Pretty standard for a Minecraft-like game.
However, instead of using “cutout transparency”, I want to make full use of my semi-transparent textures, but I cannot get it to work: some opaque blocks let blocks behind them be visible under certain angles (cf. image with legend for reference).
Legend: blocks of sand that should be behind the tree in the center but are visible within/through a block of the trunk. There are also numerous issues with how the sand, soil and foliage blocks are being displayed with locally some blocks looking both in front and at the back of other blocks.
The texture atlas (a .PNG file) is set to standards:
And here is the shadder I use (a trimmed down and slight modification of a StandardSurfaceShader):
Shader "Custom/StandardSurfaceShader_test"
{
Properties
{
_MainTex ("Texture Atlas", 2D) = "white" {}
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
LOD 100
CGPROGRAM
#pragma surface surf Lambert alpha addshadow
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
How can I fix this issue?
Am I trying to do something the wrong way?