r/howdidtheycodeit • • Jul 28 '22

Question How Does FPS Limiting Work

It just dawned on me I have no idea how limiting FPS in an engine works.

The piece I'm most uncertain about is what to do with the time after you've hit the cap. For example, if cap at 60fps and we get through everything in 0.75 seconds what happens to the remaining 0.25? If the engine sits idle for that time until the next second, won't there be a notable jitter in either input handling or rendering as we wait for the 0.25 to expire? If that tracks and I haven't missed something, or am otherwise completely off, it seems to suggest there is some method of sequencing the 60 frames across the full second but I don't suspect you could possibly know how long a frame will take to calculate before it is going to be dealt with.

I hope the question I am asking in that paragraph is clear. I also think there is a whole lot about rendering that I'm not aware of so if that is the case I'd love to be taught.

39 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/CreativeGPX Jul 28 '22

Not disagreeing with you, but adding a side note: There are some cool experiments they've done with carefully framed animations to show that we actually "see the future". That is, our brain collects all the sensory input from time N, but waits until N+1 to "send" it to our consciousness because it may peek at sensory input from N+1 to change the way we perceive that package from N. In that way, something we literally haven't "seen" yet can actually impact the way we perceive what it is we're looking at (e.g. whether something is moving and how).

That doesn't take away the argument that there are limits to our ability to perceive and react to frames, but it does sort of explain why that border is pretty blurry and nuanced and likely why an expert can develop such a dependence on frame limits seemingly beyond what our eyes can see.