Instanced Meshes

Hello everyone,

does Needle support InstancedMesh out of the box? E.g. with the static options or similiar? Would be a nifty feature I guess :slightly_smiling_face:

@cetaryl

Original Post on Discord

by user 827095900392259645

Yes it does (if the material is set to use instancing)

Internally it gets translated to Three’s InstancedMesh implementation

You can use ?debuginstancing to see instanced rendering colorcoded

I am once again baffled how feature packed needle already is. Thanks, Marcel!

by user 827095900392259645

Oh. Not baffled, stunned :slightly_smiling_face:

by user 827095900392259645

@marcel :cactus: Right now we’re trying to optimize Performance and to decrease Draw calls. Funny enough, if i change the materials of one structure to use GPU Instancing and disable static batching, the draw calls actually increase (625 → 650).

Using ?debuginstancing i can see that instancing is being applied but I’m a bit lost where to start decreasing the draw calls. Do you have a hint in which direction to look? So far, we replaced all realtime lighting with baked lightmaps

by user 263717937473519619

Hello @cetaryl do you think you could send a repro and a link to your deployed project for me to check? (can be PM)

use GPU Instancing and disable static batching’, the draw calls actually increase
How are you measuring draw calls right now? Static batching only applies to Unity at the moment

sure, will clear some stuff and then send you a link and repro :slightly_smiling_face:

by user 263717937473519619

we expose the renderer to the window and then access it via the console

by user 263717937473519619

Thank you

good morning, @marcel :cactus: did you have a chance to take a look at the repro? :slightly_smiling_face:

by user 263717937473519619

Hello @cetaryl not yet unfortunately

Just a quick question: Could it be an issue with one mesh having multiple materials?

by user 827095900392259645

It shouldnt

Okay, I think there’s no need to look anymore @marcel :cactus: – I’m pretty sure we’re having some setup issues with material references. I just confirmed with a test scene, that Needle does in fact create instancedmeshes and only one material that is referenced from each mesh then. Somehow we still end up with hundres of materials in our scene, which obviously drives the number of draw calls extremely high. It’s pretty sure not a needle issue, but something with our scene.

by user 827095900392259645

Are those objects all using the same material in Unity?

No, they weren’t. I dont know for sure why, but as I said it was a problem with our scene, not Needle :slightly_smiling_face:

by user 827095900392259645

Ah ok :slightly_smiling_face: