Difference between revisions of "Ray casting"
Jump to navigation
Jump to search
m (Advent's implementation of adaptive ray-tracing. →How do I implement it?) |
m |
||
Line 28: | Line 28: | ||
* [[eligloscode|Very simple line of sight pseudo-code.]] | * [[eligloscode|Very simple line of sight pseudo-code.]] | ||
* [[Advent#Line_of_Sight|Adaptive Ray-Tracing in Advent]] | * [[Advent#Line_of_Sight|Adaptive Ray-Tracing in Advent]] | ||
* [[Raycasting in python]] | |||
==What games use it?== | ==What games use it?== |
Revision as of 13:37, 9 January 2012
What is Ray Casting?
Ray casting is a method for calculating Field of Vision where rays are traced from the center of a source square to a select number of destination squares. Squares are marked as visible as the rays pass through them, and walls will block the rays.
There are a few ways to decide where rays are to be cast:
- Every potential destination -- This method is very slow, but results in a crude approximation of Shadow casting.
- Every square along the perimeter of the area being checked for Field of Vision -- This is faster, but causes an increasing number of artifacts as the radius increases.
- A fixed number of rays as regular intervals -- Provides a tweakable knob that trades off between accuracy and speed.
Advantages
- Easy to implement
- Builds intuitively on Line of Sight algorithms.
Disadvantages
- Slow compared to other methods. Even when casting only a few rays, squares close to the source will be visited many times.
- Many artifacts, even in common situations
How do I implement it?
- Ray-Tracing Field-Of-View Demo
- A Bucket Of LOS
- LOS by Odd
- Line of Sight - Tobias Downer
- Simple and accurate LOS function for BlitzMax
- Very simple line of sight pseudo-code.
- Adaptive Ray-Tracing in Advent
- Raycasting in python
What games use it?
What libraries implement it?
libtcod contains an enhanced version of perimeter raycasting with a post-processing step removing most artifacts and making it equivalent to shadowcasting.