Help in project optimization

Good evening, I have a question looking at my video of a larger map for optimization, there are a few points, maybe someone can tell you something that I don’t know. In general, to be honest, I’m interested in asynchronous (in a separate thread if WebGl allows it) loading models onto the scene. But also for any suggestions on optimization, I will be grateful to you.

  1. There is a frieze when I add a sword to the player’s hand. Yes, it is clear that there is no frieze for the second time already, and some people may offer to load the sword and remove it, but there are a lot of swords in the game.

  2. The same thing with the addition of a point of light, a larger frieze, but I was advised to load it separately and remove it, but the players can dynamically enter and exit the game, I will not be able to know exactly in advance how many points of light I need.

  3. And what can be additionally calculated in a separate thread using WebWorker except for models that do not fall into the visibility zone using (Frustum).

1 Like

The freezes are caused by shader recompilation. You can try to avoid them by preloading specific materials / lights (it’s also a good moment to start thinking about reusability of materials between objects :sweat_smile:) in moments when player won’t notice the jitter.

Since they don’t really have effect then - you can also just keep a bunch of lights in your scene and just set their intensity to 0 when you don’t need them (changing intensity affects shader uniforms but wont recompile shaders - as changing the number of lights on the scene does.)

Loading models itself is asynchronous and shouldn’t really cause noticable frame rate drops.

1 Like