CSE 386 Fall 2020 Project Raytracing Instructions: ● Your project must be an interactive program that responds to the keystrokes, as outlined in the keystroke document. ● Videos illustrate the behavior of the project: ○ Video A ○ 0:00 Introduction 0:30 Lights 1:57 Shadows 2:15 Spotlight 3:25 Tie light to camera/world 5:05 Transparency 5:45 Shapes and textures ○ Video B ○ 0:00 Resizing 0:30 Reflections 1:28 Anti-aliasing ○ Video C ■ 0:00 Two viewports ● You may not use code developed by other students in previous semesters; you are expected to complete this project on your own. It is also worth noting that there are subtle differences between this semester’s code base and previous semesters. In addition, we may run scripts to detect unnatural similarities between all student submissions. ● You may not use glViewport or any other gl or glu functions. We never talked about these and you should not be using them. Of course, you may use glm functions. (74) REQUIRED FEATURES 1. (50) Lighting, shading, and shadows. The lighting/shading of your scene must include: a. (25) One positional light and the correct implementation of the equations to render the objects with a realistic appearance. Backfaces must be rendered. b. (15) Shadows. Implement shadows by checking shadow feelers for each surface intersection. If the shadow feeling intersects with another surface before the shadow feeler reaches the light source, that particular light should provide only the ambient contribution. c. (3) Attenuation that can be turned on/off via keystrokes. d. (7) Spotlight. The spotlight will illuminate only the intersection points that fall inside the light’s cone. If outside the cone, the light considers the intersection point as black (i.e., not even an ambient component). If inside the cone, the intersection point is rendered like a regular positional light. (Note: spotlights often have a different approach for rendering the interior of the cone. This approach will have a “falloff” factor that decreases as the point deviates from the center of the axis. Our class will simply render the interior of the cone using the same equations that are used for a positional light.) 2. (7) Objects. Your scene must include, at a minimum, the following objects, each with their own unique material properties. Please note that the list of required shapes differs from those presented in the project videos. a. Sphere b. Plane c. Disk d. Cylinder with finite length that has capped ends and is aligned with Y axis. e. Cylinder with finite length with open ends and aligned with Z axis. When setting up this cylinder, make sure that the open end is visible to the viewer. 3. (7) Textures. The Y-oriented (or X-oriented) cylinder must have its sides textured with any recognizable object that you choose (you must have a PPM file for the image); the image must be an object, not a texture (e.g., concrete, water, gravel, etc). To arrive at a color to display, merge the texel value with the computed lighted value (using the underlying, lighted, material property) at a 50-50 weighting. 4. (7) Transparency. Add at least one transparent plane to your scene. The position of the transparent object must be placed on a timer to illustrate that the display is correct, given its position relative to the opaque objects. That is, the transparent object must move in front of and then behind opaque objects. You do not need to handle the situation where multiple transparent objects are on top of each other. 5. (3) Resizing. The display must not display skewed images when the window is resized. (26) CHOOSE ANY TWO ADDITIONAL FEATURES - 13 POINTS EACH 1. Light tied to the world or tied to the camera. When the light’s position is (10, 10, 10), it is typically thought of as being at (10, 10, 10) in the global world coordinate system. However, it is sometimes useful to have the light’s position relative to the camera’s frame. Keystrokes should allow the user to switch between these two modes. The keystrokes that alter the spotlight’s position and direction should respond accurately. 2. Reflections. Add 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 -- depth -- 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. 3. Viewports. The scene will be rendered from two different vantage points. The two images will occupy the left and right halves of the screen respectively. The two camera positions must be chosen in a way to allow the user to obviously see that the two images come from the same scene, yet different enough to allow the user to discern that the images come from two different vantage points. 4. Anti-aliasing. 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. Your approach should subdivide each pixel into the, say, 3x3 grid, casting one ray per subpixel. The resulting color should then be the average color of the 9 rays (for a 3x3). A 3x3 will provide a more refined image than a 2x2 grid or 1x1 grid. Submit the following two items. Your submission time will be considered to be the later of the two times. 1. Zip file of your completed project. a. Open the project, perform a Build-Build Clean. Close MS VS. b. Make sure that you have a backup of your work. c. From the file manager: i. Visual Studio: 1. Delete the x64 directory that is in the project folder 2. Delete the .vs directory that is in the project folder 3. Delete CSE386Fall20202/x86 ii. XCode: 1. TBD d. Now zip up the top-level project folder and submit to Canvas. Provide a Canvas note to indicate if you are using XCode or MS Visual Studio e. The project must contain everything that is needed to run. That is double clicking on the SLN file (or .xcode) will allow us to run your code. If there are aspects that are missing, 10 points will be deducted. 2. Create a video that is at most 5 minutes long that includes: a. When demonstrating your project i. Make sure that the axes are visible ii. Call out the keystrokes as you make them (e.g., “turn off first light”, “increase x”, etc). iii. Make sure that your project is running before recording. b. Script i. Announce your name and give a brief summary of what aspects of your project work and those that do not. ii. Display your source for Raytracer::raytraceScene . Walk through the code, describing the main parts of the code. Assume that you are explaining this to the instructor. This part should be 30 seconds. iii. Demonstrate lighting 1. Basic lighting a. Make sure only one positional light is active. Make sure attenuation is turned off. b. Talk about your shapes and convince the viewer that the shading on your objects is accurate. c. Increase x one or more times, identify the changes to the objects’ shading that are consistent with the light moving toward the positive x axis. d. Decrease x. Make quick observations. e. Repeat for y and z. f. Point to your open-ended cylinder and show that both the inside and outside of the cylinder is rendered properly. 2. Demonstrate shadows a. Identify several properly rendered shadows. Move the light to verify the shadows are properly updated. 3. Attenuation a. Turn on attenuation. b. Set the coefficients: quadratic = 0, linear = 1, and constant = 0. c. Place the light over an empty section of the plane and increase and decrease the light’s y position to demonstrate the increasing and decreasing of the light’s intensity. Toggle attenuation on/off to show the difference. 4. Spotlight a. Turn on only the spotlight. b. Move the spot light’s position. Identify the parts of the scene that suggest your spotlight is correct. c. Move the spot light’s direction. Identify the parts of the scene that suggest your spotlight is correct. d. Turn on positional light and show that both lights work together to jointly brighten parts of the scene. That is the spotlight and positional light add up. iv. Demonstrate Objects 1. Point out the required objects v. Demonstrate Textures 1. Point out the textured object. vi. Demonstrate Transparency 1. Identify the transparent object and indicate why it is correct. vii. Demonstrate Resizing 1. Resize the window and show that the sphere’s still look spherical. viii. Demonstrate Two Additional features 1. Light tied to the world or tied to the camera 2. Reflections 3. Viewports 4. Anti-aliasing
欢迎咨询51作业君