Starter code
We are providing starter code in ray.py
that establishes the key properties and interfaces of the following classes:
- Scene geometry classes
Sphere
Triangle
- Light sources
PointLight
AmbientLight
Camera
Material
Scene
There are also some utility functions provided in utils.py
. In the ray
module nothing but the constructor boilerplate is implemented, though.
We provide test cases for some of these classes, to help you in implementation. We also provide a few test scenes and reference renderings of them. The test cases are missing some important things, and you should feel free to add tests for shadows, scene intersection, and to confirm ray starts and ends are respected in more situations. The tests use the Python library's uinttest
module and can be run simply with python testray.py
.
There is no explicit file format for reading in scenes; rather we use the Python language as our scene specification language. Scenes are just Python scripts that build the scene and call the cli.render
method. The cli
module has a few features to allow controlling things like the output filename, the image size, exposure, etc.
For instance:
python two_spheres.py
renders thetwo_spheres
scene and writes the result totwo_spheres.png
.python cube.py --nx 128
renders thscube
scene as a 128 pixel wide image tocube.png
. (Small images like this are useful for quick-turnaround testing.)python three_spheres.py --nx 1024 --outFile three_spheres_1024.png
renders a higher resoution image to a different filename so it won't be overwritten by future default renders.