5.6.0b4 disable instancing on vertex/fragment shader

Hi, so reading the release notes:

“#pragma multi_compile_instancing” line now is no longer needed in surface shaders. Instancing variants are automatically generated for surface shaders, unless you explicitly specify “noinstancing” in “#pragma surface” line."

I’d like to know how to add “noinstancing” to my Vertex/fragment shader?

I’m getting warnings on my static Meshes that use my non surface Shader:

Is there something I can add to my Shader that tells it not to use instancing? Or is this a bug?

Hey,

Handwritten vertex/fragment shaders don’t have instancing automatically generated unless, like before, you added #pragma multi_compile_instancing line in the shader, which seems to be your case.

I will update this warning message to make it disappear if instancing is not enabled. Thanks for reporting.

Nice, thanks

Just to confirm, I have a mobile VR project with some custom shaders, I need to add #pragma multi_compile_instancing to the shader code for Instancing to be enabled? Unity won’t add it in for me automagicically in 5.6?

Is that all that is needed to add instancing support? Is adding ‘#pragma multi_compile_instancing’?

I have some shaders based on the Mobile/Diffuse Specular bump map shader and thought Instancing could give me a performance boost. I’m not a shader expert by any means :slight_smile:

Hello Justin,

Since 5.6 beta 4, to actually enable instancing, you’ll need to select your Material that is intended to be used on instanced objects and click “Enable Instancing” checkbox. you don’t need to add “#pragma multi_compile_instancing” to the shader unless you don’t see this checkbox.

Instancing comes with some overhead on GPU and will only benefit projects that have a large amount of identical objects to render and the FPS is bound by CPU processor power. Often you don’t have out-of-the-box performance boost by simply make everything instanceable.

1 Like

How can you set the enable instancing state of a material through code?

EDIT: nevermind I was looking at the wrong assembly. Theres a Material property for that.