Reflection and Refraction

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.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
CS 480/680 Computer Graphics Shading 2 Dr. Frederick C Harris, Jr.
Lecture 14 Illumination II – Global Models
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Light Issues in Computer Graphics Presented by Saleema Amershi.
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.
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
IMGD 1001: Illumination by Mark Claypool
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
3/23/2005 © Dr. Zachary Wartell 1 Illumination Models and Surface- Rendering Methods.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
7M836 Animation & Rendering
Ray Tracing Jerry Sui Adam Conner. Part I – Introduction to Ray Tracing Final Product.
Dr. Jie ZouPHY Chapter 35 The Nature of Light and the Laws of Geometric Optics.
Course Website: Computer Graphics 16: Illumination.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Shading Surface can either (both) 1.Emit light. E.g. light bult 2.Reflect light. E.g. Mirror.
Presentation by Dr. David Cline Oklahoma State University
Reflections Specular reflection is the perfect reflection of light from a surface. The law a reflection states that the direction of the incoming ray and.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Ray Tracing.
1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.
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.
1 Ray-Tracing ©Anthony Steed Overview n Recursive Ray Tracing n Shadow Feelers n Snell’s Law for Refraction n When to stop!
Basic Ray Tracing CMSC 435/634.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
Ray-tracing.
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.
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
CSE 681 Introduction to Ray Tracing. CSE 681 Ray Tracing Shoot a ray through each pixel; Find first object intersected by ray. Image plane Eye Compute.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.
CS552: Computer Graphics Lecture 33: Illumination and Shading.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Light. Intensity calculation = wavelength I( ) = wavelength intensity of light reaching eye I( ) = I diff ( ) + I spec ( ) + I refl ( ) + I trans ( )
Review Ray Tracing III Review. Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive.
Computer Graphics: Illumination
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
Introduction to Ray Tracing Dr. B. Raghu Professor /CSE Sri Ramanujar Engineering College.
Basic Ray Tracing CMSC 435/634.
© University of Wisconsin, CS559 Spring 2004
Photorealistic Rendering vs. Interactive 3D Graphics
Ray Tracing Dr. Scott Schaefer.
Real-Time Volume Graphics [06] Local Volume Illumination
Reflection Law of Reflection
Lecture 11: Recursive Ray Tracer
Ray Tracing.
Lighting.
Reflection and Refraction
CS5500 Computer Graphics May 29, 2006
Illumination and Shading
CSCE 441: Computer Graphics Ray Tracing
Simple Illumination CSE 681.
14th Lecture – Final Lecture
GR2 Advanced Computer Graphics AGR
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Light Refraction – the “bending” of light as it passes through a surface from one medium to another When light leaves a less dense media such as air and.
Reflection and Refraction
Simple Texture Mapping
Introduction to Ray Tracing
Presentation transcript:

Reflection and Refraction CSE 681

Review: Illuminate routine Given first intersection of ray with object p - point obj - object it intersects including material properties Color reflectivity n - normal vector of object at that point Calculate the color of that point Color = illuminate(p,obj,n) CSE 681

Color = illuminate(p,obj,n) Need: Position in space that is to be illuminated To form vectors to light, camera, etc. Normal vector To form reflection vector, compute angle to surface Access to object’s material properties Color, Reflection coefficients, specular power Access to scene data including Lights: position, type, color, etc Camera: position Other objects (shadows, reflections, etc.) CSE 681

Review: Illumination routine Directional/Point/Warn Intensity Color [Direction [Hood Angle]] L RE Color N Ambient: E Diffuse: Specular: ray CSE 681

Introduce SHADE routine to prepare for recusive organization For each pixel Compute ray, R, from eye through pixel C = shade(R) Pixel.color = C Color shade(R) { intersect objects – get closest intersection c = ambient For each light source Add in diffuse and specular components to c Return c } CSE 681

Reflective Ray Tracing It include reflection effects, in shade routine: Compute color of intersection point, just like before If object is shiny, spawn a reflective ray and call shade on that ray The color returned by reflective ray is attenuated by object’s shininess and added to point color Limit number of recursive calls by including count and don’t spawn ray if maximum is exceeded. CSE 681

Reflective Ray N S = kN - E S RE E k = E·N CSE 681

Reflective Ray Tracing Color shade(ray,recursionDepth) { intersect objects to get point, normal, object If (intersection) { c = ambient color Compute reflective ray, R, based on ray and normal For each light source Compute and add in diffuse and specular components to c If ( (recursionDepth < maxRecursion) && (object is shiny) ) c += object.shininess * shade(R,recursionDepth+1) } Else c = backgroundColor; Return c CSE 681

Reflective Ray Tracing CSE 681

WARNING ! Be careful not to have spawned reflection ray immediately intersect the object it is leaving! Either add epsilon to start of ray Or tag object as not intersectable Should be no intersection CSE 681

Refractive Ray Tracing Same idea as Reflective ray tracing – spawn a secondary ray The direction of the spawned ray is in the direction of the incoming ray altered a little bit The alteration is based on the material that the ray is leaving (e.g. air) and the material that the ray is entering (e.g., glass) Once this direction is computed, then the shade routine is called recursively, just as with reflective rays. CSE 681

Refractive Ray Tracing dir Medium c1 Medium c2 q1 q2 T2 Snell’s Law CSE 681

Refractive Ray Direction cos(q1) = -dir·n q1 n sin(q1) = sqrt(1- cos2(q1)) sin(q2) = n1*sin(q1)/n2 q2 cos(q2) = sqrt(1 - sin2(q2)) cos(q2) = sqrt(1 - (n1*sin(q1)/n2)2) cos(q2) = sqrt(1 - (n1/n2)2* (1- cos2(q1))) cos(q2) = sqrt(1 - (n1/n2)2* (1- (dir·n)2) NOTE: if radical is negative, no refraction! CSE 681

Refractive Ray Direction Go cos(q2) in the -n direction Go sin(q2) in the orthogonal direction (while still in the plane of dir and n) q1 dir This direction (scaled by sin(q1)) is: dir - (dir·n)n And scaled by sin(q2) is: (n1/n2)(dir-(dir·n)n) T = (n1/n2)dir - ((n1/n2)(n·dir) - cos(q2))n CSE 681

Recursive Ray Tracing Color shade(ray,recursionDepth) { intersect objects… compute R … Process each light source … If (recursionDepth < maxRecursion) { If (object is shiny) c += shininess * shade(R, recursionDepth+1) If (object is transmittive) { Compute refractive ray, T, based on ray, normal, and Snell constants c = (1-transmittive)*c + transmittive * shade(T, recursionDepth+1) } Return c CSE 681

Refractive Intersection Normal CSE 681

Recursive Ray Tracing n ray R1 T1 R2 T2 T3 R3 CSE 681

Reflectivity varies with incident angle NOTE: refraction is really wavelength dependent (where rainbows come from). Fresnel equations Schlick approximation: R0 is reflectance at normal incidence: CSE 681

From book: Assume one of the ni is always 1 (air); IF (p is on a dielectric) THEN r = reflect(d,n) IF (d.n<0) THEN { refract(d,n,n2,t) c=-d.n kr=kg=kb=1 } Else { kr=exp(-art) kg=exp(-agt) kb=exp(-abt) If refract(d,-n,1/n,t) then c=t.n Else return k*color(p+tr) R0=(n2-1)2/(n2+1) 2 R= R0+(1- R0)(1-c)5 Return k(Rcolor(p+tr)+(1-R)color(p+tt)) Assume one of the ni is always 1 (air); Call the other one n2 Also uses Beer’s Law to attenuate light passing through material (p. 214): I(s)=I(0)ea CSE 681