Skip to content

jonasgeiler/3d-raytracer-lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

raytracer.lua (WIP)

A simple 3D raytracer written in Lua

About

I followed these two books by Peter Shirley and translated the C++ code from the books into Lua:

All the code is written by me, but I added a MIT license so feel free to use it.

Note
I am currently still reading the second book, therefore this repository is work-in-progress (WIP).
If you want to try out the finished raytracer after the first book, checkout the tag end-of-book-1.

Results

Render 1 Render 2

How to use

Just download the repository and then run raytracer.lua using LuaJIT:

$ luajit ./raytracer.lua

You can also use standard Lua 5.1, but I highly recommend using LuaJIT instead. Also, to use standard Lua you have to install the Lua BitOp extension, which is included in LuaJIT.

After the rendering is finished, you can find the PPM file in renders/.
To convert the PPM file to a PNG file, I recommend using GIMP.

To Do

  • Book 1 (Ray Tracing in One Weekend)
    • Output an Image
    • The vec3 Class
    • Rays, a Simple Camera, and Background
    • Adding a Sphere
    • Surface Normals and Multiple Objects
    • Antialiasing
    • Diffuse Materials
    • Metal
    • Dielectrics
    • Positionable Camera
    • Defocus Blur
    • A Final Render
  • Book 2 (Ray Tracing: The Next Week)
    • Motion Blur
    • Bounding Volume Hierachies
    • Solid Textures
    • Perlin Noise
    • Image Texture Mapping
    • Rectangles and Lights
    • Instances
    • Volumes
    • A Scene Testing All New Features