This is a complete Go implementation of Peter Shirley's famous "Ray Tracing in One Weekend" tutorial. It implements a fully functional path tracer from scratch with no external graphics libraries.
- Custom
Vec3math library - Rays, Spheres, and Hittables
- Materials:
- Lambertian (diffuse)
- Metal (reflective)
- Dielectric (glass/refractive)
- Positionable camera with Defocus Blur (Depth of Field)
- Antialiasing (multisampling)
- Multi-core parallel rendering: Automatically uses all CPU cores for significantly faster renders.
- Direct-to-file PPM output (bypasses Windows terminal encoding bugs).
- Uses Go 1.22+
math/rand/v2for guaranteed non-deterministic random scenes.
Ensure you have Go installed.
- Build the executable:
go build -o rt.exe . - Run the renderer. By default, it outputs a quick preview (400x225, 50 samples per pixel) to
output.ppm:./rt.exe
- Or specify a custom output filename:
./rt.exe my_render.ppm
To render the high-quality final cover image (1200x675, 500 samples per pixel), edit main.go and update ImageWidth to 1200 and SamplesPerPixel to 500, then recompile and run.
The output is a standard .ppm (Portable Pixmap) file. You can view this using tools like IrfanView, GIMP, or drag and drop it into an online PPM viewer like ppmviewer.com.