See all glossary termsFrames Per Second (FPS) is a measure of how many individual images, or "frames", a system can render in one second. Our eyes perceive fastly changing images as motion, and the higher the FPS, the smoother the motion appears.
Most video games aim for a target FPS between 30 to 60. This range is generally considered to provide a good balance between visual quality and system performance. A higher FPS can result in smoother and more fluid motion in the game, but it also requires more computational resources. Conversely, a lower FPS can make the game appear choppy or laggy, but it is less demanding on the system.
Not all games need the same amount of FPS. A fast-paced action game might require a higher FPS to keep up with the player's movements, while a turn-based puzzle game might be fine with a lower FPS, even as low as rendering a new frame only when the player moves.
In the Godot game engine, the _process()
function is responsible for rendering each frame. The engine calls this function repeatedly, as fast as it can, to generate the frames of the game. The number of times _process()
is called in one second is the game's FPS. This means that the game's FPS can vary depending on the complexity of the _process()
function and the capabilities of the system running the game.
It's important to note that while a high FPS can improve the player's experience, there is a limit to what the human eye can perceive. Most people cannot distinguish frame rates above 60 FPS. Additionally, the display device (like a computer monitor or TV) also has a maximum refresh rate, which can limit the effective FPS of the game; on most consumer displays, this is 60 Hz, so any FPS above 60 will not be visible.
Therefore, optimizing a game's FPS is a balancing act between achieving smooth and responsive gameplay and managing the computational resources of the system. This is a key aspect of game development and requires careful consideration of the game's design and the target hardware.
When unbounded framerate isn't necessary, it's often a good idea to cap the FPS to a reasonable value.
In Godot, the _process()
and _physics_process
functions receive a parameter called delta
, which represents the time elapsed since the last frame was rendered. In maths, a difference is often called a "delta", and this value is then called delta time. Delta can be used to make the motion relative to the time passed, ensuring that the game runs smoothly regardless of the FPS.
_process()
is called as fast as possible, while _physics_process()
is called at a fixed rate (60FPS by default). This is because physics calculations become unstable if they're not ran at a fixed rate.
V-sync is a technology that synchronizes the game's frame rate with the monitor's refresh rate. This can help prevent screen tearing, a visual artifact that occurs when the monitor renders two or more frames at the same time.
Enabling V-Sync, you can ensure all frames sent are displayed, but it can also introduce input lag, as the game has to wait for the monitor to refresh before sending the next frame. This can be a problem in fast-paced games where input responsiveness is crucial.
In the end, it's best to offer those options and let players decide what is best for them.See Also
Related terms in the Glossary
school.gdquest.com - 0.3.5-2024-12-12T18:17:18.104Z-a38dc74be3238fd1ea161f4df67b95520741da9d-release