Review Ray Tracing III Review. Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive.

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Lecture 14 Illumination II – Global Models
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
Light Issues in Computer Graphics Presented by Saleema Amershi.
Light: Geometric Optics
Illumination Model & Surface-rendering Method 박 경 와.
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
Photorealism Reflection, Refraction Bump maps
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 14: Ray Tracing
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.
Ray Tracing Jerry Sui Adam Conner. Part I – Introduction to Ray Tracing Final Product.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
Ray Tracing 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 2: Basic Ray Tracing Ravi Ramamoorthi Some slides courtesy.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
RAY TRACING WITH DISPERSION CSS552 – Topics in Rendering Winter 2011 Final Project by: Kohei Ueda Shivani Srikanteshwara Mary Ann Chiramattel Kunjachan.
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
Presentation by Dr. David Cline Oklahoma State University
Project Raytracing. Content Goals Idea of Raytracing Ray Casting – Therory – Practice Raytracing – Theory – Light model – Practice Output images Conclusion.
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.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Ray Tracing.
Reflection & Refraction Of light By: Ahmed. Definitions Luminous objects – generate their own light (the sun) Illuminated objects – reflect light (the.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Test Corrections Due Tuesday, April 26 th Corrections must be done in a different ink color Lots of 4’s for effort – doesn’t mean answer is right! Check.
Gene Au-yeung, Daniel Quach, Jeffrey Su, Albert Wang, Jessica Wang, David Woo.
1 Ray-Tracing ©Anthony Steed Overview n Recursive Ray Tracing n Shadow Feelers n Snell’s Law for Refraction n When to stop!
Recursion and Data Structures in Computer Graphics Ray Tracing 1.
COMPUTER GRAPHICS PROJECT ON CUSTOM RAY TRACING ENGINE InterLight3D by Mehshan Mustafa ( ) Muhammad Zaki Shaheen ( )
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.
Basic Ray Tracing CMSC 435/634.
CS 450: COMPUTER GRAPHICS TRANSPARENT SURFACES SPRING 2015 DR. MICHAEL J. REALE.
CS380: Computer Graphics Distributed Ray Tracing TA Course URL:
Ray-tracing.
CS 376 Introduction to Computer Graphics 04 / 02 / 2007 Instructor: Michael Eckmann.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CSCE 441: Computer Graphics Ray Tracing
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.
Illumination 2013, Fall. Ray Casting Image RayCast(Camera camera, Scene scene, int width, int height) { Image image = new Image(width, height); for (int.
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Lighting Lighting.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
RENDERING : Global Illumination
CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
Light. Intensity calculation = wavelength I( ) = wavelength intensity of light reaching eye I( ) = I diff ( ) + I spec ( ) + I refl ( ) + I trans ( )
CS552: Computer Graphics Lecture 36: Ray Tracing.
Introduction to Ray Tracing Dr. B. Raghu Professor /CSE Sri Ramanujar Engineering College.
Basic Ray Tracing CMSC 435/634.
Advanced Computer Graphics
Hank Childs, University of Oregon
Illumination 2016, Fall.
Ray Tracer Project CSE 557.
Reflection and Refraction
Image synthesis using classical optics
GR2 Advanced Computer Graphics AGR
Ray Tracer Project CSE 557.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Reflection and Refraction
Reflection and Refraction
Presentation transcript:

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 (+ reflection) RayTrace-2  Recursive ray tracer (+ refraction)

Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive ray tracer (+ reflection) RayTrace-2  Recursive ray tracer (+ refraction) Friday, Dec 2

Pseudo Code for RayCast-1 // Global Variables rgb lsou; // intensity of light source rgb back;// background intensity rgb ambi;// ambient light intensity Point light // position of light source Object objects [n] // list of n objects in scene Camera cam; // camera settings Ray r;

My primitives in the scene Objects Object type material Sphere O // center R // radius … n kd // diffuse reflectivity factor ks // specular reflectivity factor n // shininess factor kr // refractivity index for each object Plane A,B,C,D // eq

RayCast-1 Image RayCast-1 (int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { r = ConstructRayThroughPixel (i, j); Intersection hit = FindIntersection (r); image[i][j] = GetColor (r, hit); } return image; }

RayCast-1 Image RayCast-1 (int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { r = ConstructRayThroughPixel (i, j); Intersection hit = FindIntersection (r); image[i][j] = GetColor (r, hit); } return image; }

Perspective Ray Generation

RayCast-1 Image RayCast-1 (int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { r = ConstructRayThroughPixel (i, j); Intersection hit = FindIntersection (r); image[i][j] = GetColor (r, hit); } return image; }

My primitives in the scene Objects Object type material Sphere O // center R // radius … n kd // diffuse reflectivity factor ks // specular reflectivity factor n // shininess factor kr // refractivity index for each object Plane A,B,C,D // eq Intersection index // closest-hit (-1 if none) P // point N // normal

Intersections with geometric primitives: Sphere Plane Triangle (you MUST implement the barycentric approach) Groups of primitives (scene) Ray-Scene Intersection Slides sets!! ray-lec-1 ray-intersect-2

RayCast-1 Image RayCast-1 (int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { r = ConstructRayThroughPixel (i, j); Intersection hit = FindIntersection (r); image[i][j] = GetColor (r, hit); } return image; }

rgb GetColor (Ray r, Intersection hit) { rgb intensity; if (hit.id = -1) // no intersection intensity = back else Intensity = Phong_illumination (r, hit); return intensity; }

rgb Phong_Illumination (Ray r, Intersection hit) { rgb intensity; return intensity; } r P N L R

Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive ray tracer (+ reflection) RayTrace-2  Recursive ray tracer (+ refraction) Mon, Dec 5

Pseudo Code for RayCast-2 // Global Variables – Exactly as in RayCast-1 rgb lsou; // intensity of light source rgb back;// background intensity rgb ambi;// ambient light intensity Point light // position of light source Object objects [n] // list of n objects in scene Camera cam; // camera settings Ray r;

RayCast-2 Image RayCast-2 (int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { r = ConstructRayThroughPixel (i, j); Intersection hit = FindIntersection (r); image[i][j] = GetColor (r, hit); } return image; } // Exactly as in RayCast-1

rgb GetColor (Ray r, Intersection hit) { rgb intensity; if (hit.id = -1) // no intersection intensity = back else { shadow = CheckShadow (hit); if (shadow) { Kd = objects[hit.id].material.kd Intensity = ambi * Kd } else Intensity = Phong_illumination (r, hit); } return intensity; }

boolean CheckShadow (Intersection hit) { }

NOT in shadow!

In shadow!

Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive ray tracer (+ reflection) RayTrace-2  Recursive ray tracer (+ refraction) Wed, Dec 7

Reflection

Reflection angle = view angle

Pseudo Code for RayTrace-1 // Global Variables rgb lsou; // intensity of light source rgb back;// background intensity rgb ambi;// ambient light intensity Point light // position of light source Object objects [n] // list of n objects in scene Camera cam; // camera settings Int depth; // depth of ray tree consisting of multiple paths Ray r;

RayTrace-1 Image RayTrace-1 (int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { r = ConstructRayThroughPixel (i, j); image[i][j] = GetColor (r); } return image; } Notice that now all ray-objects intersections are called within GetColor()

rgb GetColor (Ray r) { Ray flec; rgb spec, local, intensity; depth = depth +1 if (depth >= 5) intensity = back; else { Intersection hit = FindIntersection (r); if (hit.id = -1) intensity = back; else { if (objects.[hit.id].material.Ks >0) { flec = ComputeReflectionRay (hit) ; spec = objects.[hit.id].material.Ks* GetColor(flec); } else spec = 0; intensity = local + spec; } depth = depth -1 return intensity; } Recursive! shadow = CheckShadow (hit); if (shadow) { Kd = objects[hit.id].material.kd local = ambi * Kd } else local = Phong_illumination (r, hit); Check for shadow // as in RayCast-2()

Reflection The maximum depth of the tree affects the handling of refraction If we send another reflected ray from here, when do we stop? 2 solutions (complementary)  Answer 1: Stop at a fixed depth.  Answer 2: Accumulate product of reflection coefficients and stop when this product is too small.

rgb GetColor (Ray r) { Ray flec; rgb spec, local, intensity; depth = depth +1 if (depth >= 5) intensity = back; else { Intersection hit = FindIntersection (r); if (hit.id = -1) intensity = back; else { if (objects.[hit.id].material.Ks >0) { flec = ComputeReflectionRay (hit) ; spec = objects.[hit.id].material.Ks * GetColor(flec); } else spec = 0; intensity = local + spec; } depth = depth -1 return intensity; } Recursive! shadow = CheckShadow (hit); if (shadow) { Kd = objects[hit.id].material.kd local = ambi * Kd } else local = Phong_illumination (r, hit); Check for shadow // as in RayCast-2()

Memory stack eye (kd, ks, Phong) = (0.5, 0.7, 0.5) (kd, ks, Phong) = (0.1, 0.4, 0.3) (kd, ks, Phong) = (0.6, 0.2, 0.7) (kd, ks, Phong) = (0.3, 0.8, 0.8) depth = __________________ (back, ambi) = (0.32, 0.7) spec = _____ * local = ________ shadow? ___ intensity = _____ + _____ spec = _____ * local = ________ shadow? ___ intensity = _____ + _____ spec = _____ * local = ________ shadow? ___ intensity = _____ + _____ spec = _____ * local = ________ shadow? ___ intensity = _____ + _____ __ __ __ __ __ __ __

Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive ray tracer (+ reflection) RayTrace-2  Recursive ray tracer (+ refraction) Sat, Dec 10

(RayTrace-2) Ray Tracing Issues (RayTrace-2) 1)Cast a ray 2)Determine Intersections 3)For closest Intersection: Extend light shadow ray + calculate local term Extend light shadow ray + calculate local term Spawn Reflected Ray (go to step 2) Spawn Reflected Ray (go to step 2) Spawn Transmitted Ray (go to step 2) Spawn Transmitted Ray (go to step 2) I(P) = I local (P) + k s I(P r ) + k r (P t ) Local term Reflected Transmitted

Refraction From “Color and Light in Nature” by Lynch and Livingston

Refraction Snell’s Law Note that I is the negative of the incoming ray

Refraction Snell’s Law Note that I is the negative of the incoming ray Index of Refraction

Make sure you know whether you’re entering or leaving the transmissive material: Refraction & Sidedness of Objects T η T = material index η i =1 N T η T = 1 η i = material index N I I

Refraction Indices Index of refraction for various materials: Material Index Vacuum1.0 Air Water1.33 Alcohol 1.36 Fused quartz1.46 Crown glass1.52 Flint glass1.65 Sapphire1.77 Heavy flint glass1.89 Diamond2.42

Ray

?

entry_position ? Attention to the order!

entry_position

Pseudo Code for RayTrace-2 // Global Variables (same as in RayTrace-1) rgb lsou; // intensity of light source rgb back;// background intensity rgb ambi;// ambient light intensity Point light // position of light source Object objects [n] // list of n objects in scene Camera cam; // camera settings Int depth; // depth of ray tree consisting of multiple paths Ray r;

RayTrace-2 Image RayTrace-2 (int width, int height) { Image image = new Image(width, height); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { r = ConstructRayThroughPixel (i, j); image[i][j] = GetColor (r); } return image; } // Same as in RayTrace-1

rgb GetColor (Ray r) { Ray flec, frac; rgb spec, refr, local, intensity; depth = depth +1 if (depth >= 5) intensity = back; else { Intersection hit = FindIntersection (r); if (hit.id = -1) intensity = back; else { if (objects.[hit.id].material.Ks[j] >0) { flec = ComputeReflectionRay (hit) ; spec = Ks[j] * GetColor (flec); } else spec = 0; intensity = local + spec; } depth = depth -1 return intensity; } Recursive! Check for shadow // as in RayCast-2() Check for reflection // as in RayTrace-1()

rgb GetColor (Ray r) { Ray flec, frac; rgb spec, refr, local, intensity; depth = depth +1 if (depth >= 5) intensity = back; else { Intersection hit = FindIntersection (r); if (hit.id = -1) intensity = back; else { if (objects.[hit.id].material.Ks[j] >0) { flec = ComputeReflectionRay (hit) ; spec = Ks[j] * GetColor (flec); } else spec = 0; intensity = local + spec; } depth = depth -1 return intensity; } Recursive! shadow = CheckShadow (hit); if (shadow) { Kd = objects[hit.id].material.kd local = ambi * Kd } else local = Phong_illumination (r, hit); Check for shadow // as in RayCast-2() if (objects.[hit.id].material.Ks >0) { flec = ComputeReflectionRay (hit) ; spec = objects.[hit.id].material.Ks * GetColor (flec); } else spec = 0; Check for reflection // as in RayTrace-1()

rgb GetColor (Ray r) { Ray flec, frac; rgb spec, refr, local, intensity; depth = depth +1 if (depth >= 5) intensity = back; else { Intersection hit = FindIntersection (r); if (hit.id = -1) intensity = back; else { if (objects.[hit.id].material.Kr >0) { frac = ComputeRefractionRay (hit) ; refr = objects.[hit.id].material.Kr * GetColor (frac); } else refr = 0; intensity = local + spec + refr; } } depth = depth -1 return intensity; } Check for shadow // as in RayCast-2() Check for reflection // as in RayTrace-1()

rgb GetColor (Ray r) { Ray flec, frac; rgb spec, refr, local, intensity; depth = depth +1 if (depth >= 5) intensity = back; else { Intersection hit = FindIntersection (r); if (hit.id = -1) intensity = back; else { if (objects.[hit.id].material.Kr[j] >0) { frac = ComputeRefractionRay (hit) ; refr = objects.[hit.id].material.Kr * GetColor (frac); } else refr = 0; intensity = local + spec + refr; } depth = depth -1 return intensity; } Recursive! Check for shadow // as in RayCast-2() Check for reflection // as in RayTrace-1()

rgb GetColor (Ray r) { Ray flec, frac; rgb spec, refr, local, intensity; depth = depth +1 if (depth >= 5) intensity = back; else { Intersection hit = FindIntersection (r); if (hit.id = -1) intensity = back; else { if (objects.[hit.id].material.Kr[j] >0) { frac = ComputeReflectionRay (hit) ; refr = Ks[j] * GetColor (frac); } else refr = 0; intensity = local + spec + refr; } depth = depth -1 return intensity; } Shadowing Reflection Refraction

My primitives in the scene Objects Object type material Sphere O // center R // radius … n kd // diffuse reflectivity factor ks // specular reflectivity factor n // shininess factor kr // refractivity index for each object Triangle (p1,p2,p3) Other … Plane A,B,C,D // eq Mesh class MD2 Intersection index // closest-hit (-1 if none) P // point N // normal