Chris Thomas Assignment 3: Ray Tracer IMPORTANT NOTES: 1. My parser is modified. Standard ray files are unlikely to work. Of particular importance are areav0 and areav1 on lights. Set these to 0 0 0 if you want a point light source. 2. I use a different calculation for Beer's law - I removed the log() and assume you enter an appropriate vector. See some of the ray files I provide for examples. Small numbers are clearer: .0001 .0001 .0001 would be nearly transparent. .1 .0001 .0001 would block red, so you'd get a greenish-blue color. Stick with small numbers - it takes some getting used to. The raytracer runs on both windows and *nix - be sure to edit the "#define WINDOWS <1|0>" line. Modifications to .ray format ---------------------------- areav0 and areav1 are required for lights. They are vec3f's, and must preceed attenuation. Running the raytracer ---------------------------- Defaults for antialiasing, etc are set at compile time with the global variables at the top of rt_start.cpp If you change any settings, you must provide all values. The format is: ./rt_start foo.ray out.jpg [antialiasingSubpixels] [antialiasingJitter] [doLighting] [doShadows] \ [doSoftShadows] [doSoftShadowJitter] [numShadowRays] [doReflections] \ [reflectionDepth] [doRefraction] [depthOfFieldRays] [depthOfFieldEyeSize] An example commandline with the defaults: ./rt_start test.ray out.jpg 2 0 1 1 1 1 5 1 10 1 4 .1 Features supported ------------------ * Triangle Intersection * Sphere Intersection * Triangle texture mapping (the first half of my animation demonstrates this, as do various scenes) * Sphere texture mapping (the first half of my animation demonstrates this, as does the example scene) * Sphere & triangle Phong shading (you can see some specular lighting on the moving ball in the first half of the animation) * Shadow rays (see first half of animation) * Recursive reflection (run test5.ray - it gives a great demo) Extra features supported ------------------------ * Recursive refraction (see first half of animation as an example) NOTE: nested transparent objects are not supported. Make sure transparent objects don't intersect each other. * Good antialiasing (I support antialiasing with any perfect-square number of rays, with and without jitter. Jitter was disabled for animations) * Soft Shadows (see first half of animation as an example. I support jitter, but disabled it for the animations) * Depth of Field (the second half of the animation is demonstrating this. Jitter produces poor results unless you use a HUGE number of rays, so I don't support it. Small eye sizes are best for most scenes, or things get very blurry) * Threading (I use two threads on *nix platforms, and two threads per CPU on Windows. I saw a good performance boost, and don't take a performance hit on a single CPU. Unfortunately, HyperThreaded Pentium 4s are pretty poor performers) * Intermediate output (every 10%, I save the pixels rendered so far to the output file) * Special rendering order (instead of rendering top-to-bottom / left-to-right, I render points in a sparse grid and make the grid progessively denser, until the entire image is rendered. This, in conjunction with intermediate output allows you to check the overall scene structure before the whole image is rendered. Additionally, it makes render speed more constant. Simple top-to-bottom / left-to-right rendering may encounter "hard" and "easy" areas of the image - for example a region with many reflections and estimating render time based on the first 10% gives poor accuarcy. By rending in this alternate pattern, the rendering speed is much more consistent.) Sample scenes -------------------------- test.ray ouptputs/test.jpg spheres above a triangle, another sphere behind it. This was an early test scene for ordering checks, and was also used to verify shadows test2.ray outputs/test2.jpg testing reflections and specular highlights on spheres test3.ray outputs/test3.jpg single triangle, was used to debug FOVY issues (I was using degrees instead of radians) test4.ray outputs/test4.jpg reflection test. Note that I set the FOVY extra high and the camera very close to the scene, producing cool distortions on the spheres. test5.ray outputs/test5.jpg hall of mirrors - more reflections. I suggest a reflection depth of 60+ on this scene. The dark area on the nearest reg sphere is a result of a shadow (ambient light is relatively high in this scene) - the scene layout is deceptive due to the reflections and multiple lights. This scene isn't inteded to be rendered with shadows (I laid it out before I had shadow support). test6.ray outputs/test6.jpg refraction test. The triangles normals make the reflection appear incorrect, but it is in fact right. I compared this scene output to 3d studio max to verify the code. There is a specular highlight that appears near the center of the sphere due to the light position which makes Beer's law less apparent. providedtest.ray / outputs/providedtest.jpg provided test. I may have modified this since it was posted. Sphere texture mapping, triangle texture mapping, reflections. test_refr.ray outputs/test_refr.jpg refraction test. The center light area is a reflection. Compared to 3d studio max for verification. test_tri.ray outputs/test_tri.jpg refraction test. The center light area is a reflection. Compared to 3d studio max for verification. test-trimesh.ray outputs/test-trimesh.jpg trimesh support demo. You can see refraction and reflections. test_dof test_dof2 Depth of field demos. Render them with non-zero eye with and 5 or 6 as the rays test_handin Complicated scene which didn't render by midnight. It's similar to part of the movie movie/* based on ray files in movieray/ - note that I changed the shadows so they don't match the ray files exactly (shadows are smaller now). the first half shows a ball entering another ball after passing behind a clear one. the second half demonstrates depth of field.