Wednesday, August 26, 2015

Ray Tracing Graphics Rendering

Whenever I encounter something new and exciting I always want to know how it works. I want to know why it was built the way it is or how it can be customized. When using the program Adobe After Effects, I am stunned by how the preset objects (spheres, particles, lights) look realistic and physically accurate. I wanted to know how a computer could generate objects that incorporated scientific factors like light, reflection, shadows, and physics. Through an independent study with Ithaca College professor Paul Dickson, I got answers.
I worked for a semester with Paul to build a Ray Tracing Graphics Renderer. While that may be a mouthful it is actually a pretty simple concept that translates to complicated coding. The ray tracer that I built used object oriented programming. An object, in this case, is a class that has attributes, accessors, and mutators. 

For example, a sphere object:
attributes: position, radius, color
accessors: getPosition, getRadius, getColor
mutators: setPosition, setRadius, setColor
Image created from my ray tracing graphics renderer featuring planes.

All of these elements together give us an object or blueprint that we can create instances of. Once we have this outline we can have one sphere that is at position (0,0) with a radius of 5 and is red in color, as well as a green sphere at (8,10) with a radius of 2, etc.

Images from my ray tracing graphics renderer before an after
adding a light point in addition to ambient lighting.
In my ray tracer I had lines, spheres, planes, light points, and more. The light points were so that the objects placed in our virtual world could actually be seen. This is where some of the physics of computer graphics rendering came in. I was pretty much able to plug and chug numbers into my program to make the lighting work realistically but there is a lot of mathematics and research that goes into capturing the physics used in graphics renderers.
A ray tracer works by having a given perspective position or “camera” that sends a ray through every pixel of an image. If a frame of the movie is 1080x1920 pixels then the camera sends out 2,073,600 rays, which explains why ray tracing graphics takes so long and takes so much RAM. A ray has a starting point and travels infinitely in a direction. Sending out a ray means that every position between the camera and the last object in the virtual world is checked to see if it intersects with an object. If the ray intersects with an object then it sets that value of the pixel to be the color value of the objects. Lighting and physics may alter the color of the pixel as well.

When all of the rays have been sent then every pixel of the image should be colored and you will have final images like these:

Ray traced spheres with added camera effects like focal point and blur.
One Dragon object stores all of the dimensions and parameters for the dragon shape
and minor modifications to the values representing the physics of the light
make the dragon look like it is made of different materials.
This was ray traced and it makes me laugh.

1 comment :

  1. ROBLOX is driven by a growing membership base of more than 300,000 creators who generate an infinite variety of highly immersive experiences.

    These experiences range from 3D games and contests, to interactive adventures where friends can take on new avatars to discover what it feels to be a dinosaur, a miner working a mine or an astronaut out in space.