Monday, July 6, 2009

Ray casting in Flash

Ray casting is a technology used in many old ‘3D’ games such as Wolfenstein 3DDOOM. Game engine use ray casting is also called a 2.5 D engine. The limitation of a simple ray casting engine in Wolfenstein 3D is that you can't look up or down – you can’t rotate X axis. Ray casting is fast and simple so before flash 10 which supports 3d, many people used this technology to make some 3D effect. Ray casting can easily create a maze-like world of walls. You can render terrains, too. Terrain rendering is much different from walls, it is also called voxel rendering.

Here are some information about voxel terrains and volume rendering:

Ray casting is different from mode7, mode7 is much more simple, good at rendering floors or grounds, but can’t do with walls.

I collected some good examples of flash based ray casting:

1.Wolfenstein 3D flash ported by Glen Rhodes

Flash ray engine

2. Andre Michelle’s ray caster(source available)

(1)AS3 version

(2)old as2 version

You can find the source in ‘fla/examples/pro/raycasting’ ray casting engine(source available);a=summary

4. half baked ray casting (source available)

very powerful but use c processor.

5.Pixel raycasting engine (source available)

7. Strille’s ray caster(flash5)(source available) (source available at flashkit)

8.Frédéric Heintz, aka FredH’s flash maze(source available)

Find the flash8 source at

This one also has a simple editor.

9. doomedonline(source available)

10. Ryan A. Chilton’s Flash doom & quake(source available)

11.Another simple as3 raycaster

13.ericlin’s 3d maze(source available)

This one is not ray casting. It skews movieclips to create a perspective wall effect which is similar to raycasting.



1. F. Permadi’s Ray-Casting Tutorial

2. Lode's Computer Graphics Tutorial-Raycasting (c++ source available)

3. Another Raycasting Engine Tutorial

4. Advanced raycasting techniques (Line based raycasting/Doom style, instead of cell based/Wolf style)



1. id Software’s Wolfenstein3D source code

2. A fast java raycaster like doom or wolfenstein 3D (source available)

3. Wolfenstein 3D in 20 lines of JavaScript by Mathieu 'p01' Henri (source available)

4. JavaScript ray caster by Ben Joffe(source available)

5.Flash AS3 Ray Casting Tutorial with example and source

6. UPDATE(2013-11-3)
Bresenham magic: raycasting, line of sight, pathfinding:



rayfaster 2 test: