Difference between revisions of "Ray casting"

From RogueBasin
Jump to navigation Jump to search
(Added an initial page for ray casting. Need to fill in some sections.)
 
(Moved ray-casting articles here.)
Line 1: Line 1:
==What is Ray Casting?==
==What is Ray Casting?==


Ray casting is a method for calculating [[Field of View]] 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.
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:
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 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 View]] -- This is faster, but causes an increasing number of artifacts as the radius increases.
* 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.
* A fixed number of rays as regular intervals -- Provides a tweakable knob that trades off between accuracy and speed.


Line 20: Line 20:


==How do I implement it?==
==How do I implement it?==
* [[Ray-Ttracing Field-Of-View Demo]]
* [[A Bucket Of LOS]]
* [[LOS by Odd]]
* [[Line of Sight - Tobias Downer]]


==What games use it?==
==What games use it?==
[[Moria]]


==What libraries implement it?==
==What libraries implement it?==
No known libraries implement ray casting.

Revision as of 04:31, 27 April 2007

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?

What games use it?

Moria

What libraries implement it?

No known libraries implement ray casting.