/raytrace-in-weekend-go

Go implementation of "Raytracing In One Weekend"

Primary LanguageGoCreative Commons Zero v1.0 UniversalCC0-1.0

RayTraceInWeekend Go

This repository provides a Go language implementation of Peter Shirley's Ray Tracing in One Weekend. A Japanese version of the original book is also available.

image image

rendered in 40-60sec with i5-8250

How to Run

go run ./src > output.png

This takes some options:

 -aspect float
        aspect ratio (default 1.7777777777777777)
  -depth int
        depth for ray tracing (default 10)
  -samples int
        samples per pixel (default 16)
  -scene string
        scene type (default "random")
  -threads int
        number of parallel threads (default 8)
  -width int
        image width (default 384)

Preset Renderers

make scene_final

image

SOme other preset renderers are available as make target:

  • scene_test, scene_random, scene_light, scene_cornell, scene_somke

Development

This is designed to render one image per execution. To simplify the process of repeatedly compiling and rendering images, we recommend using the make loop command. This command is designed to work best with a .png viewer capable of detecting changes in the displayed image and reloading it automatically.

make loop

Please note that you need to have make installed in your system for the above command to work.