Ver. 2021.3.9 - Newly introduced error for DrawMeshInstanced calls in codes

A lot of our projects and products rely on our custom GPU renderer based on Graphics.DrawMeshInstanced calls to render models efficiently. Now suddenly after +8 years of working with this API, in Unity 2021.3.9 we receive this error:

However the models are still being rendered properly but this error spams the console and makes the projects unusable. This also leads to a state where even none of Unity’s own standard shaders working and receiving the same error!

Since our solution was based on DrawMeshInstanced and we chose this to avoid needing to touch any shader codes whether it’s a custom shader or Unity’s and was working on all shaders by default, but it broke the entire ideology and affected our development heavily.

So guides and hints on this from Unity graphics staff is strongly needed here since I guess it affected a lot of users.

2 Likes

The mentioned behavior and error comes from this line in the changelog:

here: Unity 2021.3.9

I got this after upgrading to 2022.1.16f1 (from 15f1).

This behavior stopped our development, an input to address this from Unity graphics team is highly needed!

Thanks for the report. What shaders do you use with DrawMeshInstanced?

Hi!
We used to silently ignore this (shader not reading any instanced properties and using instanced rendering). This lead to incorrect behaviour when used. After this fix it’s promptly issuing an error.

1 Like

Thanks for the heads up on this. For the past few days, we were trying to sync an instanced shader with DrawMeshInstanced without receiving this error but none worked. It is really appreciated if you could share a simple instanced shader which works without errors since we tried every possible instancing data in shaders but failed!

And by this, you mean even none of Unity’s built-in shaders will work with DrawMeshInstanced anymore! That’s sad to hear!

Looks like we have an incoming bug report about this :eyes:
I’ll post an issue tracker link when it’s there.

1 Like

Thank you so much for the follow-up on this. Please let us know if it is confirmed as a bug and its condition in issue tracker.

Just a quick + 1 from me. Relying on this for my Grass Solution as well.

OK, looks like we found the culprit. It doesn’t find any instanced properties when it’s compiling variants asynchronously. We’ll fix this, the error can be safely ignored and if it doesn’t appear in the player.

5 Likes

Thanks for the update! Looking forward to the fix.

For me, this only appears when teleporting player to a different location, then the game crashes. A Fix would be extremely welcomed.

Do you use TerraWorld?

I’m having similar issues with my grass shader. I’ve tried disabling the asynchronous compilation of shaders; which makes the error go away while editing the scene.

However, when opening a Prefab to edit it; the log is spammed with 999+ of the same error as discussed, almost instantly. Might be something there as well? The grass renders perfectly fine; it just makes it somewhat unworkable as I have difficulty seeing actual errors.

EDIT: Forgot that you can just collapse the console to atleast have these errors bundled together. That’s workable enough for now I suppose! Hopefully a fix can be made soon. My Unity version is 2022.1.18f1

I’m just tired of all the unity’s bug, have a quick proof of concept to make this morning …
This is just killing productivity.
@TerraUnity Did you find a “work around”

Regarding the perpetual issue I have with unity since like 3 / 4 years (after 10 years working on several project)
I’m considering to stop my subscription and find a another dev tools.

1 Like

Any idea when? Because it’s still happening in 2021.3.11.

It landed recently in 2023.1.0a16, backports will follow.

1 Like

So no idea then when the fix will be released for Unity 2021? The version the bug was reported for? The LTS version that’s supposed to be stable? Because that information might actually be useful. :roll_eyes:

I’d say around 3-4 weeks.

3 Likes

Disabling the asynchronous compilation of shaders in Graphics settings will stop these errors in the editor so you can try out before the official fix.

2 Likes