CS 325 Computer Graphics

Similar documents
Reflection and Shading

Lighting and Shading

9. Illumination and Shading

CPSC 314 LIGHTING AND SHADING

CEng 477 Introduction to Computer Graphics Fall

surface: reflectance transparency, opacity, translucency orientation illumination: location intensity wavelength point-source, diffuse source

CS5620 Intro to Computer Graphics

Photorealism: Ray Tracing

COMP371 COMPUTER GRAPHICS

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

Homework #2. Shading, Ray Tracing, and Texture Mapping

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

Shading. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller/Fuhrmann

Ray Tracing. Kjetil Babington

Pipeline Operations. CS 4620 Lecture 10

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

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

Illumination and Shading

Introduction to Visualization and Computer Graphics

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

CS Illumination and Shading. Slide 1

Illumination Models & Shading

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Shading, Advanced Rendering. Week 7, Wed Feb 28

Computer Graphics. Illumination and Shading

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

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

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

Simple Lighting/Illumination Models

Ray Tracer Due date: April 27, 2011

Graphics for VEs. Ruth Aylett

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

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

Computer Graphics. Shading. Based on slides by Dianna Xu, Bryn Mawr College

Comp 410/510 Computer Graphics. Spring Shading

Visualisatie BMT. Rendering. Arjan Kok

CS 488. More Shading and Illumination. Luc RENAMBOT

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

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

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

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Lighting. Figure 10.1

CPSC / Illumination and Shading

Illumination and Shading

Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Raytracing. COSC 4328/5327 Scott A. King

CS 428: Fall Introduction to. Raytracing. Andrew Nealen, Rutgers, /18/2009 1

Illumination and Shading

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

Computer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

Topics and things to know about them:

Illumination & Shading

CEng 477 Introduction to Computer Graphics Fall 2007

Virtual Reality for Human Computer Interaction

Surface Rendering Methods

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

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

How do we draw a picture?

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

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

-=Bui Tuong Phong's Lighting=- University of Utah, but with shaders. Anton Gerdelan Trinity College Dublin

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Introduction to Computer Graphics. Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling Strategies" Ø The Hall illumination model. Ø Original ray tracing paper

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Graphics for VEs. Ruth Aylett

Illumination and Shading

Shading Techniques Denbigh Starkey

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

CS770/870 Spring 2017 Color and Shading

Illumination & Shading: Part 1

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

03 RENDERING PART TWO

CPSC GLOBAL ILLUMINATION

Reading. Shading. An abundance of photons. Introduction. Required: Angel , 6.5, Optional: Angel 6.4 OpenGL red book, chapter 5.

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

Introduction to Computer Graphics 7. Shading

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

Supplement to Lecture 16

Computer Graphics: 3-Local Illumination Models

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Illumination & Shading I

Illumination Models and Surface-Rendering Methods. Chapter 10

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

Shading 1: basics Christian Miller CS Fall 2011

Approximating Refraction Kenneth Hurley Please send me comments/questions/suggestions

Illumination. The slides combine material from Andy van Dam, Spike Hughes, Travis Webb and Lyn Fong

Raytracing CS148 AS3. Due :59pm PDT

Graphics Hardware and Display Devices

Transcription:

CS 325 Computer Graphics 04 / 02 / 2012 Instructor: Michael Eckmann

Today s Topics Questions? Comments? Illumination modelling Ambient, Diffuse, Specular Reflection Surface Rendering / Shading models Flat Gouraud Phong Ray tracing Ray Sphere intersections Ray Polygon intersections Michael Eckmann - Skidmore College - CS 325 - Spring 2012

Illumination Illustration of the Phong Reflection Model. Created by Brad Smith, August 7, 2006. Licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. Michael Eckmann - Skidmore College - CS 325 - Spring 2012

Illumination I = I a k a + f radatten (d L ) I p (k d L N + W(theta)cos ns (phi)) Notice the following: the Phong term is dependent on the point light source and the attenuation factor our whole illumination model at this point is influenced by ambient light and a point light source. Further, our object has diffuse reflection properties and specular reflection properties. And the phi angle is dependent on where the viewer is.

Illumination If we have more than one point light source (that are white light), then we sum up over all the light sources i: I = I a k a + Sum all i [f radatten (d L ) I pi (k d L N + W(theta)cos ns (phi))]

Illumination If the light sources are not white light sources, then we can separate out the red, green and blue components. Also, if objects are to be colored, then they reflect different wavelengths and absorb others. Specify ambient light now as 3 components: I ar I ag I ab Specify point light now as 3 components: I pr I pg I pb Specify objects with color: O R O G O B I R = I a R k a O R + Sum all i [f radatten (d L ) I pri (k d O R L N + W(theta)cos ns (phi))] I G and I B can be expressed similarly.

Illumination We typically want our Intensities to be in the range 0 to 1. With many light sources that are specified as too intense, computed intensities of objects can easily be too large (> 1). We can normalize the range of calculated intensities into the range 0 to 1. Or we can specify our light source intensities better and if any calculations go over 1, then clip them to intensity 1.

Directional light source The light sources that we have discussed so far were point light sources which radiated light in all directions. Real lights in the world do not have this property. Instead, real lights typically are directional. A directional light source can be described as having a position a directional vector an angular limit from that vector a color The vector will be the axis in a cone shaped volume. This volume is the only part of space that will be illuminated by this light. Anything outside the cone will not be illuminated by this light. See diagram next slide.

Directional light source To determine how intense the light is from a directional light source on an object we determine the angle between the vector V o from the position of the light to the point on the object we're illuminating and the cone axis vector V l So, we take the dot product: V o V l = cos alpha, alpha is the angle between them. If V o is in the same direction as V l, then the light should be the most intense (alpha = 0). The light should get less intense as we go in larger angles away from V l. We can attenuate the light as function of alpha like so: cos al alpha where al is the attenuation exponent (a property of the light source) --- if al is 0, it's a point light source, the smaller al is, the larger the attenuation is (because the cos is less than 1.)

Transparent/Translucent surfaces Transparent, opaque, translucent Transparent refers to the quality of a surface that we can see through. Opaque surfaces, we cannot see through. some transparent objects are translucent --- light is transmitted diffusely in all directions through the material translucent materials make the object viewed through them blurry

Transparent/Translucent surfaces Terminology index of refraction of a material is defined to be the ratio of the speed of light in a vacuum to the speed of light in the material. Snell's Law is a relationship between angle of incidence and refraction and indices of refraction.

Transparent/Translucent surfaces To determine the direction of the refracted ray, the angle ( theta r ) off of -N, we need to know several things the direction of the incoming ray, the angle ( theta i ) of incidence the index of refraction (eta i ) of the material the ray is coming from the index of refraction (eta r ) of the material the ray is entering

Transparent/Translucent surfaces 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 )

Transparent/Translucent surfaces 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 524 in our text. This assumes L is in the direction shown in the diagram 3 slides ago. Verifying that the equation above is correct is left as an exercise to the reader. It may appear on a hw assignment.

Transparent/Translucent surfaces Table 17-1 on page 524 in our text shows average indices of refraction for common materials, such as Vacuum (1.0), Ordinary Crown Glass (1.52), Heavy Crown Glass (1.61), Ordinary Flint Glass (1.61), Heavy Flint Glass (1.92), Rock Salt (1.55), Quartz (1.54), Water (1.33), Ice (1.31) Different frequencies of light travel at different speeds through the same material. Therefore, each frequency has its own index of refraction. The indices of refraction above are averages.

Illumination Illumination models are used to calculate the color of a point on the surface of an object. A surface rendering (aka shading) method uses the calculations from the illumination model to determine the pixel colors of all the projected points in a scene. Can be done by doing illumination model calculations at each pixel position (like you'll see is done in ray tracing). OR Can be done by doing a small number of illumination calculations and interpolating between pixels (like is often done in scan line algorithms.) Michael Eckmann - Skidmore College - CS 325 - Spring 2010

Surface Rendering Now that we have an illumination model built, we can use it in different ways to do surface rendering aka shading.

Shading Models Constant shading (aka flat shading, aka faceted shading) is the simplest shading model. It is accurate when a polygon face of an object is not approximating a curved surface, all light sources are far and the viewer is far away from the object. Far meaning sufficiently far enough away that N L and R V are constant across the polygon. If we use constant shading but the light and viewer are not sufficiently far enough away then we need to choose a value for each of the dot products and apply it to the whole surface. This calculation is usually done on the centroid of the polygon. Advantages: fast & simple Disadvantages: inaccurate shading if the assumptions are not met.

Interpolated shading model Shading Models Assume we're shading a polygon. The shading is interpolated linearly. That is, we calculate a value at two points and interpolate between them to get the value at the points in between --- this saves lots of computation (over computing at each position) and results in a visual improvement over flat shading. This technique was created for triangles e.g. compute the color at the three vertices and interpolate to get the edge colors and then interpolate across the triangle's surface from edge to edge to get the interior colors. Gouraud shading is an interpolation technique that is generalized to arbitrary polygons. Phong shading is another interpolation technique but doesn't interpolate intensities.

Shading Models Gouraud shading (aka Gouraud Surface Rendering) is a form of interpolated shading. How to calculate the intensity at the vertices? we have normal vectors to all polygons so, consider all the polygons that meet at that vertex. Drawing on the board. Suppose for example, n polygons all meet at one vertex. We want to approximate the normal of the actual surface at the vertex. We have the normals to all n polygons that meet there. So, to approximate the normal to the vertex we take the average of all n polygon normals. What good is knowing the normal at the vertex? Why do we want to know that?

Gouraud shading. Shading Models What good is knowing the normal at the vertex? Why do we want to know that? so we can calculate the intensity at that vertex from the illumination equations. Calculate the intensity at each vertex using the normal we estimate there. Then linearly interpolate the intensity along the edges between the vertices. Then linearly interpolate the intensity along a scan line for the intensities of interior points of the polygon. Example on the board.

Shading Models Advantages: easy to implement if already doing a scan line algorithm. Disadvantages: Unrealistic if the polygon doesn't accurately represent the object. This is typical with polygon meshes representing curved surfaces. Mach banding problem when there are discontinuities in intensities at polygon edges, we can sometimes get this unfortunate effect. let's see an example. The shading of the polygon depends on its orientation. If it rotates, we will see an unwanted effect due to the interpolation along a scanline. Example on board. Specular reflection is also averaged over polygons and therefore doesn't accurately show these reflections.

Shading Models Phong shading (aka Phong Surface Rendering). Assume we are using a polygon mesh to estimate a surface. Compute the normals at the vertices like we did for Gouraud. Then instead of computing the intensity (color) at the vertices and interpolating the intensities, we interpolate the normals. So, given normals at two points of a polygon, we interpolate over the surface to estimate the normals between the two points. Example picture on the board. Then we have to apply the illumination equation at all the points in between to compute intensity. We didn't have to do this for Gouraud. Problems arise since the interpolation is done in the 3d world space and the pixel intensities are in the image space. More accurate intensity value calculations, more realistic surface highlights and reduced Mach banding.

Recap Flat Shading Shading Models Gouraud Shading --- interpolates intensities Phong Shading --- interpolates normal vectors (before calculating illumination.) For these three methods, as speed/efficiency decreases, realism increases (as you'd expect.) They all have the problem of silhouetting. Edges of polygons on the visual edge of an object are apparent. Let's see examples of Gouraud and Phong shading.

Game plan Since your fourth programming assignment is to implement a raytracer I will cover ray tracing next Other topics for the remainder of the semester will be ray tracing texture mapping & bump mapping radiosity 3d model representations parametric curves mathematical representation of surfaces as opposed to polygon mesh approximations.

Ray Casting Recall Ray Casting which we discussed recently in our topic of Visible Surface Determination. To determine which surface is visible at a pixel, draw a ray starting at the CoP/PRP/eye through the center of the pixel and determine which surface it hits first. This method could be used to determine the color of the pixel with any of the illumination models discussed.

Ray Tracing Ray Tracing is a generalization of Ray Casting. Ray tracing is an image generation method that determines the color of a pixel in the image by tracing a ray from the eye (CoP/PRP) through the center of the pixel and out into the world determining if the ray intersect any surfaces if it does, consider only the closest surface. then bounce the ray off this surface one ray each in the direction of the light sources one reflected ray (if surface is specularly reflective) one refracted ray (if surface is transparent/translucent)

then bounce the ray off this surface Ray Tracing one ray each in the direction of the light sources one reflected ray (if surface is specularly reflective) one refracted ray (if surface is transparent/translucent) The rays that are in the direction of each of the light sources are called Shadow Rays. If a shadow ray directly hits a light source without first hitting another object then that light influences the color of the surface at that point. The reflected ray is bounced off the object at the angle it makes with the normal vector at the intersection, but on the other side of it (like we saw in the illumination model discussion of specular reflection.) The refracted ray is transmitted through the surface according to Snell's law which we recently covered.

Ray Tracing Further, the reflected ray and the refracted ray may also recursively generate shadow, reflected and refracted rays. terminate a path (the bounces) when a ray doesn't intersect a reflective/refractive surface or when we hit the maximum levels of recursion that we specify This ray tracing is done for each pixel in the image!

Ray Tracing The image on the next slide shows the original ray from the eye through a pixel and out into the world. It intersects with an object (the pyramid) and only the reflected rays are shown. A more accurate picture to depict ray tracing would show the shadow rays, and the refracted rays (if any).

Ray Tracing The original ray and it's reflected and refracted rays, and those reflected and refracted rays' reflected and refracted rays and so on can form a tree. Example of this tree on the next slide. Each node in the tree also has shadow rays (but they are not edges in the tree, since they cannot spawn further rays and they are treated differently.) The shadow rays are used to calculate the color/shading of the point on the surface (both the diffuse and specular components.) If a shadow ray does not reach a light source (that is, an object is in the way) then the point we're determining the color of is in the shadow of that light.

Ray Tracing From the description thusfar of ray tracing, it should be obvious that it often needs to determine if a ray intersects with anything and if so, where does it intersect Ray Tracing is time consuming / computationally expensive. We would like to have efficient methods to determine if a ray intersects with anything compute intersection points Since spheres are among the simplest shapes to ray trace, we'll discuss how to determine intersections between a ray and a sphere first. Then cover ray-polygon intersection calculations.

Ray Tracing After we discuss intersection calculations, we'll cover (again) how to compute the reflection ray and the refraction ray, given an incident ray. I'll provide a handout with psuedocode for a ray tracing algorithm.