Chap 5 Global Illumination

Slides:



Advertisements
Similar presentations
SI31 Advanced Computer Graphics AGR
Advertisements

1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 6.
CSPC 352: Computer Graphics
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 MAE152 Computer Graphics for Scientists and Engineers Lighting in OpenGL.
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.
Based on slides created by Edward Angel
Illumination Model & Surface-rendering Method 박 경 와.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of New Mexico
Computer Graphics - Class 10
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Lighting and Shading Wen-Chieh (Steve) Lin
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
1 7M836 Animation & Rendering Global illumination, radiosity Arjan Kok
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
The Radiosity Method Donald Fong February 10, 2004.
Illumination and Shading
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Fundamentals of Computer Graphics Part 6 Shading prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 6: Shading Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Illumination & Reflectance Dr. Amy Zhang. Outline 2  Illumination and Reflectance  The Phong Reflectance Model  Shading in OpenGL.
Shading in OpenGL.
1 Chapter 6 Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting.
Shading and Illumination. OpenGL Shading Without ShadingWith Shading.
02/16/05© 2005 University of Wisconsin Last Time Re-using paths –Irradiance Caching –Photon Mapping.
Computer Graphics I, Fall 2010 Shading in OpenGL.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Shading Chapter 6. CS 480/680 2Chapter 6 -- Shading Introduction: Introduction: We have learned to build three-dimensional models and to display them.
111/17/ :21 Graphics II Global Rendering and Radiosity Session 9.
Radiosity Jian Huang, CS594, Fall 2002 This set of slides reference the text book and slides used at Ohio State.
DPL11/27/2015 CS 551/651: Radiosity David Luebke
11/04/04© University of Wisconsin, CS559 Fall 2004 Last Time Visibility –Z-Buffer and transparency –A-buffer –Area subdivision –BSP Trees –Exact Cell-Portal.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Shading NOTE: Some of these slides are from Ed Angel’s presentation at SIGGRAPH February 27, 2008.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 55 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 55 Computer Graphics Three-Dimensional Graphics V.
Shading To determine the correct shades of color on the surface of graphical objects.
Unit-7 Lighting and Shading
Shading in OpenGL Ed Angel
Illumination and Shading
Fundamentals of Computer Graphics Part 6 Shading
Lighting and Materials
CS5500 Computer Graphics April 10, 2006.
Illumination and Shading
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
CS 480/680 Computer Graphics Shading.
Presentation transcript:

Chap 5 Global Illumination Chap 6 of Angel’s book (2nd ed.) on shading Global illumination Ray tracing Radiosity Chap 5, Global illumination (CG-U) 1

Shading Local lighting Global lighting Light-material interactions can be computed, independent of any other surfaces in the scene. The calculations depend on only the surface material properties, surface’s local geometry, and parameters of the light sources. Can be added to a fast pipeline graphics architecture. Global lighting Lighting is a recursive process and amounts to an integral equation, the rendering equation. Approximations: ray tracing and radiosity. Chap 5, Global illumination (CG-U) 2

Light and matter -1 Light and surface We see the color of the light reflected from the surface toward our eyes. Human’s perception vs. computer image Chap 5, Global illumination (CG-U) 3

Light and matter -2 Light–material interaction When light strikes a surface, some of it is absorbed, some of it is reflected, and some of it is transmitted through the material. Specular surfaces, diffuse surfaces, translucent surfaces Chap 5, Global illumination (CG-U) 4

Light Sources -1 Light source Illumination function An object that emits light only through internal sources. Illumination function Each point (x,y,z) on the surface of the light source can emit light that is characterized by : the direction of emission : wavelength Chap 5, Global illumination (CG-U) 5

Light Sources -2 On a surface point that is illuminated Total contribution of the source is obtained by integrating over the surface of the source. The calculation is difficult for a distributed light source. Chap 5, Global illumination (CG-U) 6

Light Sources -3 Four types of light source Ambient lighting Provides a uniform light level in the scene. Can be characterized by a constant intensity Ia=[Iar,Iag,Iab] Each surface can reflect this light differently. Point light sources Spotlights Distant light Chap 5, Global illumination (CG-U) 7

Light Sources -4 Point light sources An ideal point source emits light equally in all directions. A point source at p0 can be characterized by At a surface point p, the intensity of light received from the point source is Chap 5, Global illumination (CG-U) 8

Light Sources -5 Point light sources An ideal point source emits light equally in all directions. A point source at p0 can be characterized by At a surface point p, the intensity of light received from the point source is Chap 5, Global illumination (CG-U) 9

Light Sources -6 Spotlight A point source with limited angles at which light can be seen. Represented as a cone Distribution of the light within the cone Uniform Represented as a function of , such as Chap 5, Global illumination (CG-U) 10

Light Sources -7 Distant light sources The light source is far from the surface. The source becomes point sources. Illuminate objects with parallel rays of light. In calculation, the location of the source is replaced by the direction of the parallel rays. Chap 5, Global illumination (CG-U) 11

Phong reflection model An efficient computation of light-material interactions. Consists of three terms Ambient term Diffuse term Specular term Chap 5, Global illumination (CG-U) 12

Computing vectors Normal vectors Angle of reflection Plane Plane equation Three non-coplanar points Implicit equations F(x, y, z)=0 Parametric surfaces P(u, v) Angle of reflection Chap 5, Global illumination (CG-U) 13

Polygonal shading Flat shading Gouraud shading Phong shading Produces Mach bands along the edges. glShadeMode(GL_FLAT) Gouraud shading glShadeMode(GL_SMOOTH) Phong shading No hardware support Almost always done off line Chap 5, Global illumination (CG-U) 14

Light sources in OpenGL -1 OpenGL supports 4 types of light sources, and allows at most 8 light sources in a program. Each must be individually specified and enabled . glLightfv(source, parameter, pointer_to_array) for vector parameters Source: source id, parameter: parameter type Position or direction of the light source Amount of diffuse, specular, and ambient light associated with the light source. glLightf(source, parameter, value) for scalar parameters Chap 5, Global illumination (CG-U) 15

Light sources in OpenGL -2 Glfloat light0_pos[]=[1.0, 2.0, 3.0, 1.0]; (point source) or Glfloat light0_dir[]=[1.0, 2.0, 3.0, 0.0]; (distant light) Glfloat diffuse0 []=[1.0, 0.0, 0.0, 1.0]; Glfloat specular0 []=[1.0, 1.0, 1.0, 1.0]; Glfloat ambient0 []=[1.0, 0.0, 0.0, 1.0]; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, light0_pos); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffues0); glLightfv(GL_LIGHT0, GL_SPECULAR, specular0); Chap 5, Global illumination (CG-U) 16

Light sources in OpenGL -3 For global ambient Glfloat global-ambient[]=[1.0, 0.1, 0.1, 1.0]; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient); For distance term based on The constant, linear, and quadratic term can be set individually by glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, a); glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, b); glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, c); Chap 5, Global illumination (CG-U) 17

Light sources in OpenGL -4 Spotlight Specify spotlight direction, exponent, and the angle glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light0_dir); glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, e); glLightf(GL_LIGHT0, GL_SPOT_SUTOFF, a); OpenGL assumes that the viewer is infinitely far from the scene, so the direction to the viewer is unchanged. The mode can be changed by glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); Chap 5, Global illumination (CG-U) 18

Light sources in OpenGL -5 Spotlight Specify spotlight direction, exponent, and the angle glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light0_dir); glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, e); glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, a); OpenGL assumes that the viewer is infinitely far from the scene, so the direction to the viewer is unchanged. The mode can be changed by glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); Chap 5, Global illumination (CG-U) 19

Material specification in OpenGL -1 Match up the supported light sources and with the Phong reflection model. We can specify different material properties for the front and back faces. OpenGL functions glMaterialfv(face, type, pointer_to_array); glMaterialf(face, type, value) One for vector, another for scalar parameters. face: GL_FRONT_AND_BACK, GL_FRONT, GL_BACK type: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_SHININESS (exponent, use glMaterialf()) Chap 5, Global illumination (CG-U) 20

Material specification in OpenGL -2 The material values remain the same until changed, and when changed, affect only surfaces defined after the change. The emission component of a surface can be defined by glMaterialfv(face, GL_EMISSION, pointer_to_array); Useful if we want a light source to appear in the image. This term is not affected by any of the light sources, and it does not affect any other surfaces. Chap 5, Global illumination (CG-U) 21

Global rendering Phong illumination model Global illumination Diffuse and specular term: light comes directly from the light. Ambient term: A constant estimating the global illumination from indirectly reflected and refracted light. Global illumination Effect of indirectly reflected and refracted lighting. Chap 5, Global illumination (CG-U) 22

Ray tracing -1 HSR ray tracing (one pass) Recursive ray tracing Computes the visible point for each pixel and then determine the local illumination. Recursive ray tracing Incorporate the following in a single framework HSR Global specular interaction by simulating indirect reflection and refraction of light Hard-shadow calculation Chap 5, Global illumination (CG-U) 23

Ray tracing -2 Ray: formed as a ray from eye to a pixel. HSR: first hit of the eye ray. Indirect lighting: recursive ray tracing At each ray-object intersection, a reflected and a refracted ray are fired to trace the light ray propagation. Chap 5, Global illumination (CG-U) 24

Ray tracing – Main program Select a COP and window on the view plane for each scan line in the window do for each pixel p in the scan line do begin TraceRay(COP, p-COP, 1, pixel_color) end Chap 5, Global illumination (CG-U) 25

Ray tracing – TraceRay() TraceRay(start, direction, depth, var color: colors) begin if depth > max_depth then color:=black else begin Intersect ray with all objects and find intersection point p that is closest to start; if no intersection then color:=background_color; local_color:=…. Compute reflection direction r TraceRay(p, r, depth+1, reflected_color); Chap 5, Global illumination (CG-U) 26

Ray tracing – TraceRay() Compute refraction direction t TraceRay(p, t, depth+1, refracted_color); Combine(color, local_color, k_local, reflected_color, k_reflection, refracted_color, k_refraction); end Chap 5, Global illumination (CG-U) 27

Intensity calculation Pixel RGB is determined by the intensity at the first ray-object intersection, which is determined by At each ray-object intersection, the RGB at that point is obtained similarly. Chap 5, Global illumination (CG-U) 28

Shadow using ray tracing Fire a shadow ray at a visible ray-object intersection. If the shadow ray is interrupted, the point is under shadow Shadow effect: Assume the objects are wholly opaque. Reduce the local term to the ambient value. Produces sharp shadow boundary. Chap 5, Global illumination (CG-U) 29

Shadow using light buffer -1 Light buffer: A cube of six faces with the point light source as center, and whose faces are partitioned to cells. Set-up: All polygons are projected to each face using the light position as the COP. Each cell contains a list of polygons that can be seen from the light source through the cell. The polygon are sorted in ascending order of the depth. Chap 5, Global illumination (CG-U) 30

Shadow using light buffer -2 Shadow testing: Find the cell that the shadow ray passes. Check to see if there is a polygon on the cell’s sorted list that is in front the point. Chap 5, Global illumination (CG-U) 31

Speed-Up Methods Adaptive depth control Bounding volume and BV hierarchy First-hit speed up Spatial coherence Uniform partition Octree Binary Space Partition Ray space subdivision Ray Coherence Chap 5, Global illumination (CG-U) 32

Radiosity -1 Ray tracing Radiosity Deals with scenes of perfect specular and transmission patches, and approximates diffuse interaction by ambient term. Scene geometry can be any. Point light source only. Radiosity Deals with perfect diffuse interior scenes. Scene geometry is polygonal patches. A single patch reflects light received from every other patches and also emit light if it is a light source. Chap 5, Global illumination (CG-U) 33

Radiosity -2 Radiosity (cont.) The diffuse interaction between patches depends on their geometry (distance and orientation). Conservation of light energy leads to an equilibrium in which light intensity is assume to be constant across a patch. A light source is treated like any other surfaces except it possesses an initial (non-zero) radiosity. Shadows are dealt with without add-on procedure, intensity within a shadow can be more effectively handled. Radiosity calculation is view-independent. Chap 5, Global illumination (CG-U) 34

Radiosity -3 Chap 5, Global illumination (CG-U) 35

Formulating Radiosity Equations The energy per unit area leaving a surface patch per unit time and is the sum of emitted and the reflected energy Fji: the form factor specifying the fraction of energy leaving entire patch j that directly arrives at entire patch i. Chap 5, Global illumination (CG-U) 36

Formulating Radiosity Equations Reciprocity relation For a pair of equally sized emitter and receiver, the fraction of energy emitted by one and received by the other is identical to the refraction of energy going the other way. With reciprocity relation Chap 5, Global illumination (CG-U) 37

Formulating Radiosity Equations Ei: input illumination to the system Fij: form factor, F00=0 for plane patch : reflectivity Ei and are wavelength dependent; e.g., (R,G,B) Solution: Bi – a single radiosity value for each patch Chap 5, Global illumination (CG-U) 38

Vertex Intensity Interior vertex e Boundary vertex b averaging the radiosities of patches that share e. Boundary vertex b Find the nearest interior vertex e Apply “vertex’s average = patch’s average” Chap 5, Global illumination (CG-U) 39

Rendering Using Radiosity Chap 5, Global illumination (CG-U) 40

Solution – Gauss-Seidel Method Can be solved by any linear solvers Direct methods: Gaussian Elimination, Decomposition Indirect Methods: Jocobi methd, Gauss-Seidel method Large size, better handled by iteration methods. Gauss-Seidel iterative method Converges for any strictly diagonally dominant systems from any initial solution. Iteration, initials, termination conditions. Chap 5, Global illumination (CG-U) 41

Solution – Gauss-Seidel Method The coefficient matrix is strictly diagonally dominant. The sum of form factors from any patch to other patches must be 1, and the reflectivity is less than 1. Sum of the elements other than the diagonal on any row is less than 1 on the diagonal, if Fii=0 for i=1,2,…,n (holds for planar or convex patches). Gauss-Seidel iteration is a gathering process Chap 5, Global illumination (CG-U) 42

Solution Cost Accuracy Form factor Linear system Space O(n2) O(n2) x O(form-factor) Linear system O(n3) Space O(n2) Accuracy Accuracy of form factor computation (e.g., Hemicube resolution) Meshing resolution Chap 5, Global illumination (CG-U) 43