Jared Ross

                              Final image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                   

This ray tracer has the capability to do soft-shadows, anti-aliasing, glossy reflections and depth of field.

    Soft-shadows were done by giving each light width and height vectors to describe the area from the given position that the light actually possess. The shadow ray is then randomized so that it points to one of the infinite points in the light's area.  This enables some of the peripheral shadow rays to make it past the object to the light giving the gradual darkening of the shadows.

    Glossy reflection involves a similar varying of the direction, this time of the reflection ray.  The difficulty here was that unlike in the shadow instance all there is to use initially is the reflection ray direction.  A basis needed to be created from one ray which involves taking the direction, changing the coordinate with the smallest magnitude to 1 and then crossing the new direction with the original direction to get the u vector.  The v vector could then be gained from crossing the u vector with the original direction.  With all the vectors normalized this creates a unit plane with the original direction pointing to its center.  Then it is a simple matter of varying the direction ray to point to a random point in this plane.  In addition there needs to be a scaling factor to say how much the randomization influences the reflection's blurriness.  This ray tracer does that by having the first reflectance parameter act as both an boolean on/off and as a scaling factor.  A value of one means that reflection is on and it is a perfect reflection.  Any increase of the number above one will turn on the glossy reflection and operate as a scaling factor of the number minus one.  Best results are gained for glossy reflection with values between 1.1 and 1.5.  Above this the reflection becomes somewhat scattered.  The second parameter added to control reflection dictates the percentage that the reflection influence the color of the object upon which it is reflected.  This can be used in the cases where it is felt that the surface would not reflect the image so strongly as a pure 100% reflection.  The glossy reflections of the orbs on the grass in the image above has been set to .5 or 50% in an attempt to give a slight wet grass reflection feel.

                                                                     

    Anti-aliasing was also implemented.  It involves another varying of a ray, this time the eye ray through the pixel.  The anti-aliasing works on a grid for each pixel. The pixel is split up into a square grid of AxA squares and a ray is fired into each of these squares for each pixel.  The rays have a random direction with in each square as well.  The colors gained from these rays are all added up and then averaged at the end.  The picture above was done with anti-aliasing of 2x2 or 4 samples in the interests of rendering the image in time.  A grid of 4x4 or 16 samples was taking too long.

    Depth of field involves two things. First it involves changing the focal distance of the camera and second it involves changing the size of the lens.  The first if a multiplication and fairly simple the second involves jittering the position of the camera so that rays are fired at different angles through the focal point for each pixel.  This ends up blurring anything not at the focal distance becase the change of angle means that the rays will hit different things.  The images above had no use for depth of field so it was set to the default of focal length 1, and lens size 0.  An interesting effect with grass texture is that at focal length 10 and lens of 0.05 I managed to make the grass look like glass.

                                                                          

    While not a technical improvement to the ray tracer I simplified my material addition to include base materials in a similar fashion as procedural and imagetexture materials.  The are all declared before whatever object is going to use them with material_base being the key word for base materials as material_procedural is for procedural materials.  Procedural and imagetexture materials can contain all of the base options after they specify their own options.  The procedural and imagetextures replace the diffuse color of a material before processing lighting and other effects.  It is recommended to at least include the coefficients option in all materials as otherwise it will all appear black.  Materials stick around after use on one object so that only one material declaration needs to be included for all objects that will use that material as long as they are listed after it and before another material declaration.

    On of the things that I would like to add but didn't is to incorporate a separate trace function into the bsptree for doing shadow rays.  Instead of looping through all objects that it eventually finds can possible intersect it would stop after it has encountered just one intersection.  If it has encountered at least one intersection then it must be in shadow and other intersections need not be tested.