James borne

How are Games Rendered So That They Are Interactive?

#renderfarm #rendering #hardware #gaming

How are Games Rendered So That They Are Interactive?

How are Games Rendered So That They Are Interactive?

Video games have come a long way since their inception, evolving from pixelated graphics like Pac-Man to today's lifelike visuals in Forza Horizon 5 where details, physics, reflections and sounds become so real it feels like you are actually driving this car. At the heart of this evolution lies the magic of game rendering, which not only brings visual depth but also ensures that games remain interactive. But how exactly do games merge high-quality graphics with real-time interaction? Let's delve into the intricacies of game rendering.


1. The Game Loop: Heartbeat of Interactivity

At the core of every game is the 'game loop'. This continual cycle checks for user input, updates game states, and then renders the game to reflect these changes. This happens many times a second, enabling real-time interactivity. You make it possible to interact with the virtual world the developers created, this way you have control over where in this world your character is located and who you talk to, or where you drive your car to and how good you are in racing for example compared to other players as you control the car in a better way than others do. This can bring your character to beautiful places in the game, or the ideal locations for taking car pictures for your racing game.

realtime vs prerender

2. Real-time vs. Pre-rendered Graphics

Most games utilize real-time rendering, meaning scenes are generated on-the-fly based on player input. This differs from pre-rendered graphics (often used in cutscenes) where visuals are created beforehand and simply played back during the game. The biggest difference between the two is that player input based graphics have to be smooth and therefor it is required to optimize textures, and a lower poly count to increase the frame rate, the frame rate will be crucial to smooth gameplay, the higher, the better. For the pre-rendered graphics they can run full reflections, full textures and the highest poly counts possible on all assets, as the pre-rendered graphics can take hours to render a single scene. Therefor these graphics look way more realistic than gameplay itself, a good example of this is the gameplay of World of Warcraft compared to their trailer renders of the new expansions:

3. Game Engines: The Framework of Rendering and Interactivity

Engines like Unity, Unreal Engine, and Frostbite provide the necessary tools and structure for real-time rendering. They manage graphics, physics, and AI, ensuring smooth gameplay. These engines utilize various techniques to maintain interactivity:

  • Occlusion Culling:

    Only objects within the player's view are rendered, conserving resources. (If a building was behind your character it would not be rendered at all to optimize the performance, as soon as it comes into view of the player it would be rendered.)
  • cyberpunk 2077 level of detail lod
  • Level of Detail (LOD):

    Objects far from the player are rendered with fewer details, reducing computational demands and therefor trees, cars or other assets could look blurry or low detailed in the distance.
  • Medieval Engineers Destructive Physics
  • Physics Engines:

    These handle collisions and object interactions, making gameplay feel realistic. Think of a cannon shooting a large cannonball at a castle, in some older games the walls of the castle would be untouched, but some newer generation games could make it possible to let the cannonball interact with the stiffness of the castle wall and do actual destructive physics to the castle, and if you shoot enough cannonballs at it eventually there would be no more castle and show you the physics of a castle being destroyed by the gravity physics. A good example of this is the game called Medieval Engineers.
Ascended Gods Shaders

4. Shaders: Bringing Depth and Realism

Shaders are mini-programs that dictate how in-game surfaces appear, influencing aspects like color, brightness, and texture. By processing data in real-time, shaders can adapt visuals based on gameplay. For instance, a character might become progressively dirtier in a mud fight, thanks to dynamic shader adjustments. But even in this part, realism can cost more performance, there are three possible lighting options in this topic, static, stationary and moveable shadows. The static shadows are pre-calculated and mostly used for objects like lanterns on a wall or traffic lights in race games, these have pre-calculated shaders and makes shadow calculations easier for your game engine to process. Stationary also pre-computes a part of nearby objects and textures, but they can also calculate a moving object like the player character during gameplay, this will make it more performance hungry and can lower the frame rate slightly. Last but not least the most intensive performance hungry option is moveable lights, think about a moving train through a tunnel, these lighting can't be calculated ahead of time as the train will be moving through a dark tunnel, so moveable lighting will need to calculate the shaders during the movement of the train.
In the example above you can see the different types of shaders in action, as lower quality tends to grab pre computed shaders it will be displayed as a blur, the other ray traced shaders even light up the small leaf of the plant on the right as the ray traced shadows are cast from the suns location and bounce against the leaves of the plant through the leaves of the trees in front of it..

Minecraft chunks are not loaded yet

5. User Input: The Essence of Interactivity

Games continuously check for player input, whether it's from a keyboard, mouse, or game pad. Upon receiving an input, the game updates its state and visuals accordingly. This instantaneous feedback loop gives the illusion of direct control and is foundational to game interactivity. Imagine a parked car inside a game watching at a street where cars are passing by, this will make the game render only the area where you are currently parked at, with the moving cards up ahead, but as soon as you give the inputs to your card to move along the cars on the street it will ask the GPU to render the next regions you are passing through, loading and offloading textures and lighting maps along the way. Your inputs will influence the whole game. The example above shows how the input of the player flying through the world is causing the game to load new chunks too fast and can't keep up with the player input moving forward, as the chunks behind have to unload it also causes the new chunks to wait for the old chunks behind the player to unload.


6. Artificial Intelligence (AI) and Interactivity

Modern games utilize AI to control non-player characters (NPCs). This makes the world feel alive and responsive. If a player shouts in a stealth game, nearby guards might come investigating – all thanks to dynamic AI algorithms. The most advanced AI systems can even generate random events based on your gameplay, or it may even have characters involved that can generate conversations that will be different for each individual player!


7. Network Rendering for Multiplayer Games

In multiplayer games, maintaining synchronicity is paramount. When players interact with the game world or each other, data is sent to a server, which then broadcasts updates to all players. This ensures everyone experiences a consistent game state. It's crucial for multiplayer games that when you shoot your weapon in the game, the other players can hear and see you shoot the weapon, so in most game engines a "Replication" is sort of build in to get this part working. The Replication process is really important for the players as this will give all players the feeling as if they were all at the same virtual world, and it all runs in sync. A good representation of this will be the familiar game "Call of Duty" or "Battlefield" where all players can see and interact with each other in the same map.


8. The Balance: Performance vs. Quality

There's always a trade-off between visual quality and game performance. Developers aim for a balance, ensuring that games look great but also run smoothly. Techniques like dynamic resolution scaling can adjust game resolution on-the-fly based on performance needs. It's important to know what graphics cards are mostly used by gamers, and most of the time it will shock you that the GTX 1660 is still used most among graphics cards, so game developers need to think of making the game playable for lower end graphics cards, and also have the possibility to support all their features and quality when using a High-end GPU like the RTX 4090. Therefor the game developers will invest a lot of time and effort optimizing the game where possible for the lower end GPU's and most of the time will have different quality settings and graphic settings in-game to play around with.


9. Post-processing: The Final Touch

After the primary render, games often undergo post-processing, enhancing visuals further. This might include adding motion blur, enhancing colors, or applying depth-of-field effects. These can even make it possible to add a cloud system to the game to make it feel more realistic, but this of course also comes at a cost, each cloud in front of the sun will increase performance demand and therefor the post-processing can be an intensive addition to the game. In the example above, the post processing adds a vignette and darkens the lighting slightly to get the right atmosphere for the Death realm inside Ascended Gods, this game is build with Unreal Engine 5 and represents the minor realism changes due to the post-processing.


The seamless integration of high-quality graphics and real-time interactivity is what makes video games such immersive experiences. Through a combination of efficient algorithms, powerful hardware, and artistic expertise, the gaming industry continues to push boundaries, promising even more visually stunning and interactive experiences in the future. On top of that Developments like Ray tracing cores inside Nvidia's RTX Graphics cards made it possible to run games at a more realistic quality than ever seen before, it was too performance hungry to do it with older generation cards, but now that the technology is growing quickly, even this technology was adopted by games very quickly increasing its realism further. If more of these type of technologies emerge, you can almost not see the difference between reality anymore in the future. This could even lead to Virtual Reality games where people can work from at home, as games have an interactive nature, why not use it for work and have a beautiful desk in a large skyscraper office with all your colleagues instead from your couch at home.