CS 465 Program 5: Ray II

Similar documents
CS 4620 Program 4: Ray II

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

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

Assignment 6: Ray Tracing

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

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

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

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

CPSC GLOBAL ILLUMINATION

Assignment 2 Ray Tracing

Ray Tracer Due date: April 27, 2011

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

Today. Acceleration Data Structures for Ray Tracing. Cool results from Assignment 2. Last Week: Questions? Schedule

Computer Graphics Ray Casting. Matthias Teschner

Ray Tracing. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

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

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

TDA361/DIT220 Computer Graphics, January 15 th 2016

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

Questions from Last Week? Extra rays needed for these effects. Shadows Motivation

CS 431/636 Advanced Rendering Techniques

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

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

Raytracing CS148 AS3. Due :59pm PDT

Ray Tracing Acceleration. CS 4620 Lecture 20

Deferred Rendering Due: Wednesday November 15 at 10pm

CS 184: Assignment 4 Simple Raytracer

lecture 18 - ray tracing - environment mapping - refraction

CS Simple Raytracer for students new to Rendering

Point Cloud Filtering using Ray Casting by Eric Jensen 2012 The Basic Methodology

Advanced Ray Tracing

Ray Tracing. Brian Curless CSEP 557 Fall 2016

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

CS 4620 Midterm, March 21, 2017

Sung-Eui Yoon ( 윤성의 )

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

Lecture 18: Primer on Ray Tracing Techniques

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

Topics. Ray Tracing II. Intersecting transformed objects. Transforming objects

Project 3 Path Tracing

MITOCW MIT6_172_F10_lec18_300k-mp4

Lecture 11: Ray tracing (cont.)

Practical 2: Ray Tracing

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

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

Computer Graphics I. Assignment 3

Photorealism: Ray Tracing

Ray-tracing Acceleration. Acceleration Data Structures for Ray Tracing. Shadows. Shadows & Light Sources. Antialiasing Supersampling.

Introduction to Visualization and Computer Graphics

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

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

03 RENDERING PART TWO

Assignment 3: Path tracing

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

Chapter 9- Ray-Tracing

Home Lab 7 Refraction, Ray Tracing, and Snell s Law

Topics and things to know about them:

Topics. Ray Tracing II. Transforming objects. Intersecting transformed objects

Logistics. CS 586/480 Computer Graphics II. Questions from Last Week? Slide Credits

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

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

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

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

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

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

COMP371 COMPUTER GRAPHICS

Acceleration Data Structures

improving raytracing speed

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

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

Intro to Ray-Tracing & Ray-Surface Acceleration

CS 4620 Program 3: Pipeline

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

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

COMPUTER GRAPHICS AND INTERACTION

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

Shading, Advanced Rendering. Week 7, Wed Feb 28

Lighting and Shading

CHAPTER 1 Graphics Systems and Models 3

Spatial Data Structures

Lecture 11. More Ray Casting/Tracing

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

Intersection Acceleration

Review for Ray-tracing Algorithm and Hardware

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Acceleration. Welcome!

Spatial Data Structures

Ray Tracing Acceleration Data Structures

Recall: Basic Ray Tracer

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

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

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 24 Solid Modelling

Computer Graphics. Si Lu. Fall uter_graphics.htm 11/22/2017

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

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

CPSC / Sonny Chan - University of Calgary. Collision Detection II

CS 4620 Midterm 1. Tuesday 22 October minutes

Simple Nested Dielectrics in Ray Traced Images

Transcription:

CS 465 Program 5: Ray II out: Friday 2 November 2007 due: Saturday 1 December 2007 Sunday 2 December 2007 midnight 1 Introduction In the first ray tracing assignment you built a simple ray tracer that handled just the basics. In this assignment you will build a more capable ray tracer that can handle more substantial models and can produce much more interesting renderings. This assignment is rather open-ended relative to the earlier ones. The framework is the solution to the first ray tracing assignment. If you are happy with your Ray I solution you are encouraged to use it; otherwise you can start from our solution. You are free to design and implement the extensions in any way you like. 2 Requirements Your ray tracer will read files in a standard file format and output PNG images (like the first ray tracer). It has to support the basic features given below, plus an extension (or more for extra credit) as described below. 2.1 Basic features Your ray tracer must implement the following features beyond what the first ray tracer did: 1. An acceleration structure. Your program must be capable of rendering large models (up to several hundred thousand triangles) with basic settings in a few minutes. Achieving this requires a spatial data structure that makes the time to trace a ray sublinear in the number of objects. We recommend implementing an axis-aligned bounding box hierarchy (AABB), which is a simple and effective way of speeding up ray traversal. 2. Recursive ray tracing. You must implement two new shaders: one ( Glass ) that simulates an interface between air and a dielectric material, and another ( Glazed ) that acts like a thin layer of dielectric over another material. The glass shader should compute the directions of the reflected and refracted rays using Snell s law, compute the reflection factor using Fresnel s formulas, then trace reflected and refracted rays recursively and combine the results using the reflection factor. It needs to work for rays coming from both sides of the surface; you can always tell which side is air because the air is on the outside, the side toward which the normal 1

CS 465 Ray II 2 points. The glazed shader should compute reflections in the same way as the glass shader, but rather than tracing a refracted ray it should just call another shader (which represents the substrate below the glaze) and treat its result as the color of the refracted ray. A shader that uses recursively computed rays means that your renderer will generate a tree of rays, which needs to be pruned to keep the program from becoming too slow. In addition to a maximum-depth cutoff, you should also implement a maximum-attenuation cutoff by keeping track of how much a given ray will contribute to the image (i.e. what is the factor it is being multiplied by before it is added to the image). When that factor drops below a user-determined threshold, you should terminate recursion. Transparent objects should not cast black shadows; they should attenuate the illumination but not block it entirely. You should work out a way of computing the attenuation that produces shadows with an appearance you like. In the input file the glass shader is specified just by its index of refraction, through a parameter named refractiveindex: <shader type="glass"> <refractiveindex>1.5</refractiveindex> </shader> The glazed material is the same but also expects to see another shader for its substrate: <shader type="glazed"> <refractiveindex>1.5</refractiveindex> <substrate type="lambertian"> <diffusecolor>0.4 0.5 0.8</diffuseColor > </substrate> </shader > 3. Transformations. Your ray tracer must support transformations using an approach similar to the modeler. You should introduce a new type of surface, Group, that contains a transformation and a list of surfaces. The transformation is specified as a sequence of rotations, scales, and translations, which are combined in the order given to define the transformation that is applied to all members of the group. The transformation that appears first in the file is on the outside. All transformations apply to all objects, even if the transformations and objects are intermixed in the file (it makes most sense to put the transformations first, then the objects). Transformations are described in exactly the same way as in the modeler: translations and scales have components for x, y, and z; a rotation is actually a sequence of three rotations about the three coordinate axes, with the x rotation on the inside and the z rotation on the outside. The file format can be defined by example. For instance, if the a transformation in the modeling assignment was given as T: 1 2 3; R: 40 50 60; S: 0.7 0.8 0.9, the same effect can be specified in the ray tracer as follows: <surface type="group"> <translate>1.0 2.0 3.0</translate> <rotate>40 50 60</rotate> <scale>0.7 0.8 0.9</rotate>

CS 465 Ray II 3 <surface type="sphere"> <!--... --> </surface> <!-- more surfaces... --> </surface> 4. Triangle meshes. In order to allow for more interesting geometry than spheres and boxes, you must support triangle meshes. Since meshes can be quite large, it is not practical to process them using the parser, so they are stored in a simple text format in separate files. These files contain standard indexed triangle meshes, with optional texture coordinates and surface normals at the vertices. If the mesh contains vertex normals, you should shade it with interpolated normals; otherwise you should shade it with the triangles geometric normals. The input format for a mesh is just a filename reference: <surface type="mesh"> <shader><!--... --></shader> <data>filename.msh</data> </surface> The mesh file contains text as follows, one word or number per line: The number of vertices in the mesh. The number of triangles in the mesh. The keyword vertices The 3D coordinates of the vertices, ordered by vertex number: x 0, y 0, z 0, x 1, y 1, z 1,.... The keyword triangles Three integer vertex indices per triangle. (Optional) The keyword texcoords, followed by u and v coordinates for each vertex. (Optional) The keyword normals, followed by x, y, and z components of a normal vector for each vertex. You can find code that reads meshes in this format in the Mesh class of the Model assignment framework. 5. Antialiasing. You must support antialiasing by regular supersampling. The number of samples is specified by the samples property of the Scene class. For example, the following input specifies a 640 by 480 pixel image rendered with a 3x3 grid of subpixel samples for each pixel. <scene> <camera> <!--... --> </camera> <image>640 480</image> <samples>9</samples> </scene> You are free to round the number of samples to a convenient number (for example, to the nearest perfect square).

CS 465 Ray II 4 2.2 Extension features Your ray tracer must also implement one extension from the following list. 1. Cube-mapped backgrounds. A ray tracer need not return black when rays do not hit any objects. Commonly, background images are supplied that cover a large cube surrounding the scene. The directon of rays that do not intersect objects are used to as indices into these images and the color of the image in the rays direction is returned rather than black. The technique is commonly called cube-mapping. To implement cube-mapping in you ray tracer you will need to extend the Scene class to contain an image used as the cube map background. You will also need to write code that maps ray directions into cube-map pixels. A short introduction to cube-maps can be found here http://panda3d.org/wiki/index.php/cube_maps and many actual maps can be found here http://www.debevec.org/probes/. 2. Spotlights. Extend your point light source to be a circular spotlight. A spotlight has a direction, a beam angle θ b, and a falloff angle θ f, in addition to the usual position and intensity. For directions that make an angle less than θ b with the spotlight s direction, it produces the same intensity as a regular point light. For directions that are more than an angle of θ b + θ f from the spot direction, it produces no illumination. In the falloff zone it drops off smoothly according to a C 1 function of angle. In the input file an overhead spotlight with a full beam width of 30 degrees might look like this: <light type="spot"> <position>0 10 0</position> <intensity>1 1 1</intensity> <direction>0-1 0</direction> <beam>15</beam> <falloff>5</falloff> </light> 3. Adaptive image plane sampling. Rather than using a fixed number of samples per pixel, use an adaptive scheme. Start by tracing a grid of rays that are a few pixels (4 is a good starting number) apart. Then for each square of four pixels trace a ray in the center. If the ray is close to the average of the four neighbors, bilinearly interpolate the remaining pixels in the block. If not, recursively apply the same procedure to smaller blocks. You should use this same procedure to cast as many samples as necessary for antialiasing, up to a predetermined maximum recursion depth. 4. Propose your own. You can propose your own extension based on something you heard in lecture, read in the book, or learned about somewhere else. Doing this requires a little extra work to document the extension and come up with a good test case. If you want to do your own extension, email your proposal to the course staff list before the Thanksgiving break.

CS 465 Ray II 5 3 Implementation hints 3.1 Axis-aligned bounding boxes To implement an AABB you could take the following approach: 1. Create a class that defines an axis aligned bounding box. Design the class as you feel appropriate, but you will likely, at minimum, need methods to: determine if the box intersects a ray, determine if the box intersects another box, grow the box to include a point, and grow the box to include another box. You will also need to extend the Surface class to include a method that can grow a bounding box to include each surface type. 2. Design a class to represent a node in the hierarchy. Each node should have a pointer to a bounding box object, pointers to two children and a list of pointers to objects contained in the box. 3. Implement a method of building the hierarchy. The most straight forward approach is to create an AABB that encloses all the objects in the scene and then create a bounding volume node for this box and that includes all objects. Then recursively split this box and its children until the number of objects in each node is less than a constant (usually around 10). To split a node, choose an axis to split along, sort all the objects in the box along the axis and put each half in each of the children. The sort will require that you implement a method of sorting Surfaces. A good method is to sort by an approximation of their center: the center for Spheres and the average of the vertices for triangles. 4. Implement a method of traversing the hierarchy and finding the first object intersecting a ray. The method is described both in the lecture notes and in Shirley Chapter 10. 3.2 File format This assignment will require you to make several extensions to the existing code. Of course, you will need to be able to make test cases that can exercise the new features you will be adding. The framework s Parser class is designed to support this type of extension without change, but it requires that you implement the new features in a certain way. The requirements are: 1. Any class that will be instantiated by the Parser must implement a public constructor that takes no arguments. 2. Any class described by a block of xml that includes sub-tags must have public methods called either setxxx() or addxxx where XXX is the exact name of the sub-tag used in the description. These methods must take exactly one argument. The data will be parsed as if it is the same type as the argument. The Parser can correctly parse all primitive types, Strings, Colors and sub-classes of Tuple3. For example, if you wanted the following input to parse correctly: <foo> <bar>

CS 465 Ray II 6 <cat>lucky</cat> </bar> </foo> You would need to have classes with the minimum definitions: class Foo { public Foo() { public setbar(bar inbar) { //Do something with inbar class Bar { public Bar() { public setcat(string inname) { //Do something with inname Finally, the most common case is that you will be adding new shaders, surfaces, or lights. In this case, in addition to the requirements above, the new classes should extend Shader, Surface, or Light. You can then instantiate the correct class using the type argument. For example: <shader type="myshader"> </shader> is the correct way to specify an instance of a new shader class named MyShader. You can find comments with a more detailed description of the Parser in Parser.java. 4 Handing in When you hand in your ray tracer, in addition to the code you need to hand in input files that demonstrate its abilities. A fraction of the grade for this assignment will be set aside for the quality of your test cases: do they test your features well, so that we can tell for sure that they work, and do the images just look nice. None of the test images should take more than about 10 minutes to compute on a recent PC (such as the ones in the lab). You are required to submit at least 2 test input files for each of the items you implement above. Also hand in a text file (a page or so) with simple user documentation that explains how to use your program. For example, we need to know how to set any options or parameters that are not set through the input file, and we need to know about any extra extensions you made to the file format. Rendering contest: Finally, hand in one image, rendered at high quality and at high resolution (1280 pixels across) that shows off the best your program can do. Make the model interesting, and make the image aesthetically pleasing. We will award 10 extra credit points to the best image (on combined technical and aesthetic grounds) we receive, and 5 points to each of two runners-up.