Docsity

Ray Tracing Lab 3: Rendering Scenes with Ray Tracing Algorithm, Lab Reports of Computer Graphics

Toggle sidebar
bg1
Comp 360 Lab 3 : Rendering Scenes with Ray Tracing
First milestone due Saturday, 4 November 2006, 11:59 PM
Completed project due Wednesday, 15 November 2006, 11:59 PM
Overview
In this project you will implement a static ray-tracer for scenes containing primitive 3-
dimensional objects, including ellipsoids, boxes, cylinders, and cones. Your renderer will
support multiple light sources, object shadows, reflection, refraction, and transparency. Ad-
ditionally, you will create at least one interesting 3-dimensional scene, and render it with
your ray-tracer.
This project is due at 11:59 PM on Wednesday, November 15th. There is one project
milestone due at 11:59 on Saturday, November 4th. The whole project is worth 150 points.
For this lab, you must work with a partner other than the partners you worked with in
the first two labs. As soon as possible, send an email with your partner’s name and username
to [email protected]. If you have trouble finding a partner, let us know and we will try to pair
you up.
Specification
Your program will take a single command-line argument: the name of a text file that
defines a scene to render. The format of the text file is given in the section “Scene File
Format,” below. Under the Windows OS, the path to a file is passed as an argument to a
program if the program is opened by dragging the file onto the program’s icon.
When the program starts, the window will contain only a black background. Once the
scene file is successfully parsed, your program should begin rendering the scene. The scene
should be rendered progressively– that is, as soon as you have calculated the color for a pixel,
that pixel should be colored in the window. Your program should not wait for the rendering
process to finish before displaying the scene.
All images should be rendered at a resolution of 500 by 500 pixels. (You can modify the
constants WIDTH and HEIGHT in OpenGLFrame.h to set the window size automatically.)
Milestone 1 (65 points)
By the first milestone deadline, your program must do the following:
•Render scenes containing any number of light sources and spherical objects. No other
object types are required at this time.
•Implement the ray-tracing illumination model.
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Ray Tracing Lab 3: Rendering Scenes with Ray Tracing Algorithm and more Lab Reports Computer Graphics in PDF only on Docsity!

Comp 360 Lab 3 : Rendering Scenes with Ray Tracing

First milestone due Saturday, 4 November 2006, 11:59 PM Completed project due Wednesday, 15 November 2006, 11:59 PM

Overview

In this project you will implement a static ray-tracer for scenes containing primitive 3- dimensional objects, including ellipsoids, boxes, cylinders, and cones. Your renderer will support multiple light sources, object shadows, reflection, refraction, and transparency. Ad- ditionally, you will create at least one interesting 3-dimensional scene, and render it with your ray-tracer.

This project is due at 11:59 PM on Wednesday, November 15th. There is one project milestone due at 11:59 on Saturday, November 4th. The whole project is worth 150 points.

For this lab, you must work with a partner other than the partners you worked with in the first two labs. As soon as possible, send an email with your partner’s name and username to [email protected]. If you have trouble finding a partner, let us know and we will try to pair you up.

Specification

Your program will take a single command-line argument: the name of a text file that defines a scene to render. The format of the text file is given in the section “Scene File Format,” below. Under the Windows OS, the path to a file is passed as an argument to a program if the program is opened by dragging the file onto the program’s icon.

When the program starts, the window will contain only a black background. Once the scene file is successfully parsed, your program should begin rendering the scene. The scene should be rendered progressively– that is, as soon as you have calculated the color for a pixel, that pixel should be colored in the window. Your program should not wait for the rendering process to finish before displaying the scene.

All images should be rendered at a resolution of 500 by 500 pixels. (You can modify the constants WIDTH and HEIGHT in OpenGLFrame.h to set the window size automatically.)

Milestone 1 (65 points)

By the first milestone deadline, your program must do the following:

  • Render scenes containing any number of light sources and spherical objects. No other object types are required at this time.
  • Implement the ray-tracing illumination model.
  • Implement shadow, reflection, refraction, and transparency effects for spherical objects.

Final Submission (65 points)

By the final project deadline, in addition to the requirements for milestone 1, your pro- gram must do the following:

  • Be able to ray trace all 5 object types: spheres, ellipsoids, boxes, cylinders, and cones
  • Render any scene given in the file format specified below.

Sample Files / Pretty Pictures (20 points)

Your final submission should contain one or more scene files of your own creation. Be creative. Your files should demonstrate all the various ray tracing effects and all the object types. (Though you can get full credit for only one scene, you are encouraged to submit sev- eral.) For each scene file you create, please include a picture file in jpg format that contains your renderer’s output for that scene. Please put effort in this portion of the lab.

You may receive extra credit if you implement the torus.

Implementation Notes

  • See the lecture notes posted on the Comp 360 web site for the algorithms and calcula- tions used in recursive ray tracing. For alternative presentations, you might also want to look at Foley and van Dam’s book or on the web.
  • You may assume that the viewer is at the origin (0,0,0) and looking towards the positive z axis (0,0,1). Choose a reasonable viewing angle (60 degrees is average) and document your choice.
  • Implement affine and projective transformations as given in the lectures. You will need these transformations to calculate ray-object intersections. (As usual, you must use your own code for mathematical computations.)
  • Remember, when a ray intersects a reflective or refractive surface, rays are traced recursively from the point of intersection.
  • Shadow rays are NOT refracted. If a shadow ray hits an object with a positive transparency coefficient t, scale the contribution of the light source by t and continue tracing the shadow ray.
  • Your program may assume that input files are well-formed.
  • Your program must implement near and far clipping planes. Please document what these planes are in your README file.

a README file containing:

  • The names and usernames of you and your partner.
  • A brief overview of how your code is organized.
  • Information about your scene files.
  • Any known bugs or incomplete features.
  • Any other implementation details you think your grader should know.

Only one partner per group should turn in code. The other partner should put a README file in his or her own ~/comp360/lab3 directory that gives their partner’s name and username.

Do not touch the files in your submission directory after the project deadline. If your project will be completed late, email your labby and let him know. Otherwise, he may attempt to grade an incomplete or nonexistent project directory, and the project grade will reflect this.

Turning In Milestone 1

Please follow the same submission directions as above when you complete Milestone 1, but put the milestone files in the directory ~/comp360/lab3-milestone. The README for the milestone requires only your name and a list of the features your milestone code supports. Do not touch the milestone files after the milestone deadline; late milestone submissions will incur penalties at the usual rate.

Scene File Format

A lab 3 scene file is an ASCII text file containing data that define lighting and geometry for a ray-traced scene. A scene file is organized into two parts, lighting attributes and object definitions. Lighting attributes are always given first.

In a scene file, values are separated by one or more blank spaces. Scene files support C++-style double-backslash (//) comments– the double backslash characters mean that input should be ignored until the next newline character. An example file appears at the bottom of this document.

Lighting Attributes

The lighting of the scene appears in the following sequence.

  1. The scene’s ambient light color. (Three floating point values.)
  1. The number of lights in the scene – at least 1. (One integer.)
  2. For each light

(a) The light’s position in space. (Three floating point values.) (b) The light’s color. (Three floating point values.)

Object Definitions

Beneath the lighting attributes, the input file will contain at least one object definition. Object definitions are given with the following sequence.

  1. The number of objects in the scene – at least 1. (One integer.)
  2. For each object

(a) The object’s type, one of the strings “ellipsoid”, “box”, “cone”, or “cylinder”. (b) A set of numbers defining the object’s geometry– format varies, see below. (c) A set of numbers defining the object’s material properties. The format is the same for all objects.

The object definition formats are as follows.

Sphere

A sphere is defined by the following values.

  1. The coordinates of the center of the sphere. (Three floating point values.)
  2. The radius of the sphere. (One floating point value.)

Ellipsoid

An ellipsoid is defined by the following values.

  1. The coordinates of the center of the ellipsoid. (Three floating point values.)
  2. Unit vector in the direction of the ellipsoid’s first axis, v1. (Three floating point values.)
  3. Unit vector in the direction of the ellipsoid’s second axis, v2. (Three floating point values.) Dot product of v1 and v2 should be zero.
  4. Unit vector in the direction of the ellipsoid’s third axis, v3. (Three floating point values.) v3 should be the cross product of v1 and v2.
  5. Length of ellipsoid along v1 (floating point value).
  1. Length of the second axis of the cylinder’s elliptical base (floating point value).

Note that if the last two values are equal, the cylinder’s base is a circle, and the result is a canonical cylinder.

Cone

A cone is defined by the following values.

  1. The coordinates of the center of the base of the cone. (Three floating point values.)
  2. Unit vector along of the first axis of the ellipse that forms the cone’s base. (Three floating point values.)
  3. Unit vector along the second axis of this ellipse. (Three floating point values.) Dot product of this vector and the vector along the first axis should be 0.
  4. Unit vector in the direction cone’s central axis. (Three floating point values.)
  5. Height of the cone along the axis (the distance from the center of the cone’s base to the vertex of the cone). (Floating point value).
  6. Length of the first axis of the cone’s elliptical base (floating point value).
  7. Length of the second axis of the cone’s elliptical base (floating point value).

Material Properties

Immediately after the definition of an object’s geometry, its material properties are given as follows.

  1. The object’s ambient coefficient. (3-Floating point values between 0 and 1.)
  2. The object’s diffuse coefficient. (3-Floating point values between 0 and 1.)
  3. The object’s specular coefficient. (3-Floating point values between 0 and 1.)
  4. The object’s specular exponent. (Floating point value.)
  5. The object’s color. (Three floating point values.)
  6. The object’s reflective coefficient. (Floating point value between 0 and 1.)
  7. The object’s transparency coefficient. (Floating point value between 0 and 1.)
  8. The object’s index of refraction. (Floating point value.)

Sample File

// Lighting 1 1 1 // R, G, B of ambient color 1 // Number of light sources 10 10 0 // x, y, z position of the first light source 1 1 1 // Color of the first light source

// Objects 2 // Number of objects

// First object cylinder // Type 0 0 0 // x, y, z coordinates of center of the base of the cylinder 1 0 0 // Normalized vector of first axis of the ellipse forming the // base of the cylinder 0 1 0 // Normalized vector of the second axis of the ellipse 0 0 1 // Normalized vector of the direction of cylinder axis 20 // Height of the cylinder (along the axis) 5 6 // Length of each axis of the ellipse 0.1 0.1 0.1 // Ambient coefficient 0.45 0.45 0.45 // Diffuse coefficient 0.5 0.5 0.5 // Specular coefficient 5 // Specular exponent 0.1 .7 1 // R,G,B of material color 0.5 // Reflection coefficient 0.1 // Transparency coefficient 1.6 // Index of refraction

// Second object box // Type 0 0 0 // x, y, z coordinates of corner of box 1 0 0 // Normalized vector of the direction of Length (vl) 0 1 0 // Normalized vector of the direction of Width (vw). // (Dot product of vl and vw should be zero.) 0 0 1 // Normalized vector of the direction of Height (vh). // (vh should be the cross product of vl and vw.) 5 5 10 // The Length, Width, and Height of the box, in floats. 0.1 0.1 0.1 // Ambient coefficient 0.45 0.45 0.45 // Diffuse coefficient 0.5 0.5 0.5 // Specular coefficient 5 // Specular exponent 1 1 1 // R,G,B of material color 0.5 // Reflection coefficient 0.1 // Transparency coefficient