CMPS 160 - Final Project

Fall 2009

Ray-tracer

Bryan Blackford & Tommy Hamala

 

Out project is a program on OpenGL that draws realistic scenes that simulate ray-tracing effects using 3D models.

 

 

 

What is Ray-tracing?

 

(Example of a scene rendered using ray tracing)

 

Ray-tracing is the method of casting a ray out from the camera (viewpoint) through every pixel on the screen and drawing whatever it hits first.

 

When a ray passes through a curved, clear object, such as a glass of water, it is refracted and continues down a different angle from which it entered. The refraction effect is caused by differences in the speed that light travels through different mediums. The angle of refraction is specified by the formula: Snell’s Law.

 

(Another example picture)

 

Furthermore, when an object has a reflective surface, it reflects objects on that surface. What is seen is determined by the shininess, of the object, the colors of both of the objects, and the location of the objects relative to each other and the viewer.

 

-----------

 

However, since OpenGL does not support true Ray-tracing, we have done our best to simulate Ray-tracing within the confines of OpenGL, using cameras and texture mapping. Our simulation creates a refraction/lens effect, reflections, and transparency.

 

The draw function has multiple modes. The default mode cycles through each of the texture cameras, calling draw for each camera, which renders the scene into the camera’s texture. After all the textures are rendered, the screen is rendered.

 

The object data structures are arranged hierarchically, with a point at the bottom, a polygon which has a point container, and an object which has a polygon container. The objects also have child objects, which share transformations with their parents. The polygons contain texture information, with the texture coordinates in the points. Normals for lighting are stored in the points and the polygons, either one can be used, but the point normals will overwrite the polygon normal if available.

 

The shapes are mostly provided through glu, including gluCylinder and gluSphere. These have built in texture mapping, which is very convenient for our purposes.

 

The mirrored surface is another camera, this time with the camera facing in the same direction as the surface normal. The mirror uses an orthographic projection to create a more realistic mirror.

 

 

Controls:

Camera Movement:

H + Right click drag – Move camera along the X axis (horizontal).

V + Right click drag – Move camera along the Y axis (vertical).

M + Right click drag – Move camera along the Z axis (movement).

P+Left click drag – Rotate object about X axis (pitch).

Y+Left click drag – Rotate object about Y axis (yaw).

R+Left click drag – Rotate object about Z axis (roll).

 

Object Manipulation:

>(.) – Change to the next model that you are manipulating.

<(,) – Change to the previous model from the one that you are manipulating.

X + Right click drag – Move an object along the X axis.

Y + Right click drag – Move an object along the Y axis.

Z + Right click drag – Move an object along the Z axis.

A+Left click drag – Rotate object about X axis.

B+Left click drag – Rotate object about Y axis.

C+Left click drag – Rotate object about Z axis.

S+Right click drag – Scale object

 

Lighting:

I – Increase the amount of ambient light in the scene.

O – Decrease the amount of ambient light in the scene.

9 – Increase the level of non-ambient light in the scene.

0 – Decrease the level of non-ambient light in the scene.

 

Movie:

Included in the report folder is a movie: cmps160-final.wmv

The movie stutters a bit, the actual application does not stutter.

 

References:

http://www.opengl.org/sdk/docs/man/

Lighting

Reflections [nehe]

Refraction [wiki]

TexShadowReflectLight.html

Tutorial14.php.htm

lights.htm