Assignment 6: Ray Tracing

Similar documents
Ray Tracer Due date: April 27, 2011

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

The feature set you are required to implement in your ray tracer is as follows (by order from easy to hard):

Topics and things to know about them:

Practical 2: Ray Tracing

Movie: For The Birds. Announcements. Ray Tracing 1. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

CS Simple Raytracer for students new to Rendering

Assignment 2 Ray Tracing

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

CS 184: Assignment 4 Simple Raytracer

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

Photorealism: Ray Tracing

COMP 175 COMPUTER GRAPHICS. Lecture 11: Recursive Ray Tracer. COMP 175: Computer Graphics April 9, Erik Anderson 11 Recursive Ray Tracer

COMP371 COMPUTER GRAPHICS

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Movie: Geri s Game. Announcements. Ray Casting 2. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

CS 465 Program 5: Ray II

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

COS 116 The Computational Universe Laboratory 10: Computer Graphics

CS 4620 Program 4: Ray II

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

Programming projects. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer

Ray Tracing Part 1. CSC418/2504 Introduction to Computer Graphics. TA: Muhammed Anwar & Kevin Gibson

CPSC GLOBAL ILLUMINATION

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Intro to Ray-Tracing & Ray-Surface Acceleration

Ray Tracing. Kjetil Babington

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Ray Tracer I: Ray Casting Due date: 12:00pm December 3, 2001

Project 1 Simple Ray Tracer

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

COS 116 The Computational Universe Laboratory 10: Computer Graphics

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Deferred Rendering Due: Wednesday November 15 at 10pm

Computer Graphics and Image Processing Ray Tracing I

CS 4620 Program 3: Pipeline

Raytracing CS148 AS3. Due :59pm PDT

Introduction to Visualization and Computer Graphics

Graphics 2009/2010, period 1. Lecture 8: ray tracing

Graphics for VEs. Ruth Aylett

Ray Tracing. Outline. Ray Tracing: History

CMSC427 Final Practice v2 Fall 2017

Lecture 11. More Ray Casting/Tracing

Sung-Eui Yoon ( 윤성의 )

CS 325 Computer Graphics

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Lighting and Shading

Homework #2. Shading, Ray Tracing, and Texture Mapping

Lecture 18: Primer on Ray Tracing Techniques

Computer Graphics. Shadows

CS 428: Fall Introduction to. Raytracing. Andrew Nealen, Rutgers, /18/2009 1

Ray Tracing CSCI 4239/5239 Advanced Computer Graphics Spring 2018

Supplement to Lecture 16

MITOCW MIT6_172_F10_lec18_300k-mp4

Ray Casting. Outline. Similar to glulookat derivation. Foundations of Computer Graphics

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Ray Casting. Outline in Code. Outline. Finding Ray Direction. Heckbert s Business Card Ray Tracer. Foundations of Computer Graphics (Fall 2012)

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

Shading, Advanced Rendering. Week 7, Wed Feb 28

03 RENDERING PART TWO

Virtual Reality for Human Computer Interaction

1999, Denis Zorin. Ray tracing

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

Ray Casting. To Do. Outline. Outline in Code. Foundations of Computer Graphics (Spring 2012) Heckbert s Business Card Ray Tracer

Computer Graphics Tick 1

Interactive Real-Time Raycasting

Photon Mapping. Due: 3/24/05, 11:59 PM

Comp 410/510 Computer Graphics. Spring Shading

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Graphics for VEs. Ruth Aylett

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

Recall: Basic Ray Tracer

L15 POV-Ray - Part 1

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Lecture 11: Ray tracing (cont.)

Lighting. Figure 10.1

Computer Graphics Ray Casting. Matthias Teschner

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

4) Finish the spline here. To complete the spline, double click the last point or select the spline tool again.

A Little Background. Motivation. Motivation

Global Illumination. COMP 575/770 Spring 2013

Effects needed for Realism. Computer Graphics (Fall 2008) Ray Tracing. Ray Tracing: History. Outline

COMPLETION OF Z-buffer Graphics Pipeline

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Advanced Lighting Techniques Due: Monday November 2 at 10pm

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

light light light B E

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

Transcription:

Assignment 6: Ray Tracing Programming Lab Due: Monday, April 20 (midnight) 1 Introduction Throughout this semester you have written code that manipulated shapes and cameras to prepare a scene for rendering. In this (final) assignment, you will be writing a raytracer for your scenes. 2 Requirements 2.1 The Raytracing Pipeline You learned in lecture the basic steps of the raytracing pipeline s inner loop: Generating rays (simplest case: Just shoot a ray through the center of each pixel) Finding the closest object along each ray Illuminating samples 2.2 Implicit Equations One of the real advantages of raytracing is that you don t have to work with approximations to the objects in your scenes. When your objects are defined by an implicit equation, you can render that object directly with a resolution as high as your image allows. You need to be able to render the following objects using their implicit equations: Cube, Cylinder, Sphere, and Cone. 2.3 Ray intersections and normals Your first task is to intersect a ray with objects in the scene. You can do so by writing an intersection code for a shape that allows for any position, orientation, and scale, but this is likely to be quite complicated. To re-use your code in the previous lab, you can instead transform the ray into the standard object s space (i.e., where the object has unit size centered at the origin) and then perform intersection. This is done simply by multiplying the ray equation with the inverse of the object transformation. 1

After intersection, you will need to transform both the intersection point and its normal back to the world space. To transform the intersection point from object space into world space, simply use the object transformation matrix. But, to transform the normal vector you computed in the object space to the world-space, you need to do something different. In particular, let the object transformation matrix be M, the intersection point be p object in the object space, and the normal vector be n object in the object space. The intersection and normal vector in the world space are obtained by p world = n world = M p object (M 1 ) T n object where n world needs to be re-normalized. That is, the normal vector is transformed by the inverse-transpose of the object transformation. This is necessary for the normal vector to be again orthogonal to the tangent plane of the shape at the intersection point in world-space. To see why this works, take a vector v object that lies on the tangent plane of the object at p object in the object-space, which is transformed into the world space by v world = M v object. The normal vector n world in the world space is orthogonal to v world : (n world ) T v world = ((n object ) T (M 1 )) (M v object ) = (n object ) T v object = 0 2.4 Illumination For this assignment you are required to write a program that, given a name of a scene file, will generate a high-quality image that correctly takes into account lighting, all surface characteristics, as well as shadows. You have already implemented the ray tracing portion of the assignment. Your primary job in this assignment is to correctly handle various surface characteristics: Point light sources Shadows Attenuation Reflection (Optional) Texture mapping must be able to map a texture onto the following shapes: Cube Cylinder Cone Sphere (Optional) Advanced Lighting (e.g. transparency, refraction) 2

To calculate the intensity of the reflection value, you need to determine the reflection vector based on object s normal and the look vector. You then need to recursively calculate the intensity of the intersection point that the reflection vector hits. With each successive recursive iteration, the amount of the reflection contribution to the overall intensity drops off. For this and for practical reasons, you need to set a limit to the amount of recursion your reflection is calculated with. Make sure that this value (level of recursion) is a variable or a constant instead of a hard coded value (i.e., check your current level of recursion against a variable like RECURSIVE LIMIT instead of a hard coded number like 5). TA s may want to change it when grading your work. If you do not implement your program this way, you will get some deduction. Texture mapping: To support texture mapping you can use the Fl BMP Image image class in FlTk to read bmp files. You should correctly deal with missing files preferably by popping up a dialog asking where the file is. To derive the final light intensity value for each of your pixels, you need to make sure that you can parse, store and use the following parameters for each of your object: trans [. object object name [ ambient <color > diffuse <color > specular <color > reflect <color > shine float texture filename u v Here, shine is the specular exponent, and reflect is the coefficient specifically for weighting the sum of illumination along the reflected ray (coefficient k r in the lecture). Some notes about texture mapping parameters: Filename should be a text file name of the texture you want to use for that shape. U and V values are how many times you should repeat the texture for that shape in X and Y texture coordinates. For example, if the 2 and 1 are used for U and V respectively, then, the pattern should repeat itself twice in X coordinates, but only once in Y coordinate. You can chose to ignore these parameters, but you get more bonus points if they work. 3 Support Code The support code is similar to the previous assignments. You should be familiar with how to set up your scene to be loaded. The code will call MyScene::render 3

with the rendering type (which you can safely ignore unless you are going to implement several rendering methods), the width and height of the target image, and an array of bytes that will hold the image. Recall from the first brush assignment how pixels can be stored as a big array of bytes representing the red, green and blue coefficients of each pixel in row major order. Feel free to refer to the support code from the brush lab if you need help with how to access and plot pixels into this bitmap. A first step is to simply plot some simple pattern into the array of pixels and return, so you can become familiar with how the code works. Next, implement ray-object intersection and simply plot the diffuse color of the objects you find. Finally, write a shade function which evaluates the lighting equation at the intersection point for each pixel. There is also a stoprendering method which gets called when the user clicks that button. You should gracefully bail out of your rendering code at the next scanline after stoprendering is called. (FlTk code is threaded.) 4 Extra credit Extra credit: Support one additional kind of light, either a directional light or a spotlight. If you want to implement the spotlight, the scenefile would look like something like the following. Spotlights have a point, direction, and an aperture in degrees, which dictates the steradian angle being subtended by the light cone. light [ id <number > type spotlight color <color > function <color > direction <vector > point <point> aperture <angle> Texture mapping: Requires calculating texture map coordinates for the intersected object point. Transparency/refraction: Refraction earns you more points than simple transparency, since you have to calculate the new refraction ray. Speed optimization: Speeding up raytracing is difficult. Usually, it is not enough to optimize inner loops, as there is just too much work that needs to be done for ray creation, intersection testing and illumination. You need to cut away large amounts of this work. You can try implementing some of the culling tricks, such as bsp-trees, octrees or grids. Others: See a TA if you have/need any ideas. Remember, if you implement something interesting, make sure you create sample scenefiles to demonstrate the capabilities clearly. Document all of this in your readme. 4

5 FAQ 1. My ray-tracer seems to be running really slow. What do I do? You are probably going to want small windows for testing your ray tracer. (Time spent is proportional to size of window.) 2. Where do I start? Start with a camera looking down the z axis and a single object (say a sphere) at the origin, no transforms. In this case the camera to world matrix is close to the identity (minus a scale) and the object s matrix is the identity. The intersection of the ray with the sphere should be on the positive z side, and the length of the vector from the intersection point to the origin is 0.5. Now add some simple lighting. Once this is working, apply a matrix transformation and see if it still works (make sure the sphere is visible by checking with your sceneview code). Once you ve got the scenes working with the basic lighting, then add in shadows. Finally, add in refraction. 5