Playing with Polygons › Introduction to Playing with Polygons
Painting and Lighting the Polygons

The last time you played a video game, chances are you were playing it inside a realistic "3-D World." For example, you might have been playing a racing game where you drive a very realistic looking car around a very realistic looking track. Alongside the track are trees, buildings and spectators that look like the real thing. Or, perhaps you were walking around a very realistic looking city trying to blow away pretty convincing zombies when they tried to attack you.

spooky house
What goes into creating a realistic 3-D scene like this in a video game?

In these advanced video games, everything looks realistic. The buildings look realistic, complete with peeling paint and textured bricks. The trees look realistic, and in some games, they even sway in the breeze. The water ripples in the sun so that it looks realistic too. Even the people look realistic, to the point where you can almost read their lips when they talk.

Have you ever wondered how game designers create such realistic looking worlds? In this article, we will look at the basic techniques game designers use to simulate real life.

It All Starts with a Polygon
In the world of realistic 3-D graphics, everything starts with the polygon, better known as a triangle. For example, let's say that you’re designing a game, and you want there to be a house in the game. Let's assume that the house is very simple - just four walls and two roof panels. In most video games, you would be able to make a house like this out of 14 polygons.

polygons
Polygons

As your character walks around the house, what you’re looking at changes. If you are standing right in front of the house looking at the front door, you only see three of the polygons. If you move a little to the left, you can see seven polygons. If you are in an airplane looking down at the house, you see a lot more of the roof. When you are far away from it, the house looks very small. When you are right next to it, the house can fill the entire screen. Inside a video game, the designers create all of these different perspectives using mathematical equations. The way this is done is by storing the coordinates for all of the house's polygons in a table. The computer looks at where "you" are standing in the game, and where the house is in the 3-D world. Then the computer changes and rotates all the coordinates of the house's polygons to match your position. For example, if you are far away from the house, the computer shrinks all the coordinates of the polygons. That makes the polygons appear very small on the screen.

There is a part inside your PC or your video game console called the graphics card. The graphics card is in charge of painting all the polygons on the screen. So, once the graphics card knows the coordinates for all the polygons of the house, it paints those polygons on the screen one by one. It paints them in a certain order, from "farthest away" polygons to "closest" polygons. That way, you only see the polygons that you are supposed to see. The ones in back get covered up and become invisible.

3-d man
Polygons

The house that we have used as an example, with its 14 polygons, is a very simple object. But, what if you are trying to create a complex object like a person or a car or a tree? You do it exactly the same way. The only difference is that it takes a lot more polygons. To make a realistic car, complete with curved things like tires, you might use 10,000 polygons or more. A realistic human face also takes thousands of polygons. Modern graphics cards can draw millions of polygons per second.

Next >>