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

Similar documents
Raytracing CS148 AS3. Due :59pm PDT

Photorealism: Ray Tracing

Topics and things to know about them:

Lighting and Shading

Assignment 6: Ray Tracing

Comp 410/510 Computer Graphics. Spring Shading

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

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Computer Graphics Tick 1

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Assignment 2 Ray Tracing

COMP371 COMPUTER GRAPHICS

Ray Tracer Due date: April 27, 2011

Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling Strategies" Ø The Hall illumination model. Ø Original ray tracing paper

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

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Ray Tracing. Kjetil Babington

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

Shading I Computer Graphics I, Fall 2008

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

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

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

Pipeline Operations. CS 4620 Lecture 10

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Virtual Reality for Human Computer Interaction

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

Introduction to Computer Graphics 7. Shading

Visual cues to 3D geometry. Light Reflection and Advanced Shading. Shading. Recognizing materials. size (perspective) occlusion shading

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Ray-Tracing. Misha Kazhdan

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

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

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

CS5620 Intro to Computer Graphics

Algebra Based Physics

CS 184: Assignment 4 Simple Raytracer

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

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

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

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

Illumination & Shading: Part 1

COMP environment mapping Mar. 12, r = 2n(n v) v

Deferred Rendering Due: Wednesday November 15 at 10pm

CS Simple Raytracer for students new to Rendering

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

Illumination Models & Shading

MITOCW MIT6_172_F10_lec18_300k-mp4

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

WHY WE NEED SHADING. Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like.

CS 4620 Program 4: Ray II

The exam begins at 2:40pm and ends at 4:00pm. You must turn your exam in when time is announced or risk not having it accepted.

Raytracing. COSC 4328/5327 Scott A. King

Illumination & Shading

Supplement to Lecture 16

Introduction to Visualization and Computer Graphics

CS 4620 Midterm, March 21, 2017

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

Lighting affects appearance

Interactive Real-Time Raycasting

CS 325 Computer Graphics

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Chapter 12 Notes: Optics

Reflection and Shading

Computer Graphics. Illumination and Shading

Illumination in Computer Graphics

Recursive Ray Tracing. Ron Goldman Department of Computer Science Rice University

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

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

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

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

CSE 167: Lecture #7: Color and Shading. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

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

CS 465 Program 5: Ray II

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

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

Last Time? Ray Casting. Administrivia: Lab & Office Hours. Notes on Assignments. Ray Casting. Overview of Today

Light and the Properties of Reflection & Refraction

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

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

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

Shading. Why we need shading. Scattering. Shading. Objectives

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

CS 130 Final. Fall 2015

Pipeline Operations. CS 4620 Lecture 14

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

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

The University of Calgary

The exam begins at 2:40pm and ends at 4:00pm. You must turn your exam in when time is announced or risk not having it accepted.

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

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

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

Specular reflection. Lighting II. Snell s Law. Refraction at boundary of media

Sung-Eui Yoon ( 윤성의 )

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

lecture 18 - ray tracing - environment mapping - refraction

Simple Lighting/Illumination Models

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

Transcription:

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007 Programming For this assignment you will write a simple ray tracer. It will be written in C++ without using OpenGL. For full credit, it must support the following features: A camera with arbitrary position, direction, and orientation Arbitrary image resolution Triangle and sphere primitives Ambient, directional, and point lights Arbitrary materials defined by a color, Phong exponent, and specular fraction Diffuse and specular shading, and mirror reflections Cast shadows Note that the BMPImage library sometimes has problems with weird image resolutions, so you should stick with either powers of 2 (e.g. 64x64, 128x128,...) or standard resolutions (e.g. 640x480, 1024x768,...). The program must read from the command line the name of an input file describing the scene to be ray traced, the name of the output bmp file, and the image resolution. We have provided skeleton code that parses the command line and the scene input file. We have also provided sample input files, and the output files that the ray tracer should produce when using these as input.

The input file format consists of a series of commands, each followed by a list of parameters. Blank lines and lines beginning with # are ignored. The supported commands are: Format Example Description camera eye x,y,z look at point x,y,z up vector x,y,z y field of view degrees camera 0.0 0.0 0.0 0.0 0.0-100.0 0.0 1.0 0.0 30.0 Specifies the position, orientation, and direction of the camera. The image is defined to be 1 unit away from the camera in the direction the camera is facing. "eye" is the camera's position "look at point" is a point in the scene the camera is pointing at "up vector" gives the camera's orientation "y field of view degrees" is the angle from the top to the bottom of the image in the camera's up and down directions ambientlight intensity r, g, b directionlight intensity r, g, b direction x, y, z ambientlight 0.1 0.1 0.1 directionlight 0.3 0.0 0.0 1.0 1.0 1.0 Specifies an amount of light that is striking all objects in the scene. Each scene has at most one ambient light. Specifies a light coming into the scene from infinitely far away from the given direction ("direction" is the direction TO the light from any point in the scene). Direction lights can be shadowed. pointlight intensity r,g,b position x,y,z pointlight 0.0 300.0 0.0 30.0 10.0-50.0 Specifies a point light source located at the given position. Since the light intensity attenuates with distance, you may want to make the initial intensity much larger than 1. Point lights can be shadowed. material color r,g,b Phong cosine exponent specular fraction material 1.0 1.0 1.0 50.0 0.0 Specifies the material properties for all triangles and spheres declared after this point in the file (until the next material command). "specular fraction" is the fraction of the final color that comes from the Phong specular highlight and the mirror reflection. The remaining fraction of the final color comes from the diffuse Lambertian shading. triangle vertex1 x,y,z vertex2 x,y,z vertex3 x,y,z sphere center x,y,z radius triangle 5.0 0.0-50.0 15.0 0.0-50.0 15.0 10.0-50.0 sphere 10.0 5.0-47.5 1.0 Specifies a triangle primitive with the given 3 vertices. Specifies a sphere primitive with the given center and radius.

Points will be assigned as follows: 40 Points- Render spheres and triangles with ray tracing under ambient light. For this you will need to shoot rays from the eye position through the pixels in the image and into the scene, and test for intersection against the primitives. The pixel color will be determined by finding the closest intersection, and multiplying that primitive's material color by the ambient light. 30 Points- Add point and directional light sources with specular highlights and diffuse shading. Now, once you've found the closest ray intersection, you will need to compute a diffuse and a specular contribution to the final color from each light. The diffuse light contribution involves the angle between the surface normal and the light, while the specular light contribution involves the angle between the viewer and the light reflection, as well as the Phong exponent. The material's "specular fraction" tells what fraction of the final color should come from the specular light. The remaining fraction should come from the diffuse light, with the ambient light being added on top of these. Remember that point light intensity decreases proportional to the square of the distance from the light. 20 Points- Add cast shadows. To implement this, when computing the diffuse and specular contributions from each light, you will need to first cast a ray in the direction of the light from the intersection point on the surface. If the ray intersects another object that is closer than the light, the point is shadowed from the light, and the light should not affect it. 10 Points- Add mirror reflections. At each intersection point, recursively cast a ray from the point in the direction to the viewer reflected across the surface normal. This ray should not be cast if the recursion depth is greater than 5, or the surface material's "specular fraction" is 0. The light returned by this ray cast should be added to the specular light for this point. Extra credit: Add anti-aliasing with super-sampling. Instead of casting one ray through each pixel in the image, cast several through different points in each pixel, and average the resulting colors. Add refractions. Allow the index of refraction of materials to be specified in the scene file (your program should still be able to read scene files in the original format). You can assume the index of refraction of air is 1. When a ray intersects a surface, in addition to recursively casting a reflected ray, recursively cast a refracted ray in the direction given by Snell's law. The light returned by this ray should be added to the diffuse, specular, and ambient light.

Notes: One thing you need to be careful of when writing this program is that, due to roundoff error, the intersection distance reported by your intersect routines will be slightly incorrect. This can cause a problem if you shoot another ray from the intersection point, since it might end up intersecting the same surface it's supposed to be coming from. To prevent this, you should define some small constant epsilon (say, 0.01), and assume that any intersections at a distance along the ray less than this are not true intersections and ignore them. The images produced by your program do not have to be pixel-for-pixel accurate to the example image, although if there's significant deviation you may be doing something wrong. It's also not impossible that there are bugs in the demo program, so let us know if your program is producing different output than the demo that you really think is correct. Written Part: Pencil and Paper exercises (5 points each) 1. Suppose there is a thin sheet of glass which occupies the space in which 0<z<1. Light travels half as fast through this glass as it does through air. Suppose we use a laser located at (-10,0,11), to shine a light so that it strikes the glass at the point (0,0,1). Using Snell s law, answer the following: a. What will be the direction of the light when it is inside the glass? You can express this direction with a unit vector in this direction. b. If there is a sheet of paper occupying the plane z = -20, where will the light strike this paper? c. What would happen if the light traveled twice as fast in the glass as in air (ok, that s probably not possible, but imagine we are on some planet with really thick air)? In answering this question, you might have to look up information, eg., see: http://www.volpiusa.com/whitepapers/fundamentalsofoptics.pdf. 2. Suppose we are looking at a white, Lambertian sphere, which has a center at (0,0,50) and a radius of 20. We are using a perspective camera with a focal point at (0,0,0) and an image plane of z = 5. The camera is two units square. That is, imagine there is film covering a portion of the image plane in which we have z=5, and -1<x<1, -1 < y < 1. (The point here is that you can t see the whole sphere). a. Suppose we shine a directional light on the sphere with direction (0,0,1) (that is, the light seems to be coming from the camera). If the intensity in the image at the point (0,0,5) is 100, what will the intensity be at (0,0,.1)? b. Suppose that instead, we shine two directional lights of equal intensity, one with the direction (0,.11,.99), and the other with direction (0,-.11,.99). Suppose the point (0,0,5) still has an intensity of 100. Will any points in the image have different intensities from the ones they had in (a)? Explain.

c. Suppose we shine two directional sources on the sphere, in directions l and m. Give necessary and sufficient conditions that will guarantee that the white ball will have the same appearance in the image with these sources that it had in (a). We are looking for a very simple, elegant set of conditions. Not an answer like: If we plug these sources into the Lambertian equation we will get the same value at every pixel. 3. Suppose we have the same conditions as in problem 2, but the sphere reflects light using Phong reflectance. We have a single directional source of light with a direction of (0,.11,.99). a. What will be the brightest point in the image? b. Suppose the ratio of the intensity in the image at (0,0,5) to the intensity of the brightest point is.8845. What is the exponent that we are using for Phong reflectance? 4. Instead of a point source of light, let s imagine a continuous light. For example, consider a line segment of light stretching from (-1,0,0) to (1,0,0). This is a tube that emits a constant amount of light all along its length. The strength of this light still falls off with distance, d, at a rate of 1/d 2 as it does for any physically real light. a. Consider a surface located at the position (x,0,0), for x>1. Determine the amount of light that reaches this point from our tube of light. b. Explain why this lighting cannot be produced by a single point source of light whose strength drops at a rate of 1/d 2. Show that it can be produced by a non-physically real point source of light whose strength attenuates at 1 a rate of:. How would you choose a 2 0, a 1, a 2, to model this a 0 + a1d + a2d light?