Extend LightFlicker-Script for sine implementation #3

Closed
opened 2026-08-09 22:17:29 +02:00 by akkiirah · 3 comments
Owner

Description

The LightFlicker-Script should adjust the lights output of light energy based on the sine wave provided by the Game Manger.

Acceptance Criteria

  • The LightFlicker-Script changes the brightness based on the provided sine wave values.
  • Light sources changes don't happen all together but rather across multiple frames, which is controlled by the Light Manager.
### Description The `LightFlicker`-Script should adjust the lights output of light energy based on the sine wave provided by the `Game Manger`. ### Acceptance Criteria - [x] The `LightFlicker`-Script changes the brightness based on the provided sine wave values. - [ ] ~~Light sources changes don't happen all together but rather across multiple frames, which is controlled by the `Light Manager`.~~
akkiirah added this to the v0.2.0 milestone 2026-08-09 22:17:29 +02:00
akkiirah changed title from Extend Light Manager for sine implementation to Extend LightFlicker-Script for sine implementation 2026-08-11 00:14:31 +02:00
Author
Owner

It's not the Light Managers responsibility to change light energy values.
It should just tell the light scripts to change their values.

It's not the `Light Manager`s responsibility to change light energy values. It should just tell the light scripts to change their values.
Author
Owner

Encountering an Issue on the second criteria

I encountered an issue where the time between frames was larger than the amount of time allocated to update a single light.

For example, if the scene contains 120 lights and all lights need to be updated at rate of 5 FPS, a complete update cycle has to happen within 0.2 seconds. Distributing these updates evenly means that each light has an update interval of only about 0.00167 seconds.

At 60 FPS, a frame takes approximately 0.0167 seconds. This means that the time allocated to a single light is much smaller than the time between two frames.

My issue originated from checking whether the accumulated delta time had exceeded the interval for a single light. Whenever that happened, I would update exactly one light which led to frame rate dependent behavior.

### Encountering an Issue on the second criteria I encountered an issue where the time between frames was larger than the amount of time allocated to update a single light. For example, if the scene contains 120 lights and all lights need to be updated at rate of 5 FPS, a complete update cycle has to happen within 0.2 seconds. Distributing these updates evenly means that each light has an update interval of only about 0.00167 seconds. At 60 FPS, a frame takes approximately 0.0167 seconds. This means that the time allocated to a single light is much smaller than the time between two frames. My issue originated from checking whether the accumulated delta time had **exceeded** the interval for a single light. Whenever that happened, I would update exactly one light which led to frame rate dependent behavior.
Author
Owner

Got that bug fixed by calculating how many lights needed to be updated within the given time and changing that much on that update cycle.

However, when comparing the performance of both updating all lights every 0.2 seconds and the offset method, I have found the exact opposite of what I was expecting!

With the all lights method I have observed steady frame rates and mostly steady frame times as well.
With the offset method I have observed a slightly lower frame rate (which is to be expected since I spread the lighting updates across multiple frames), but the frame times were also horrible!

I am not sure why this happens. I believe it might have something to do with overhead since we calculate each frame how many lights have to be updated which might be worse than just updating it constantly?

Whatever the reason may be, I'll stick to my observations for now and cancel the second criteria.

Got that bug fixed by calculating how many lights needed to be updated within the given time and changing that much on that update cycle. However, when comparing the performance of both updating all lights every 0.2 seconds and the offset method, I have found the exact opposite of what I was expecting! With the all lights method I have observed steady frame rates and mostly steady frame times as well. With the offset method I have observed a slightly lower frame rate (which is to be expected since I spread the lighting updates across multiple frames), but the frame times were also horrible! I am not sure why this happens. I believe it might have something to do with overhead since we calculate each frame how many lights have to be updated which might be worse than just updating it constantly? Whatever the reason may be, I'll stick to my observations for now and cancel the second criteria.
Sign in to join this conversation.
No labels
bug
feature
refactor
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
akkiirah/node.you#3
No description provided.