DrawMesh/DrawMeshInstanced do not work in-game
I'm trying to optimize some path indicator rendering, and I switched it from using gameObjects for each indicator to a direct call to DrawMesh.
This works great in-editor, it behaves exactly as expected. But it does not work on the target build. I've checked the shader to make sure instancing is properly enabled, which it is. But still, nothing appears.
There are no errors, the call to DrawMeshInstanced or DrawMesh (I've tried both) does occur but the render call does not appear in the frame profiler.
I'm certain it's not just being clipped, or if it is being clipped, I'm not certain why.
The indicators draw OK if they're dropped directly in the scene, so it doesn't appear to be a shader issue.
Answer by bisc67 · Feb 20, 2020 at 06:46 PM
I did manage to figure it out.
There was no "INSTANCING" version of the shader actually included in the build. I had to adjust graphics properties to switch stripping to "Strip Unused" and also add the shader types to the variants collection.
No error was received from this; probably because the material existed (with instancing enabled) but there was no compiled variant of the shader it could use.
It WOULD be helpful if it'd at least shown a pink shader. Better still, return an error.
Your answer
Follow this Question
Related Questions
GPU Instancing works strangely on android 0 Answers
How to make trail glow through shaders? 1 Answer
Multiple UV on mesh 1 Answer
How to achieve smooth (non Rippling) skybox gradient with shaders? 0 Answers
Unity shaders/materials outside unity enviroment,Unity object export with shaders from shadergraph 0 Answers