Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shader[Custom/Terrain]: Incompatible texture type #25

Open
Sparksx opened this issue Apr 8, 2020 · 4 comments
Open

Shader[Custom/Terrain]: Incompatible texture type #25

Sparksx opened this issue Apr 8, 2020 · 4 comments

Comments

@Sparksx
Copy link

Sparksx commented Apr 8, 2020

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

@erikbethke
Copy link

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();
	}

@rikkcarey
Copy link

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)...

@erikbethke
Copy link

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...

@erikbethke
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants