CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.

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
CS 376b Introduction to Computer Vision 04 / 21 / 2008 Instructor: Michael Eckmann.
Graphics Graphics Korea University cgvr.korea.ac.kr Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
May Visible Surface Detection Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
Light Issues in Computer Graphics Presented by Saleema Amershi.
Illumination Model & Surface-rendering Method 박 경 와.
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 02 / 24 / 2010 Instructor: Michael Eckmann.
CS 376b Introduction to Computer Vision 04 / 11 / 2008 Instructor: Michael Eckmann.
RAY TRACING.
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.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
Ray Tracing Jerry Sui Adam Conner. Part I – Introduction to Ray Tracing Final Product.
CS 376 Introduction to Computer Graphics 03 / 26 / 2007 Instructor: Michael Eckmann.
CS 376b Introduction to Computer Vision 04 / 15 / 2008 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 04 / 06 / 2007 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 03 / 30 / 2007 Instructor: Michael Eckmann.
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
CS 325 Introduction to Computer Graphics 03 / 03 / 2010 Instructor: Michael Eckmann.
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 04 / 11 / 2007 Instructor: Michael Eckmann.
-Global Illumination Techniques
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
College of Computer and Information Science, Northeastern UniversityOctober 18, CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.
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.
CS 325 Introduction to Computer Graphics 03 / 26 / 2010 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 03 / 24 / 2010 Instructor: Michael Eckmann.
1 Ray-Tracing ©Anthony Steed Overview n Recursive Ray Tracing n Shadow Feelers n Snell’s Law for Refraction n When to stop!
CS 376 Introduction to Computer Graphics 02 / 23 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 04 / 14 / 2010 Instructor: Michael Eckmann.
CS 450: COMPUTER GRAPHICS TRANSPARENT SURFACES SPRING 2015 DR. MICHAEL J. REALE.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Ray-tracing.
CS 376b Introduction to Computer Vision 03 / 18 / 2008 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 04 / 12 / 2010 Instructor: Michael Eckmann.
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
College of Computer and Information Science, Northeastern UniversityFebruary 3, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
CS 376b Introduction to Computer Vision 03 / 31 / 2008 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Radiosity Radiosity.
CS 325 Introduction to Computer Graphics 03 / 10 / 2010 Instructor: Michael Eckmann.
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.
CS552: Computer Graphics Lecture 33: Illumination and Shading.
CS 376 Introduction to Computer Graphics 04 / 13 / 2007 Instructor: Michael Eckmann.
CS 376 Introduction to Computer Graphics 04 / 18 / 2007 Instructor: Michael Eckmann.
Basic Ray Tracing CMSC 435/634.
Photorealistic Rendering vs. Interactive 3D Graphics
Distributed Ray Tracing
Ray Tracing.
GR2 Advanced Computer Graphics AGR
Simple Texture Mapping
Introduction to Ray Tracing
Presentation transcript:

CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS Spring 2010 Today’s Topics Questions? computing the reflected, and refracted ray directions. antialiased ray tracing Go over the pseudocode for ray tracing

Reflected Ray Given L, the incident ray (incoming ray) and the normal N of the surface (see figure in our text) we wish to calculate the reflected ray R. We assume that L and N are unit vectors (if they're not, make them unit vectors). We will compute the unit vector R in the correct direction. Drawing on the board. Note that fig shows L in a direction away from the surface. Typically we will have a vector pointing towards the surface, so if we are going to follow the procedure in the text to compute R, we must negate the vector we have to get L in the direction as shown in A is the angle between L & N, and between N & R, therefore we have L N = N R = cos A

Reflected Ray A is the angle between L & N, and between N & R, therefore we have L N = N R = cos A On the board (fig )‏ –Show the value of L N graphically –Show the sum of R and L graphically Therefore we can see that R + L = 2 (L N) N whose magnitude is 2 (L N)‏ and direction is in the direction of N So to compute R we get R = 2 (L N) N – L

Reflected Ray If you have a unit vector say L' in the opposite direction of L (as shown in figure 10-20) compute R to be R = 2 (-L' N) N + L'

Refracted Ray Given L, the incident ray (incoming ray) and the normal N of the surface (see figure in our text) we wish to calculate the refracted ray T. Recall that Snell's Law is a relationship between angle of incidence and refraction and indices of refraction.

Refracted Ray Snell's law states that sin ( theta r ) eta i = sin ( theta i ) eta r which can be written as: sin ( theta r ) = ((eta i ) / (eta r )) * sin ( theta i )‏

Refracted Ray Assuming all of our vectors are unit vectors, using Snell's law, according to our textbook we can compute the unit refracted ray, T, to be T = (((eta i ) / (eta r )) cos ( theta r ) – cos ( theta r )) N – ((eta i ) / (eta r ))L See page 578 in our text. This assumes L is in the direction shown in the diagram of figure

RayTracing and Antialiasing As was stated earlier, Ray Tracing works by shooting a ray from the eye (CoP) through the center of a pixel and from the information about the surface it hits and the lights, etc. a color & intensity is determined for the pixel. Let's see some example situations that give way to aliased images. –Not sampling enough –Staircasing of edges –High frequency textures can cause Moire patterns

RayTracing and Antialiasing An improvement to eliminate or at least reduce the aliasing effects just seen is to cast rays not through the center of the pixel, but through the corners of the pixel. Then compute a color at each corner. Then to set the color of the pixel do either: Supersampling –Take the average of the color of all four corners to set the pixel color. Adaptive Supersampling –in addition to using supersampling, if one corner's calculated color is significantly different than the other three (your call as to what is significantly different) then subdivide the pixel into four quadrants and shoot a ray through the additional 5 corners. Continue to do this until you decide to stop or when the four corners you're concerned with don't have one which is significantly different. –Then average the four corners of each of the subareas and the color of the pixel is determined by the colors of these subareas in proportion to their area. –Example on the board.

RayTracing Let's take a look at the handout which shows pseudocode for a recursive ray tracing algorithm and see what it entails. We'll have all our objects defined in the world (assume only spheres and polygons) with world coordinates. First part shows that we decide on a CoP and a view plane then go through the image to be created one pixel at a time from left to right on a scan line and top to bottom in scan lines. For each pixel we –Determine the ray through the center of the pixel starting at the CoP (how to we determine this?)‏ –Then call RT_trace and pass in that ray and the number 1 (for the current depth in the ray tree)‏ –RT_trace will return the color that the pixel should be RT_trace first determines which is the closest object of intersection (how would we do this?)‏ –If the ray doesn't intersect any object, then return the background color (whatever you decide it to be) otherwise...

RayTracing RT_trace first determines which is the closest object of intersection (how would we do this?)‏ –If the ray doesn't intersect any object, then return the background color (whatever you decide it to be) otherwise –call RT_shade with the closest object intersected, the ray, the point of intersection, the normal at that intersection (calculate this) and the depth (which is 1 the first time). How do we compute the point of intersection with the object? How do we compute the normal there? In RT_shade we set the color initially to be some ambient term (based on an ambient coefficient for the object, the object's color and our ambient light defined in our world.)‏ Go through all the lights in our world and determine the shadow rays one at a time. It then says “if the dot product of normal and direction to light is positive”. Can anyone describe what that tells us? –If a shadow ray is blocked by an opaque surface then ignore it. –If a shadow ray goes through a transparent surface reduce the amount of light transmitted by some factor (k t ) which is associated with the object (see Basic Transparency Model discussion on pages in text). –If a shadow ray doesn't intersect anything, then just attenuate the light based on the distance. Use this attenuated light and the surface's diffuse property to compute the diffuse term.

RayTracing Then add each of the shadow ray/diffuse contributions to the color RT_shade then continues as long as depth < MaxDepth. Depth is initially 1 and MaxDepth can be set to something like 4. –Recursively call RT_trace for the reflection ray (and depth+1) if the surface is specularly reflective Scale the color returned by the specular coefficient of the surface Add this to the color of the pixel we're calculating –Recursively call RT_trace for the refraction ray (and depth+1) if the surface is transparent Scale the color returned by the transmission coefficient of the surface Add this to the color of the pixel we're calculating Return color

RayTracing Comments about ray tracing –To store which object is closest for a given ray through a pixel, we could use an altered form of the z-buffer method. –How did z-buffer method (aka depth buffer) work again?

RayTracing A few comments about ray tracing –To store which object is closest for a given ray through a pixel, we could use an altered form of the z-buffer method. –How did z-buffer method (aka depth buffer) work again? It stored the color of the nearest surface for each pixel into the frame buffer and the distance into a z-buffer Instead of storing the distance into the z-buffer, store which object is closest into an item-buffer.

RayTracing A few comments about ray tracing –Instead of creating the same depth tree for each ray (that is, the number of levels of recursion) at a particular level, determine if the expected maximum contribution (to the color of the pixel) of the ray to be cast will not be above some threshold. If it is deemed to be insignificant, don't cast it. If it has the potential to be significant, cast it. For example, a primary ray hits an object which could cast a reflection ray and that reflection ray also hits an object and casts a reflection ray and that one also hits an object and can cast a reflection ray. The surface that the second reflection ray hits might have a very small specular coefficient thereby influencing the color of the pixel insignificantly, so, then don't cast that ray (and you can save the computation for that ray as well as the ray it would have spawned, and so on.)‏ Ideally in this situation, only the ones that count will be recursed to further depths.