Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

I'm working on an endless game so i designed it so that the lights are created when the player is near and deleted when not. However I've noticed that when the player comes into contact with any light for the first time it stutters when creating the light. If they leave and come back, even though the light was deleted and needs to be created again it doesnt stutter. 

Example, i have a section with 28 lights. Only 8 are actually existing at most at any time. If I create 4 of that section in a row, after going through the whole first section with stutters the next 3 don't stutter.

I don't know the cause of this or fix. I'm just ignoring it happens and putting it on the back burner for now.

(+1)

This issue occurs due to shader compilation and GPU resource allocation that happen the first time a specific light configuration (type and number of lights) is used.
Since three.js internally caches compiled shaders, removing lights does not cause them to be recompiled when the same types and number of lights are created again.

The best solution is to avoid creating and destroying lights during gameplay.
At the beginning of the game scene, create only the minimum number of lights that will be used simultaneously during gameplay, and place them somewhere outside the camera view.
After that, instead of adding or removing lights during gameplay, reuse them by updating their position and intensity.

Additional notes about using lights have been added to the WithThreeJS Extension page.
Please also refer to the “Notes on Using Lights” section at the following URL:
https://pandako.itch.io/with-threejs-extension-for-gdevelop