Important Optimization
Optimizing Dynamic Lighting in My Game with a Custom LightManager
In my recent development sprint, I focused on improving the performance of my game by optimizing how dynamic lights are managed and rendered. Initially, the game experienced noticeable frame drops, especially during the first few seconds of gameplay, due to the computational cost of updating all dynamic lights (like torches) every frame.
To address this, I implemented a custom LightManager
class that efficiently handles dynamic lights by prioritizing and culling them based on their relevance to the player's position and camera view.
Cluster-Based Light Management
I began by organizing lights into spatial clusters using a grid system. Each light is assigned to a cluster based on its position in the game world. When the player moves, the LightManager
identifies nearby clusters and only considers the lights within these clusters for rendering. This reduces the number of lights that need to be processed each frame.
Prioritizing Lights in the Camera's View
To ensure that the most relevant lights are rendered, I incorporated frustum culling with an adjustable offset. This means lights within the camera's view (and slightly beyond) are prioritized. By expanding the camera's frustum slightly, we capture lights near the edges of the screen, ensuring they illuminate the scene appropriately even if their source isn't directly visible.
Files
Mysterious Maze
3D FPS Action RPG
Status | Released |
Author | FialaGames |
Genre | Role Playing, Adventure |
Tags | 3D, Action RPG, Boss battle, Dungeon Crawler, Fantasy, FPS, Roguelike, Singleplayer |
Languages | English |
More posts
- Controls & Minimap Improvements24 days ago
- "Mysterious Isle" DLC in Progress61 days ago
- Quest Improvements for New Players64 days ago
Leave a comment
Log in with itch.io to leave a comment.