Why the move to 3D Graphics? Why not stick with good ol’ sprite-based graphics? It’s time a brief summary of how 3D graphics work in the gaming scene!
How Graphics Work
Trying to explain complex 3D concepts to someone without any understanding of programming is kinda’ like trying to teach an elephant how to do calculus but hey, I believe in you dear reader, we’ll take this slow. To make this easier on your sanity, I’ll keep this simple (…& clean, amirite Kingdom Hearts fans), so that you get the fundamentals of this amazing tech works.
Let’s start with the building blocks of 3D, you guessed it right, it’s POLYGONS! But it’s easier to understand these building blocks by splitting them into 2 kinds, namely:
- Squares (or Quads in 3D-speak)
So the idea is that these 2 fundamental shapes are responsible for every 3D model out there! Also, models are simply the 3D rendition of shapes, in case you were wondering. So the reason why games in the early years of 3D were always boasting about how they had better polygon counts that anything else that came before, is simply because it meant that those games packed in more detail! You see, every little polygon adds up to form more and more individual elements of a complete model. The more polygons you had, the more detailed the model would look! So far so simple right? Alrighty, let’s move on to how 3D worlds work.
So the deal with models, is that you use 3D coordinates to track their placement. So imagine a graph, you got your x-axis for horizontal and y-axis for vertical, but when you add the z-axis for depth, suddenly your 2D plane, becomes a 3D plane, hence the whole 3 dimensions thing. Anyways, so let’s try drawing a simple triangle or quad, how many points are there if you translate the 2D image into a 3D plane, well, it would look something like this:
Figure 1 Illustration of shapes on a 3d plane. Source: TheHappieCat
So that’s what happens, alright, so we have 3 coordinates (x, y, z) for every vertex, that’s the actual points/apexes of the shape. In layman speech, vertices are basically the pointy bits of a shape, so take the triangle for example, it has 4 vertices, the top point, and the 3 points at its base, and each one of those has its own coordinates, not too shabby. You’re making real progress!
So, when it comes to environments, things get a little trickier. So, the thing is, you have to keep track of two types of coordinates at all times, otherwise every single model in the environment just ends up overlapping each other at the origin point, a.k.a. (0,0,0).
- Model Coordinates
- World Coordinates
So the idea is that when you put all the coordinates of the shape into a matrix (remember those rows and columns of numbers in big brackets back in highschool… or if you’re an engineering undergrad?) so can multiply them and translate their positions into the world coordinates. So now every model is placed in a specific point in the world, by readjusting its origin point to no longer be (0,0,0), but maybe (193,345,612) for example. There’s some math involved in this but its not too important for right now, as we’re just talking about the concepts here, neat huh?
Now it comes to the cool bit, how we see the 3D environment being displayed. There’s actually two ways to do this, but we mostly only ever use one way, since the other is super taxing on computers since there’s so many additional computations to be done.
- Rotate the world relative to the camera. (the good way)
- Rotate the camera relative to the world. (the “my CPU is melting” way)
So here’s the big secret to 3D, are you ready?…
Yup, that’s the trick, at the end of the day, what you see on your monitor is just a 2D image being projected, but you think its 3D because of the way our eyes and brain works (but that’s beyond the scope of our topic so let’s get to the point). What you are actually seeing is a lot of very small squares called pixels on your screen light up with colors and the big picture becomes an image you can recognise. This technique of creating perspective is aptly named: Perspective Projection.
Figure 2 Illustration of perspective projection. Source: Real 3D Tutorials
Now, to ensure the computer isn’t actually rendering anything out of the frame, things you can’t see get clipped out and technically don’t exist. This is kinda trippy to wrap your head around but work with me here. Let’s take a 3D game like Dark Souls and look at a still image of it in-game. I’ll even make it extra large so we can see it clearer.
Figure 3 Dark Souls in-game footage. Source: IVG
So in this image, the dude with anorexia nervosa on the top is an enemy and the dude/dudette going for the hippie cloak look is your player character, and of course the ground, stairs, rails, and trees are all part of the environment. Everything you are seeing here is in 2D, it’s just that having a metric ton of polygons and good use of perspective projection techniques makes things look like they have depth. But the kicker is that there’s no way to render everything in the environment at the same time. Those 3 steps of the stairs to the left? Those lead to a big cathedral, and the path to the right? That way to a tower that goes down a steep cliff. So that’s a lot of environment, and that’s not even counting all the objects in the environment, more models representing furniture, enemies, and so on.
Gosh darn, that’s a lot of environment. That’s why we clip out EVERYTHING that is not currently on screen right there and then, so in this very moment that this in-game image was taken, those other places don’t exist visually (they aren’t being rendered), but they still exist figuratively. So if like, some dude with a sword was right behind our player character in this image about to stab him/her from behind, then it would still exist in the game’s memory, like how fast he’s running at you and stuff like that, but when that dude comes onscreen eventually, then the game will render him.
But that’s not nearly good enough. Even if we stuck to showing only what’s currently on screen right now, our computers would likely still be chugging hard when it comes to high polygon count models like the ones in Dark Souls (for its time anyways, I mean have you SEEN Dark Souls 3!?). So programmers take it one step further, and don’t render anything that isn’t directly able to be seen from the current perspective. Confused? Let me try again. So you see how the player character has a shield and sword in-hand? Well, the game is only rendering the back of the shield and the right side of the sword right now because we can’t see the other side of those objects at this moment. Actually, let me correct myself, you see the part of the shield that is obscured by the player character right now? That’s not being rendered either. The anorexia nervosa victim’s legs? Nope. What’s directly behind those stairs? Nope. Our own player character’s body and face? Nope, just the hippy clothes. I think you get the idea.
3D’s pretty cool… it’s hard as balls to make happen, but it’s still cool. Maybe you’ll start to better appreciate how much incredible technology goes into the run-of-the mill 3D video game in the market nowadays, and why more and more indie developers opt more sprite-based graphics instead so they can save themselves from the countless migraines they face trying to compute matrices. But what do I know? I’m just a dude with likes to know how his chicken sandwich is made.
How rendering graphics works in games! by TheHappieCat @ https://www.youtube.com/user/TheHappieCat
Next Week on The HotSeat: “Monster Hunter, what’s that?… or why the words “plate” and “ruby” have a special place in my heart.”
“ArcticLyrae is a 3rd-year Monash University Malaysia undergraduate with great enthusiasm for all things related to gaming and its many forms. He is the Game Master of Monash Gaming Society and writes articles for Radio Monash Malaysia covering various gaming-related discussions in his weekly section, The HotSeat.”