Ray Casting Tutorial – Part 12
May 17, 1996
0
<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >>
FLOOR CASTING (Continued)
The math behind floor-casting is explained in the Figure 25 below.
Figure 25: The math behind floor-casting.
To reiterate, take a look at the illustration while reading these steps:
* Start from the bottom of the wall slice.
- Take the pixel position (you have this value when you did the wall casting).
- Draw a line (a ray) from the pixel to the viewers eye.
- Extends the line so that it intersect the floor.
- The point where the line “intersect” the floor is the point on the texture map that is being hit by the ray.
- Take the pixel value of that point on the texture map (see the next figure to see how this can be done) and draw it on the screen.
* Repeat 1-5 until the bottom of the screen is reached.
Demo with source code: https://permadi.com/tutorial/raycast/demo/4/