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.
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.
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?