Thank you for visiting Blazing Games

Lighting Rays

It probably comes as no surprise that the further something is from a light source, the dimmer it will appear. This is due to the very simple fact that there are a finite amount of photons coming from the light source. As light tends to spread out (even heavily focused light such as those produced by lasers) as it gets further from the source. The further something is away from the light source the number of photons that will hit it are reduced. As the brightness of something appears is dependent on the energy that our eyes absorb, fewer photons means less bright.

The ray-casing technique that I am using is often combined with another technique known as texture mapping. Because of the uniform shape of the objects that make up the world, this is fairly simple to implement as the texturing operation can be simplified to the scaling of a strip of the bit-mapped texture. Adding lighting to this, however, can dramatically slow down the rendering because you then need to calculate the color of every pixel in the texture.

As this game takes place in ducts, this problem is easy to get around because no texturing is needed so the only thing needed to simulate lighting is to calculate the distance and base the color of the vertical line being drawn on the distance.

One thing about games is that often tricks are used to avoid time consuming calculations. One trick that I have used in the past to create lighting effects is to overlay an alpha channel. Technically speaking, there is still per-pixel calculations when you use this technique, but the calculations are being done by the Flash player software. The Flash Player is native code and possibly takes advantage of hardware acceleration as a result of using the Flash player can perform the task faster than ActionScript code would.

Previous page
Chapter 31 Page 4

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2009 Blazing Games Inc. All Rights Reserved