I have a strange problem I am unable to diagnose. The sorting of my scene objects gets messed up based on the material used.
In this image, you can see the middle tile overlaps the ball (which should be in front):
In this image, when I change the material of the tile, it draws as expected:
I am using 2 materials, but they both have the exact same shader applied. Here is the shader code:
Shader "Unlit/Unlit RGB x Tex"
{
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1)
}
SubShader {
Lighting Off
cull off
ztest always
Zwrite on
Tags {"Queue" = "Geometry" }
Pass {
SetTexture [_MainTex] {
constantColor [_Color]
Combine texture * constant, texture * constant
}
}
}
}
Both materials are set up identically, with only the textures being different:
Neither texture has an alpha map. Both are the same dimensions. Both have the same import settings, and filter settings. They are identical in format, only differing in the pixel values.
I’ve even tried forcing the RenderQueue via a script, setting all Tiles to renderQueue 1010 and the player ball to renderQueue 1020. Exactly the same result.
Now while the texture is the only thing that differs between these two materials, if I change the texture of the problem material, it STILL draws in front. If I change the material on the object, it draws correctly.
Any suggestions?