hello, everyone. I draw something by means of Graphics.DrawMeshInstanced in scripts. It’s working in unity editor, and you can see below picture in unity frame debugger.

But…after build windowsplayer, Graphics.DrawMeshInstanced does not draw anything. My gpu instancing material attaches the mono scripts. And I check the shader has #pragma multi_compile_instancing. The material has enable gpu instancing toggle. The SVC also has the keyword INSTANCING_ON.
Which stage may be wrong, please tell me, thanks.
I think that most likely you have to set Project Settings > Graphics > Shader Stripping > Instancing variants to Keep all. You might also have to add your shader to Always included shaders in case the shader isn’t used anywhere on a material in a scene.
It’s also a good idea to start using RenderDoc to inspect frames. It gives you a very detailed breakdown of everything that is happening on the GPU, so you can easily tell if for instance the draw call is being executed in the first place, if the mesh is empty, if it is being drawn off screen, etc.
1 Like
Thanks for your answer. I tried the RenderDoc, but no such frame data. The Graphics.DrawMeshInstanced’s draw call has gone. However,in AB bundle debug mode,the material, the shader, the mesh are available. This makes me feel more stranger.
Is there a performance problem with the method Instancing variants to Keep all you said? Now my graphics setting instancing variants is strip unused.
1 Like
No, it should only be a slight increase in build time and build size. I’ve had the same issue as you had - when you’re not using an instanced variant of a shader directly as a material, Unity removes it, and then your custom draw call won’t work.
As for RenderDoc, you can make your life easier by wrapping your graphics calls in a command buffer and giving it a descriptive name. When you then make a development build, those names are retained, and you can see them inside the RenderDoc timeline.
1 Like