A ray tracer written in Golang. Implemented with much help from the tremendous book by Jamis Buck, The Ray Tracer Challenge.
- Easy concurrency. It's almost a necessity to use multithreading in a ray tracer in order to improve performance, and Go's sync.WaitGroup makes this very simple.
- Garbage collection. There are a LOT of objects created while the ray tracer is running, and having those cleaned up automatically is a great convenience.
- Inheritance/polymorphism is hard. The object classes (shapes) in this ray tracer have a lot of common code, and are designed in such a way that polymorphism is required. I managed to make it work, but it isn't as pretty as it could be using an object-oriented language.
- go 1.17 installed
make build
builds the ray tracer binary.
Specify a scene file when running:
./gtracer --scene my-scene.yaml
Both YAML and JSON file types are supported. See the demo/
directory for some example scenes. The schema for the scene file can be viewed here.
Important Notes:
- In a scene definition, children listed in either a group or csg need to be defined as a top level object (either as shape, file, group, or csg) in order to be properly referenced.
- Child objects must be defined before their parents.
- As of now, materials defined on a child within nested groups may not be honored. For best results, avoid nested groups and csgs.