Download presentation
Presentation is loading. Please wait.
Published byAsher Rodgers Modified over 9 years ago
1
David Luebke 1 10/12/2015 CS 551/651: Advanced Computer Graphics Advanced Ray Tracing Radiosity
2
David Luebke 2 10/12/2015 Administrivia l Quiz 1: Tuesday, Feb 20 n Yes, I’ll have your homework graded by then (somehow) n Normal written exam (oral later)
3
David Luebke 3 10/12/2015 Recap: Distributed Ray Tracing l Distributed ray tracing: an elegant stochastic approach that distributes rays across: n Pixel for antialiasing n Light source for soft shadows n Reflection function for soft (glossy) reflections n Time for motion blur n Lens elements for depth of field l Cook: 16 rays suffice for all of these
4
David Luebke 4 10/12/2015 Recap: Backwards Ray Tracing l Two-pass algorithm: n Rays are cast from light into scene n Rays are cast from the eye into scene, picking up illumination showered on the scene in the first pass l Backwards ray tracing can capture: n Indirect illumination n Color bleeding n Caustics
5
David Luebke 5 10/12/2015 Recap: Backwards Ray Tracing l Arvo: illumination maps tile surfaces with regular grids, like texture maps n Shoot rays outward from lights n Every ray hit deposits some of its energy into surface’s illumination map u Ignore first generation hits that directly illuminate surface (Why?) n Eye rays look up indirect illumination using bilinear interpolation
6
David Luebke 6 10/12/2015 Recap: Radiosity l Ray tracing: n Models specular reflection easily n Diffuse lighting is more difficult n View-dependent, generates a picture l Radiosity methods explicitly model light as an energy-transfer problem n Models diffuse interreflection easily n But only diffuse; no shiny (specular) surfaces n View-independent, generates a 3-D model
7
David Luebke 7 10/12/2015 Recap: Radiosity l Basic idea: represent surfaces in environment as many discrete patches n A patch, or element, is a polygon over which light intensity is constant n Model light transfer between patches as a system of linear equations n Solve this system for the intensity at each patch n Solve for R,G,B intensities; get color at each patch n Render patches as colored polygons in OpenGL
8
David Luebke 8 10/12/2015 Recap: Fundamentals l Definition: n The radiosity of a surface is the rate at which energy leaves the surface u Radiosity = rate at which the surface emits energy + rate at which the surface reflects energy l Simplifying assumptions n Environment is closed n All surfaces have Lambertian reflectance n Surface patches emit and reflect light uniformly over their entire surface
9
David Luebke 9 10/12/2015 Radiosity l For each surface i: B i = E i + i B j F ji (A j / A i ) where B i, B j = radiosity of patch i, j A i, A j = area of patch i, j E i = energy/area/time emitted by i i = reflectivity of patch i F ji = Form factor from j to i
10
David Luebke 10 10/12/2015 Form Factors l Form factor: fraction of energy leaving the entirety of patch i that arrives at patch j, accounting for: n The shape of both patches n The relative orientation of both patches n Occlusion by other patches l We’ll return later to the calculation of form factors
11
David Luebke 11 10/12/2015 Form Factors l Some examples… Form factor: nearly 100%
12
David Luebke 12 10/12/2015 Form Factors l Some examples… Form factor: roughly 50%
13
David Luebke 13 10/12/2015 Form Factors l Some examples… Form factor: roughly 10%
14
David Luebke 14 10/12/2015 Form Factors l Some examples… Form factor: roughly 5%
15
David Luebke 15 10/12/2015 Form Factors l Some examples… Form factor: roughly 30%
16
David Luebke 16 10/12/2015 Form Factors l Some examples… Form factor: roughly 2%
17
David Luebke 17 10/12/2015 Form Factors l In diffuse environments, form factors obey a simple reciprocity relationship: A i F ij = A i F ji l Which simplifies our equation: B i = E i + i B j F ij l Rearranging to: B i - i B j F ij = E i
18
David Luebke 18 10/12/2015 Form Factors l So…light exchange between all patches becomes a matrix: l What do the various terms mean?
19
David Luebke 19 10/12/2015 Form Factors 1 - 1 F 11 - 1 F 12 … - 1 F 1n B 1 E 1 - 2 F 21 1 - 2 F 22 … - 2 F 2n B 2 E 2.. …... - p n F n1 - n F n2 … 1 - n F nn B n E n l Note: E i values zero except at emitters l Note: F ii is zero for convex or planar patches l Note: sum of form factors in any row = 1 (Why?) l Note: n equations, n unknowns!
20
David Luebke 20 10/12/2015 Radiosity l Now “just” need to solve the matrix! n W&W: matrix is “diagonally dominant” n Thus Guass-Siedel must converge (what’s that?) l End result: radiosities for all patches l Solve RGB radiosities separately, color each patch, and render! l Caveat: for rendering, we actually color vertices, not patches (see F&vD p 795)
21
David Luebke 21 10/12/2015 Radiosity l Q: How many form factors must be computed? l A: O(n 2 ) l Q: What primarily limits the accuracy of the solution? l A: The number of patches
22
David Luebke 22 10/12/2015 Roadmap l So, we know the basic radiosity algorithm n Represent light transfer as a matrix n Solve the matrix to get radiosity (=color) per patch l Next topics: n Evaluating form factors n Progressive radiosity: viewing an approximate solution early n Hierarchical radiosity: increasing patch resolution on an as-needed basis
23
David Luebke 23 10/12/2015 Form Factors l Calculating form factors is hard n Analytic form factor between two polygons in general case: open problem till last few years l Q: So how might we go about it? l Hint: Clearly form factors are related to visibility: how much of patch j can patch i “see”?
24
David Luebke 24 10/12/2015 Form Factors: Hemicube l Hemicube algorithm: Think Z-buffer n Render the model onto a hemicube as seen from the center of patch i n Store item IDs instead of color n Use Z-buffer to resolve visibility n See W&W p 278 l Q: Why hemicube, not hemisphere?
25
David Luebke 25 10/12/2015 Form Factors: Hemicubes l Advantages of hemicubes n Solves shape, size, orientation, and occlusion problems in one framework n Can use hardware Z-buffers to speed up form factor determination (How?)
26
David Luebke 26 10/12/2015 Form Factors: Hemicubes l Q: What are some disadvantages of hemicubes? n Aliasing! Low resolution buffer can’t capture actual polygon contributions very exactly u Causes “banding” near lights (plate 41) n Actual form factor is over area of patch; hemicube samples visibility at only center point on patch (So?)
27
David Luebke 27 10/12/2015 Form Factors: Ray Casting l Idea: shoot rays from center of patch in hemispherical pattern
28
David Luebke 28 10/12/2015 Form Factors: Ray Casting l Advantages: n Hemisphere better approximation than hemicube u More even sampling reduces aliasing n Don’t need to keep item buffer n Slightly simpler to calculate coverage
29
David Luebke 29 10/12/2015 Form Factors: Ray Casting l Disadvantages: n Regular sampling still invites aliasing n Visibility at patch center still isn’t quite the same as form factor n Ray tracing is generally slower than Z-buffer-like hemicube algorithms u Depends on scene, though u Q: What kind of scene might ray tracing actually be faster on?
30
David Luebke 30 10/12/2015 Form Factors l Source-to-vertex form factors n Calculating form factors at the patch vertices helps address some problems: for every patch vertex for every source patch sample source evenly with rays visibility = % rays that hit n Q: What are the problems with this approach?
31
David Luebke 31 10/12/2015 Form Factors l Summary of form factor computation n Analytical: u Expensive or impossible (in general case) n Hemicube u Fast, especially using graphics hardware u Not very accurate; aliasing problems n Ray casting u Conceptually cleaner than hemicube u Usually slower; aliasing still possible
32
David Luebke 32 10/12/2015 Substructuring l More patches better results l Problem: # form factors grows quadratically with # patches l Substructuring: adaptively subdivide patches into elements where high radiosity gradient is found
33
David Luebke 33 10/12/2015 Substructuring l Elements are second-class patches: n When a patch is subdivided, form factors are computed from the elements to other patches n But form factors from the other patches to the elements are not computed u However, the form factors from other patches to the subdivided patch are updated using more accurate area- weighted average of elements
34
David Luebke 34 10/12/2015 Substructuring l Elements vs. patches, cont. n Elements “gather” radiosity from other patches n But those other patches only gather radiosity from the “parent” patch, not the individual elements n So an element’s contribution to other patches is approximated coarsely by it’s patch’s radiosity
35
David Luebke 35 10/12/2015 Substructuring l Bottom line: n Substructuring allows subpatch radiosities to be computed without changing the size of the form- factor matrix n Show examples: u W&W plate 38, F&vD plate III.21 n Note: texts aren’t clear about adaptive subdivision vs substructuring
36
David Luebke 36 10/12/2015 Progressive Radiosity l Good news: iterative solver of radiosity matrix will converge l Bad news: can take a long time l Progressive radiosity: reorder computation to allow viewing of partial results
37
David Luebke 37 10/12/2015 Progressive Radiosity l Radiosity as described uses Gauss-Seidel iterative solver n Must do an entire iteration to get an estimate of patch radiosities n Must precompute and store all O(n 2 ) form factors
38
David Luebke 38 10/12/2015 Progressive Radiosity 1 - 1 F 11 - 1 F 12 … - 1 F 1n B 1 E 1 - 2 F 21 1 - 2 F 22 … - 2 F 2n B 2 E 2.. …... - p n F n1 - n F n2 … 1 - n F nn B n E n l Evaluating row i estimates radiosity of patch i based on all other patches l We say the patch gathers light from the environment
39
David Luebke 39 10/12/2015 Progressive Radiosity l Progressive radiosity shoots light from a patch into the environment: B j due to B i = j B j F ji j rather than B i due to B j = i B j F ij j l Given an estimate of B i, evaluating this equation estimates patch i’s contribution to the rest of the scene
40
David Luebke 40 10/12/2015 Progressive Radiosity l A problem: evaluating the equation B j due to B i = j B j F ji j requires knowing F ji for each patch j l Determining these values requires a hemicube computation per patch l Use reciprocity relationship to get B j due to B i = j B j F ij (A i /A j ) j
41
David Luebke 41 10/12/2015 Progressive Radiosity l Now evaluation requires only a single hemicube about patch i n Compute, use, and discard form factors n Drastically reduces total storage! l Reorder radiosity computation: n Pick patch w/ highest estimated radiosity u Shoot to all other patches u Update their estimates n Pick new “brightest” patch and repeat
42
David Luebke 42 10/12/2015 Progressive Radiosity l We can look at the scene after every iteration through this loop l Q: How will it look after 1 loop? l Q: 2 loops? l Q: If m = # of light sources, how will it look after m loops? After 2m loops?
43
David Luebke 43 10/12/2015 Progressive Radiosity l Subtleties: n Pick patch with most energy to shoot u Energy = radiosity * area = B j A i n A patch may be selected to shoot again after new light has been shot to it n So don’t shoot B j, shoot B j, the amount of radiosity patch i has received since it was last shot
44
David Luebke 44 10/12/2015 The End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.