This page is for the raytracer assignment for CS184 at UC Berkeley.
The raytracer renders spheres, triangles, and quads with point, directional, and area lights. The vim3D obj parser can read any geometry file, however, at this time we are able to render geometry that has faces with 3-4 vertices. Polygonal hit detection with vertices greater than 4 will be added later.
On this page, you will find information about these elements of the raytracer:
Bounding Volume Hierarchies
area lights and soft shadows
You may also wish to navigate to the Rendering Documentation or the raytracer gallery.
ReflectionsReflection is implemented using the reflection command, which specifies the reflectivity of each color component:
reflection 0.7 0.7 0.7Click here for information on reflection
RefractionsRefractions are implemented. You can specify this using the refraction command:
refraction 1.5Click here for information on refraction
NormalsWe have implemented a way to "meld" vertices of an arbitrary geometry and smooth the normals. Below show two renders, one with regular normals, and the other with smooth normals. Click here for more information on normals and computing smooth normals
TexturesClick here for information on texturing
TransformationsBelow we have demonstrated how transforms can be used to instantiate objects. The first is the original geometry, and the second image contains copies with various transformations. You can do this using the copy, translate, rotate, and scale commands:
copy tv translate 0 10 0 rotate 45 0 0 1These can be applied in a hierarchical fashion, using object groups. The object group command will create an entirely new geometry object that you can animate or modify. The matrix of the new object will affect all children.
obj group <obj1> <obj2> ... <objn> obj child <parentObj> <childObj>Click here for more information on hierarchies
Bounding Volume Hierarchy for AccelerationWe implemented hierarchical, oriented, bounding-box structures to accelerate the raytracer.
Anti-aliasingAnti-aliasing is achieved through regular sampling. Of the two images below, the first has aliased edges, and the second is anti-aliased. This can be achieved with the following:
render samples 1 raytrace noanti.ppm 3 320 240 render samples 3 raytrace anti.ppm 3 320 240
JitterThe default is set to use regular sampling. However, you can use random sampling, and in particular, jittering or stratified sampling if you specify
render jitter 1to set it back to regular, simply set it to 0. The images below were produced with
raytrace first.ppm 3 480 320 render jitter 1 render samples 4 raytrace second.ppm 3 480 320
Area lights and Soft ShadowsWe implemented area lights and soft shadows. This can be achieved using the light command:
add light light area 3 3
Normal MapsUsing the normalmap command, you can apply normal maps:
normalmap <filename>Below is a normal map courtesy of nvidia.com. We used this as an image to displace the normals in this example:
We converted the test scenes to our scene description language: Test Scenes
Also there is a raytracer gallery.
The source below will compile on all platforms, however, windows may require a .dll file or so. Mac OSX and Linux compile and run fine.