November 7th, 2007

Anatomy of a Game – Part 4

Beginner Game Tutorials, by nazeeh.

Another part of the grand illusion that game developers are creating is lighting. You can use the concept of lighting to illuminate certain parts of the world in a realistic way. Of course, there is no real light shining on anything; it’s all a simulation of how the objects will look when light is bouncing off of them.

Light in games is usually specified by a color and a direction vector. This information is used to mathematically derive the exact look of every pixel in the screen based on how the light bounces off of it, the color of the light when combined with the color of the pixel, as well as any properties of the material that this pixel is part of. In order for lighting to work, every vertex in your world needs to define what is called a normal vector. A normal vector is a vector that points in the direction that is perpendicular to the surface that the vertex is part of.

clip_image002

The reason you need that normal is that light calculations use it to know how much of the light bounces off a surface. By calculating the angle where the light hits the vertex normal, you can tell if that light is going to reflect or not and by how much. By calculating this information for all the vertices and using it to darken and lighten each pixel, you get the illusion of a well lit object.

clip_image004

In this example, the light is hitting the sphere model from the top left corner. As you can see, the light reflected relatively accurately by making the parts of the sphere that are facing towards the light brighter and the other areas darker. That’s because the normals on every vertex close to the light calculated a strong reflection angle for the light, while the other normals that are facing away from the light did not reflect much of it. It will make more sense when you actually try it.

Move on to part 5

Thanks for reading! I'd love to hear your thoughts, feel free to leave a comment below. Don't forget to subscribe to my RSS Feed!
Share and Enjoy:
  • Print
  • Digg
  • Twitter
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Back Top

Anatomy of a Game – Part 3 Anatomy of a Game – Part 5

Responses to “Anatomy of a Game – Part 4”

  1. I can’t believe that after learning algebra I finally have a real use for knowing what a normal vector is. Thanks for these tutorials. They are really clear and easy to follow. Hope you keep them coming.

  2. Very useful! Please do not take this site down!!! This site is really helpful and unlike any other!

    WannabeGamer at April 3, 2011 7:31 pm

Leave a Reply

Back Top