Ray Casting 3D Rendering Demo
Controls
Create a 2D map on the map editor on the right screen, walk through the 3D map on the left screen.
Note: You may have to click on the left screen to focus the controls onto it.
Select block | Place blocks | Remove blocks | Movement | Look around |
![]() Click on a block from the bottom list | ![]() Left click on the 2D map | ![]() Right click on the 2D map | ![]() | ![]() |
About Ray-Casting
Ray Casting (not to be confused with ray-tracing) is a technique to convert 2D grid maps into simple 3D visualisations. It works as follows:
- For each column of the output screen cast a ray through the 2D map
- Follow the ray until it intersects with a non-empty block
- Calculate the intersection point with the block
- Calculate the intersect point distance along the wall/block
- Calculate the distance to the camera
- Sample a column from the corresponding texture
- Scale the column according to the distance to the camera
- Draw the scaled texture column in the column the ray belongs to