Download presentation
1
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
2
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
3
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
4
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
5
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
6
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
7
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
8
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
9
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
10
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
11
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
12
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
13
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
14
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
15
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
16
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
17
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
18
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
19
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
20
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
21
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
22
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
23
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
24
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
25
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
26
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
27
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
28
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
29
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
30
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
31
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
32
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
33
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
34
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
35
Radiosity -3 Chap 5, Global illumination (CG-U) 35
36
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
37
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
38
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
39
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
40
Rendering Using Radiosity
Chap 5, Global illumination (CG-U) 40
41
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
42
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
43
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.