Ray Tracer Help Session.

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
3D Graphics Rendering and Terrain Modeling
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Christian Lauterbach COMP 770, 2/11/2009
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
Ray Tracing Outline For each pixel { Shoot ray r from eye to center of pixel with trace( r ) } function trace( r ) For each object { Find object with closest.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
Ray Tracing 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Computer Graphics Mirror and Shadows
Presentation by Dr. David Cline Oklahoma State University
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Today More raytracing stuff –Soft shadows and anti-aliasing More rendering methods –The text book is good on this –I’ll be using images from the CDROM.
-Global Illumination Techniques
Ray Tracing Sang Il Park SEjong University With lots of slides stolen from Jehee Lee, Doug James, Steve Seitz, Shree Nayar, Alexei Efros, Fredo Durand.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
Ray Tracing Jian Huang, CS 594, Fall, 2002 This set of slides are used at Ohio State by Prof. Roger Crawfis.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Ray Tracer Winter 2014 Help Session Due: Tuesday, Feb 25 th, 11:59pm TA: Will Gannon.
Computer Graphics 2 Lecture 7: Texture Mapping Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Intro. to Advanced Lighting, Basic Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, April.
Ray Tracer Spring 2008 Help Session. Outline Project Web Resources What do you have to do for this project? Ray Class Isect Class Requirements Tricks.
Alex YAU Important Notes Website for Assignment #2 You.
- Laboratoire d'InfoRmatique en Image et Systèmes d'information
CS380: Computer Graphics Distributed Ray Tracing TA Course URL:
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Project 3 Help Session: Ray Tracing. Getting Started Download the starter pack. 1.sample_ray.exe 2.ray-skel directory 3.scenes directory Look at the Road.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
RENDERING : Global Illumination
Global Illumination (3) Path Tracing. Overview Light Transport Notation Path Tracing Photon Mapping.
Review Ray Tracing III Review. Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive.
Ray Tracer Help Session. Outline Introduction ray vec.h and mat.h isect Requirements Tips and Tricks Memory Leaks Artifact Requirement Ray Tracing Surface.
Advanced Computer Graphics
Basic Ray Tracing CMSC 435/634.
- Introduction - Graphics Pipeline
Photorealistic Rendering vs. Interactive 3D Graphics
Ray Tracer Spring 2007 Help Session.
Deferred Lighting.
3D Graphics Rendering PPT By Ricardo Veguilla.
Autumn 2010 Help Session Christopher Raastad
Interactive Computer Graphics
© University of Wisconsin, CS559 Fall 2004
Transformations.
Ray Tracer Project CSE 557.
(c) 2002 University of Wisconsin
Lecture 11: Recursive Ray Tracer
Distributed Ray Tracing
(c) 2002 University of Wisconsin
Image.
Progressive Photon Mapping Toshiya Hachisuka Henrik Wann Jensen
CS5500 Computer Graphics May 29, 2006
Ray Tracer Spring 2004 Help Session.
GR2 Advanced Computer Graphics AGR
Ray Tracer Project CSE 557.
Ray Tracer Spring 2008 Help Session.
Chapter 14 Shading Models.
Introduction to Ray Tracing
Distributed Ray Tracing
Ray Tracer Autumn 2005 Help Session.
Ray Tracer Spring 2006 Help Session.
Presentation transcript:

Ray Tracer Help Session

Outline Introduction ray vec.h and mat.h isect Requirements Tips and Tricks Memory Leaks Artifact Requirement Ray Tracing Surface of Revolution Using ply Models Bells and Whistles

Ray Tracer Given a ray “caster”, you have to implement: Shading (multiple parts) Reflection and Refraction Sphere Intersection Triangle Intersection Complex objects consist of a 3D mesh made up of triangles

ray A 3D ray is a fundamental component of a ray tracer. ray r(start position, direction, RayType) RayType, an enum, includes: VISIBILITY REFLECTION REFRACTION SHADOW Example: ray r(foo, bar, ray::SHADOW); r.at(t) – direction of r * distance t Returns the end position of the ray r after going a distance of t from its start position

vec.h and mat.h vec.h provides useful tools for 2D, 3D, and 4D vectors Easy Vector Construction – Vec3d x = Vec3d(0,0,0); Basic operators are overridden: + and – arthimetic, Vec3d v3 = v1 + v2; *, multiply by a constant, Vec3d v2 = 2*v1; *, dot product, double dot = v1 * v2; ^, cross product, Vec3d cross = v1 ^ v2; For other useful functionality, such as normalize(), length(), and iszero(), read vec.h for complete details mat.h is very similar, but for matrix operations not heavily used in this project

isect An isect represents the location where a ray intersects an object Important member variables: const SceneObject *obj – the object that was intersected double t – the distance along the ray where it occurred Vec3d N – the normal to the surface where it occurred Vec2d uvCoordinates – texture coordinates on the surface [1.0, 1.0] Material *material – non-NULL if exists a unique material for this intersect const Material &getMaterial() const – return the material to use

Requirements The following requirements need to be implemented: Sphere intersection Triangle intersection Blinn-Phong Specular-Reflection Model Multiple light sources Shadow attenuation Reflection Refraction

Requirement: Sphere Intersection Fill in Sphere::intersectLocal in SceneObjects\Sphere.cpp Return true if ray r intersects the canonical sphere (sphere centered at the origin with radius 1.0) in positive time Set the values of isect i: i.obj = this i.setT (time of intersection) i.setN (normal at intersection)

Requirement: Triangle Intersection Fill in TrimeshFace::intersectLocal in SceneObjects\trimesh.cpp Intersect r with the triangle abc: Vec3D &a = parent->vertices[ ids [0] ]; Vec3D &b = parent->vertices[ ids [1] ]; Vec3D &c = parent->vertices[ ids [2] ]; Return true if ray r intersects the triangle Need more help? See triangle intersection handout linked to on project website: http://www.cs.washington.edu/education/courses/cse4 57/handouts/triangle_intersection.pdf

Requirement: Blinn-Phong Specular-Reflection Model Fill in Material::shade in material.cpp Refer to the Ray Tracing lecture To sum over the light sources, use an iterator as described in the comments of the code CAUTION: If you are on the inside of an object, the object’s normal will point outside. For this case, you will need to flip the normal for any shading, reflection, or refraction.

Requirement: Multiple Light Sources Fill in PointLight::distanceAttenuation in light.cpp (distance attenuation for directional light is done for you) Use the alternative described in the ray tracing lecture where: a – constant term b – linear term c – quadratic term These terms are defined in light.h

Requirement: Shadow Attenuation Fill in DirectionalLight::shadowAttenuation and PointLight::shadowAttenuation in light.cpp The ray tracing lecture shows you where to insert this factor into the Blinn-Phong equation (a_shadow for each light) Rather than simply setting the attenuation to zero if an object blocks the light, accumulate the product of k_t’s for objects which block the light (use the prod function from vec.h) Count each intersection with an object by the shadow ray (includes entering and exiting) Extra Credit: Better shadow handling (caustics, global illumination, etc.)

Requirement: Reflection Modify RayTracer::traceRay in RayTracer.cpp to implement recursive ray tracing, which takes into account reflected rays See Shirley, et. al. and lecture slides

Requirement: Refraction Modify RayTracer::traceRay in RayTracer.cpp to create refracted rays Remember Snell’s law, watch out for total internal reflection, and consider the case when the ray is exiting a material into air (think about the direction of the normal) You can test refraction with simple/cube_transparent.ray Unlike reflection, this routine has several cases to consider: An incoming ray An outgoing ray Totally internally reflected ray nglass=1.5 nair=1.0003

Tips and Tricks Use the sign of the dot product r.getDirection() with i.N to determine whether you are entering or exiting an object Don’t write too much code without testing! Lots of dependencies, you need to know what works to proceed Use RAY_EPSILON (which is defined as 0.00001) to account for computer precision error when checking for intersections RAY_EPSILON

The Debugger Tool USE THIS, IT WILL SAVE YOUR LIFE! Shipped with skeleton code Find out how to use it here: http://www.cs.washington.edu/education/courses/cse4 57/13sp/projects/trace/extra/debug.html

Memory Leaks A memory leak can (and probably will) ruin your night hours before your artifact is due To test, try to ray trace a complex model (the dragon) with depth 10, anti-aliasing, HUGE Image Cause: not calling free after allocating memory Object constructors, vector (array) creation Solution: free stuff! Call the “delete [object]” on ANYTHING you create that is temporary i.e. 3 byte temporary vectors in the rayTrace function It is HIGHLY RECOMMENDED you have no memory leaks

Artifact Requirement Draw a pretty picture! One JPEG/PNG image traced with your Ray Tracer submitted for voting Has to be a (somewhat) original scene For each image submitted for voting, a short .txt description of the scene or special features Examples of each bell/whistle implemented with an accompanying readme.txt specifying which image demonstrates which feature (and where/how)

Ray Tracing Surface of Revolution Use this code snippet to write triangle mesh into a file: http://www.cs.washington.edu/education/courses/cse4 57/13sp/projects/trace/code/write_revolution_rayfile.c Use this .ray file as a template http://www.cs.washington.edu/education/courses/cse4 57/13sp/projects/trace/code/revolution.ray It contains default lighting of modeler Replace polymesh{} part with your own surface of revolution Render your new .ray file in tracer!

Sample Results texture mapping

Using ply Models ply is one of the standard formats for 3D models: http://en.wikipedia.org/wiki /PLY_(file_format) There are a plethora of ply models available online We provide a simple tool (ply2ray) that converts ply models into .ray files It is in your source folder, so check it out! You still need to add lightning and material property

Comparison Tool We will be using this tool (link on the course webpage) to evaluate your solution versus the sample. So you should check too !! Demo of comparison tool

Bells and Whistles TONS of awesome extra credit! Anti-aliasing – A must for nice scenes (to render scenes without “jaggies”) Interpolate trimesh material properties – will make them look nicer Envrionment/Texture/Bump Mapping – Relatively easy ways to create complex and compelling scenes Single Image Random Dot Stereograms Depth of field, soft shadows, motion blur, glossy reflection – most images we’re used to seeing have at least one of these effects NOTE: Please add control boxes for substantial ray tracing modifications so that required extension are easily gradable See sample solution style

3D and 4D Fractals

Constructive Solid Geometry Allows for complex objects while still just intersecting simple primitives