Shader[Custom/Terrain]: Incompatible texture type
Hi,
I'm currently at ep18 and i got this strange warning thousands times in my console: Metal: Shader[Custom/Terrain]: Incompatible texture type [MTLTextureType2D] of texture bound at index 1, expected [MTLTextureType2DArray]
After some researches, I got this warning until I clic on update button in my default texture (Terrain Assets/Default Texture) The only thing we can found online is this stackoverflow question
Did you have any idea for a fix about that? I'm on unity 2019.3.3f1
Thanks
There is a race condition here. To solve it I simply used Invoke and created the terrain 0.1 seconds later:
TerrainGenerator.cs
void Start()
{
Invoke("CreateTerrain", 0.1f);
}
public void CreateTerrain()
{
textureSettings.ApplyToMaterial(mapMaterial);
textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
float maxViewDst = detailLevels[detailLevels.Length - 1].visibleDstThreshold;
meshWorldSize = meshSettings.meshWorldSize;
chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / meshWorldSize);
UpdateVisibleChunks();
}
Crap. I tried your fix but still see the Metal errors. It does feel like a race condition... Code seems to be sending a single texture rather than an array (i.e. splat map)...
So it is an ugly race condition, as my startup code has become more heavy, I have had to increase from 0.1 seconds to now 0.3 seconds. I am sure there is a stronger callback we should be using when all of the shaders have been created... but try a longer invoke...
I finally solved this for me game for good by creating the terrain mesh behind the view of a full screen view that is modal waiting for the player's action.