Tuesday, September 11, 2007

What is ray casting?

I am sure some of you are wondering what this ray casting thing I am talking about is. Essentially it is like ray tracing except with only one ray per column of pixels instead of one ray per pixel. So the next questions would have to be what is ray tracing and what are the advantages of ray casting over ray tracing.

Ray Tracing is one of the oldest forms of 3D graphics generation. The concept is simple. What we see is made up of light. This light comes from one or more light sources and bounces off objects that absorb some of the lights energy causing it to change color. Eventually the light reaches our eyes where we see the results. Some brilliant person came up with the idea of doing this process in reverse. If you start from the eyeball, you can mathematically work out the path of the light as it travels through the world and trace the route the ray of light took back to it's original light source. By doing this, you can generate incredibly realistic looking images. The down side to this is that there are an awful lot of calculations, and the more complex the objects in the scene the more calculations have to be performed.

The advantage ray casting has is that it is done in a much simpler environment. In fact, it is often done on two dimensional maps that get projected into three dimensions. Because the geometry being calculated is so much more predictable, the amount of calculations that have to be performed are drastically reduced. In fact, ray casting can be done fast enough that it can be used for a game without requiring any 3D hardware support. When you are using Flash, at least as of Flash 9, you don't have 3D hardware support or for that matter any type of standard 3D library. The popularity of open source Flash 3D libraries is growing so eventually Adobe may finally add 3D support. I know for a fact this is a feature that a lot of developers have asked for. Until there is proper 3D support in Flash, all 3D will have to be done in software which means that the speed will be significantly slower meaning that the experience won't be anything like you could achieve if you had hardware 3D support.

No comments: