LifeEngine
LifeEngine copied to clipboard
Skip frames option to keep rendering w/o performance issues.
The specified amount of frames is skipped before each render, making it possible to render without performance problems.
Hotkey J was assigned to this feature and now Hotkey K serves as stop/start key.
I think this would be better solved by only rendering a max of 60 fps, while more frames can be computed without rendering in between. In other words, it won't render every single frame when its running so fast that you couldn't tell.
I think this would be better solved by only rendering a max of 60 fps, while more frames can be computed without rendering in between. In other words, it won't render every single frame when its running so fast that you couldn't tell.
If you look at the commits, I already tried the 30fps version of your idea with the number of frame skips found by dividing the fps value by 30. However, the most important problem related to this is the constant repetition of the vicious cycle that occurs when the real fps value decreases during the rendering, the number of skipped frames decreases, and the decrease in the fps value is triggered by the rendering of more frames.
Fps drops -> fps/30 drops -> skipped frames drops -> fps drops because more frames are rendered -> fps/30 drops -> skipped frames drops -> fps drops because more frames are rendered -> ... ( Inevitable lag)
I have tried many ways to circumvent this problem.
First, I calculated fps/30(frame-skip number) from the target fps value when the actual fps value fell below the target fps value. Although it alleviated the problem to some extent, it could not prevent the occasional long-term lag.
Then, as a more logical solution, I calculated the fps/30(frame-skip number) value over the average fps so that the fps value falling during rendering does not create a vicious circle. This really reduced the problem, but unfortunately could not solve it.
Of course, this problem could be solved with a creative idea, but in the end, the occasional lag was getting so annoying that I decided that it would be the healthiest way to temporarily switch to a simpler logic and let the user decide the number of frames to skip.
I think this would be better solved by only rendering a max of 60 fps, while more frames can be computed without rendering in between. In other words, it won't render every single frame when its running so fast that you couldn't tell.
But I will figure it out soon but now, I need to concentrate on my schoolwork for a week or more :D
I think this would be better solved by only rendering a max of 60 fps, while more frames can be computed without rendering in between. In other words, it won't render every single frame when its running so fast that you couldn't tell.
Maybe use requestAnimationFrame() instead of a fixed 60fps for the draw loop? Monitors with non-standard refresh rates (30, 75, 120, etc) would take a hit from such a change