Herbert David Young Raytracer -------------------------------------------------------------------------------- -YoungRay- -------------------------------------------------------------------------------- Features: -I included several example YoungRay Scene files: *.yrs (and the output *.ppm if you do not want to trace them) -Command line options: input_scene width height output_image -Relatively fast rendering (only a couple minutes for a large scene with a dozen objects and 81 lights, or several seconds for a small scene) -Supports a scene description language for input, which is flexable for white space, and optional parameters. Also, the parser generates useful error messages in the case of incorrect syntax. Here is the correct syntax: global_settings { background_rgb = (float,float,float) max_trace = int } camera { position = look_at = image_plane_distance = float image_plane_height = float image_plane_width = float } light_source { position = ambient_rgb = (float,float,float) diffuse_rgb = (float,float,float) specular_rgb = (float,float,float) // the area_light portion is optional area_light { vec1 = num1 = int vec2 = num2 = int } } // multiple light statements optional plane { position = normal = texture = texture_name // bounding shapes are optional bounding_box { x_min = float x_max = float y_min = float y_max = float z_min = float z_max = float } bounding_sphere { position = radius = float } } sphere { position = radius = float texture = texture_name // bounding shapes are optional } // multiple objects (sphere,plane) optional Multiple lights and objects are allowed, as long as the maximums are not reached (100 objects, and 81 lights). -Supported textures are: Yellow_Plastic Blue_Plastic Rainbow Wood Checker Glass Marble Mirror Metal Sun Mercury Venus Earth Mars Jupiter Saturn Saturn_Rings Uranus Neptune Pluto -New textures can be added by simple creating new subclasses of the Texture class, and defining the functions which specify colour and lighting attributes. -New objects can be created by subclassing the Object class, and defining certain functions, such as getNormal() and getIntersection(). -All objects support optional bounding_box or bounding_sphere which allow for interesting new shapes, and possible future updates to the algorithm for efficiency -Textures and lighting work correctly inside/outside, treating every object as a surface. -Shadows are filtered when passing through transparent objects, based on each objects transparency. -Images are output into P3 (ascii) ppm files, with 256 shades of red, green, and blue. The resolution is specified by parameters two and three in the command line, and the image name is the fourth parameter. -Area lights are supported: when area_light is defined inside of a light source, the raytracer will simulate this by creating n1xn2 lights on a grid, specified by vec1 and vec2, centred around the light's position. Remember that because there are a maximum of 81 lights in a scene, a 9x9 area light is the maximum grid size. Area lights simulate more realistic shadows by blurring the line between full shadow and full light. -max_trace specifies the maximum depth of ray recursion, and background_rgb specifies the colour given to rays which do not intersect anything in the scene. -Parsing and raytracing progress is outputted to the screen to keep the user notified. After tracing is complete, statistics are output to the console, which include: number of reflected, refracted, and shadow rays total number of lights, objects, rays, pixels, and time to complete average number of rays/pixel, rays/second, and pixels/second -Time to create raytracer: 51 hours -------------------------------------------------------------------------------- -The code I used to create "Solar System.mpg" was copied to MainAnim.cpp. I hardcoded the anmation since I did not have time to write animation-ability into my scene description language. MainAnim.cpp output 96 .ppm files which I used serveral utilities on, to convert to .bmp, then to .avi, then to .mpg. I also included a couple of sample .ppm images in case the viewer does not want to wait to trace a sample scene. -To view the images output by YoungRay, use xview file.ppm -scene1.yrs demostrates: reflection, refraction, and most textures -scene2.yrs: background colour, object clipping (bounding_box, bounding_sphere) -scene3.yrs: mirror and metal textures, and area_light the soft shadows of the metal and wood spheres are because of a 9x9 area_light