Optimization Tips Wanted When Enabling Models

My game is running at 60fps no problem .

I enable a large amount of models (which have already been loaded) behind my camera and there is a very slight drop in fps for just a half second as I do this.

BUT… when i turn my camera to view the newly enabled models the frame rate drops significantly for several seconds until all models are in view and then the fps returns to 60fps again.

What is the cause of this (graphics memory?) and how can I avoid it or soften the blow. Any advise welcome!
Thanks

The Chrome profiler should show you what is taking the time, but most likely a shader compilation, which is pretty expensive. There is no easy fix, but people have some workarounds - search the forum for similar topics to shader compilation and so on.

1 Like

Is there any way to pre compile them?

After some investigation it seems that these may help:

  • enabling the glbs one by one (timed interval)
  • enabling them and then disabling them again imediatly at the start of the game (perhaps under the cover of a load screen) with frustrum culling disabled on the camera would force compilation of the shaders.

Personally, I’d take the second approach here. It can be a bit of a pain to implement, but it’s going to give the best experience to the player.

1 Like

I tried this (second approach) and something strange happened.

When I initially load the game the camera can see everything (frustrum culling is off at this point) so theoretically at this moment all shaders should get /be compiled.

But then I disable everything and then enable again (some seconds later with frustrum culling on) the stuttering happens as objects come into view (as if compiling shaders).

This only happens once. if i disable and enable again no matter how many times after there is no stutter.

So why when I can see the full scene at the start the shaders aren’t compiled?? How is it possible? Is something else going on?

I had a similar problem a while ago, and in my case it was caused by Clustered Lightning. I disabled it.