联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2019-11-06 09:00

CSE 287 Project One Spring 2017.doc

CSE287- Page 1 of 7

Project One

Description: Your ray tracing work will conclude with this project. The project will require

you to implement shadow feelers to create shadows, trace reflection vectors to create

mirror-like inter-object reflections, and add additional types of shapes to a scene. Your

starting point for this lab is your completed lab four.

Your grade on this project will depend not only on successful implementation of

additional aspects of ray tracing, but also on quality of the scene that is rendered by

your project.

Simple Polygon Surfaces

Simple polygons are described by three or more vertices in same plane, are convex,

and have no sides which cross one another. The front face of the polygon is normally

defined as the face on which the vertices appear in counter clockwise order. The

surface normal for the polygon should point out of the front face.

Implement a sub-class of the Plane class that represents a simple polygon. The

constructor among other things should have an input parameter that is a vector of

vec3 objects which specify the vertex locations for the polygon in counter-clockwise

order.

The sub-class should use the findClosestIntersetion method of Plane class to

determine if the plane in which the polygon lies is intersected. It can then use the

method described in the notes to determine if the intersection is inside the polygon

CSE 287 Project One Spring 2017.doc

CSE287- Page 2 of 7

described by the vertices passed to the constructor. You should be able to account for

intersections with both the front and back side of the polygon. Both sides of the polygon

should be rendered with correct lighting.

Quadric Surfaces

Implement at least one specialized sub-class of the QuadricSurface class. Your

specialization should enable the rendering of a quadric surface such as a cylinder,

cone, ellipsoid, paraboloid, hyperbolic paraboloid, etc. Shapes such as the cone or

cylinder should not be infinite. It should be possible to render them in any position within

the scene. In your sub-class, use the findClosestIntersetion of the

QuadricSurface class to do the heavy lifting of intersection testing. In the sub-class

findClosestIntersetion method, you can then check the point of intersection to see

if it is in the more limited shape you are creating. Both sides of the surface should be

rendered with correct lighting.

Function to Look for Ray Intersections

Ray tracing is all about finding intersections between rays and surfaces in a scene. You

have already written code that carries out this task. You will need the functionality that

carries out this task to create shadows and reflections.

You will find the declaration of a function (not a method) called findIntersection. in

Lights.h (I left in in the lab code by mistake). It is defined it in Lights.cpp

#include "Lights.h"

HitRecord findIntersection( const glm::vec3 &e, const glm::vec3 &d,

std::vector<std::shared_ptr<Surface>> & surfaces)

{ …

}

The code in the function is similar to what you previously included in the RayTracer

class to fill in the body of this function. Modify your RayTracer class so that it calls this

function when individual rays are traced. Make sure everything still works.

CSE 287 Project One Spring 2017.doc

CSE287- Page 3 of 7

Shadows

Implement shadows by checking shadow feelers for intersections with the surfaces in

the scene. Cast a shadow feeler whenever a traced ray intersects an object. For

directional light sources, an intersection with a surface anywhere along a shadow feeler

that points in the direction of the light vector for the source should result in there being

no contribution from that light source. For positional light sources, an intersection with a

surface in between the origin of the shadow feeler and the position of the light source

should result in there being no contribution from that light source.

With the ray tracing infrastructure we have been developing in the labs, one way to

accomplish this would be to have the illuminate methods of the LightSource struct

and sub-structs to accept a third parameter containing all the surfaces in the scene.

Then the shadow feelers can be appropriately generated and tested for intersections

within the illuminate method by calling the findIntersection function.

virtual color illuminate( const vec3 & eyeVector,

HitRecord & closestHit,

vector<Surface*> surfaces) {…

Inter-Object Reflections

Add mirror-like inter object reflections by tracing a reflection ray to the closest surface

intersection for each view ray. Once generated, the reflection ray can be traced in

exactly the same way as the viewing rays. The best way to accomplish this is by calling

the traceIndividualRay method recursively and adding what it returns to the total

color for the pixel. To do this, it is necessary to keep the recursion from being infinite.

This can be accomplished by adding an additional parameter to the

traceIndividualRay method. This parameter can be decremented prior to each

recursive call. The recursion would stop when the value is less than or equal to zero.

color RayTracer::traceIndividualRay( const vec3 &e,

const vec3 &d,

int recursionLevel)

Taking it Further

Implement at least three of the following extensions for your ray tracing program. You

are of course encouraged to implement more if you like.

CSE 287 Project One Spring 2017.doc

CSE287- Page 4 of 7

Varying the Recursion Level

Add the ability to have the scene rendered with different levels of recursion for

reflection rays by pressing the number keys. You can do this by adding additional

cases to the switch statement in the KeyboardCB function in the Lab.cpp file. In

each case change the maximum recursion depth by modifying a data member in

the RayTracer class. The call to glutPostRedisplay at the bottom of the

KeyboardCB function will cause the scene to be rerendered when you press a

key.

static void KeyboardCB(unsigned char key, int x, int y)

{

switch(key) {

case('f'): case('F') : // 'f' key to toggle full screen

glutFullScreenToggle();

break;

case(27): // Escape key

glutLeaveMainLoop();

break;

case('0') :

rayTrace.recursionDepth = 0;

break;

case('1') :

rayTrace.recursionDepth = 1;

break;

case('2') :

...

Reflect the “Sky”

Reflection rays often do not intersect any surfaces in the scene. The illumination

for these non-intersecting rays can simply be “no color” or if can be a scaled

down default color. The later will cause shiny objects to appear to reflect the

default color as though it is the sky. Modify your program to create this effect.

Attenuation

Use constant, linear, and quadratic attenuation constants to attenuate the

contributions of positional light sources based on their distance from the point of

intersection.

Use attenuation to reduce the contribution of reflection vectors based on the

distance to the intersection between the reflection ray and the object it hits.

CSE 287 Project One Spring 2017.doc

CSE287- Page 5 of 7

Day and Night

Modify the program so that pressing the ‘d’ and ‘n’ causes the scene to be

rendered in day and night modes. You can simply “dim” the lights or change the

lighting entirely to create the two different effects.

Front and Back

Modify the program so that pressing the ‘a’ and ‘b’ keys causes the scene to be

rendered from two different opposite viewpoints.

Perspective Versus Orthographic Projection

Modify the program so that pressing the ‘p’ key causes the scene to be toggled

back and forth between perspective and orthographic renderings of the scene.

Antialiasing

Modify the program so that pressing the ‘l’ key toggles on and off antialiasing.

Because of the discrete nature of raster image representation, rendered images

will include aliasing artifacts. These artifacts create a jagged or stair stepped in

objects that should appear smooth. In ray tracing applications, anti-aliasing can

be performed by tracing multiple rays per pixel. The simplest approach it to

subdivide each pixel into the grid, cast one rays per grid square, and then set the

rendered pixel intensity to the average of color associated with the rays.

CSE 287 Project One Spring 2017.doc

CSE287- Page 6 of 7

Texture Mapping

Basic texture mapping uses a function to determine the diffuse color at the point

of intersection with a surface. I will provide a lab on texture mapping that will be

used in future sections of this course. If you are interested in adding texture

mapping to your project, use the lab as a guide. Incorporating texture mapping

would count as two extensions.

Turn it in

Submission instructions for this project are similar to the lab instructions with the

exception that you should also submit a screen capture of the best result you achieve

when rendering your scene.

1. When submitting your project include a screen capture of the scene that is created

CSE 287 Project One Spring 2017.doc

CSE287- Page 7 of 7

by your project.

2. Copy the folder containing your solution to the desktop.

3. Change the name of the folder to CSE287ProjectOne followed by your unique

identifier. For instance “CSE287ProjectOneBachmaer.”

4. Open the solution. Make sure it still runs.

5. Clean the solution by selecting Build->Clean Solution.

6. Zip up the solution folder using the standard windows compression tool. (No 7zips,

rars, etc.)

7. Submit your zip archive of the solution through canvas.

8. Upload a screen capture of the best result you achieve when rendering your scene.


版权所有:留学生编程辅导网 2018 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。