Upcoming Events
Unite 2010
11/10 - 11/12 @ Montrťal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27††

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
79 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Fake Shadows
 Vertex Projection
 Shadow Z-Buffers
 Shadow Volumes
 Combining
 Algorithms


 Printable version
 Discuss this article
 in the forums


 


Introduction

So, you want to add shadows into your games. Why? Maybe itís because it looks cool, maybe you want to brag about it to your friends, or maybe you think it will add to the game atmosphere. Whatever your reason, youíve definitely come to the right place!

Ok, ready to get started? Well, weíre going to start with the very basics here. What is a shadow? Webster defines a shadow as "an area that is not or is only partially irradiated or illuminated due to blockage of light by an opaque object," or "the rough image cast by an object blocking rays of light." For our purposes, a shadow is a dark area caused by light being blocked by an object. So why exactly do we need to know this? Simple, if we know what a shadow is, it will be that much easier to create them in our games.

The most obvious solution is presented by the definition of a shadow. We could just cast a bazillion rays from the light source and determine lighting that way. While this may work, itís computationally expensive (i.e. slow), and it isnít very easy to implement. So, are you getting sick of definitions yet? Well, youíre in luck; you now know all you need to know to get started.

Ok, so I lied, there is one more thing you have to know before we get started, these algorithms are ordered based on complexity, the easiest algorithms are first, and the more complex ones are at the end. Ok, here we go!

Fake Shadows

The simplest way to create a shadow is to add a polygon to the bottom of the object. Since this is best understood visually, you should take a look at figure 2.1 if you donít understand the concept.

Figure 2.1


Example of a fake shadow

This is a very simple way of doing things. Unfortunately, itís very limited in itís applications. The ground must be flat, the object has to remain a fixed length above the ground, the object can only rotate around the y-axis, it doesnít take into account the direction the light is coming from, and it doesnít shadow anything other than the floor. But, weíre only getting started, and the next three algorithms are much better, if a little bit slower and more complex.




Next : Vertex Projection