Extend LightFlicker-Script for sine implementation #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
The
LightFlicker-Script should adjust the lights output of light energy based on the sine wave provided by theGame Manger.Acceptance Criteria
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 theLight Manager.Extend Light Manager for sine implementationto Extend LightFlicker-Script for sine implementationIt's not the
Light Managers responsibility to change light energy values.It should just tell the light scripts to change their values.
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.
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.