About ModelComponent.isStatic Perf

The documentation says that setting a model as static is an “optimization.”

Under what conditions would I see the best performance gains from using isStatic? Is it better for single large meshes vs many smaller meshes?

I ask because i was noticing a better fps when I had isStatic set to false on my non-moving objects (multitudes of them) and also a lot less material switches.

1 Like

It only worth if you have multiple dynamic lights that potentially can affect only part of large meshes.
By having light and model set to static, that model mesh then will be split into smaller chunks based on lights overlaps, etc, so that shader on those pieces will be simpler, including only lights that affect that particular piece.

Do you have example project where performance is worse with static?

Thanks for the response. It seems I don’t need to use isStatic then. I don’t have an example project no. I saw the perf issue in my production project and can’t easily separate out the example at the moment. I’ll put something together when I get some time. I can describe it though. I had multiple meshes with about 20-30 verts each that got dynamically created into the scene and positioned based on some data (like props in a level). They all shared the same material. I made a lot of them and set them all to static. I saw render time and material switches increase in the profiler.

If they were sharing Vertex Buffers, then indeed, they will get separated. In such case if there is one or few lights and they do affect all of those models, then static model/light wont make sense. But if you have many lights in scene, but they don’t overlap much and there is good variation but together many light - then static make huge difference.

You basically trading more CPU work (switches of buffers and materials) against more fill-rate, heavier shaders.