450 likes | 576 Views
CS 551/651: Advanced Computer Graphics. Advanced Ray Tracing Radiosity. Administrivia. My penance: Ray tracing homeworks very slow to grade Many people didn’t include READMEs Many (most) people didn’t include workspace/project files or Makefiles Some people’s don’t work
E N D
CS 551/651: Advanced Computer Graphics Advanced Ray Tracing Radiosity David Luebke 111/17/2014
Administrivia • My penance: Ray tracing homeworks very slow to grade • Many people didn’t include READMEs • Many (most) people didn’t include workspace/project files or Makefiles • Some people’s don’t work • Nobody’s works perfectly • Quiz 1: Tuesday, Feb 20 David Luebke 211/17/2014
Recap: Stochastic Sampling • Sampling theory tells us that with a regular sampling grid, frequencies higher than the Nyquist limit will alias • Q: What about irregular sampling? • A: High frequencies appear as noise, not aliases • This turns out to bother our visual system less! David Luebke 311/17/2014
Recap: Stochastic Sampling • Poisson distribution: • Completely random • Add points at random until area is full. • Uniform distribution: some neighboring samples close together, some distant David Luebke 411/17/2014
Recap: Stochastic Sampling • Poisson disc distribution: • Poisson distribution, with minimum-distance constraint between samples • Add points at random, removing again if they are too close to any previous points • Jittered distribution • Start with regular grid of samples • Perturb each sample slightly in a random direction • More “clumpy” or granular in appearance David Luebke 511/17/2014
Recap: Stochastic Sampling • Spectral characteristics of these distributions: • Poisson: completely uniform (white noise). High and low frequencies equally present • Poisson disc: Pulse at origin (DC component of image), surrounded by empty ring (no low frequencies), surrounded by white noise • Jitter: Approximates Poisson disc spectrum, but with a smaller empty disc. David Luebke 611/17/2014
Recap: Nonuniform Supersampling • To be correct, need to modify filtering step: David Luebke 711/17/2014
Recap: Nonuniform Supersampling • Approximate answer: weighted average filter • Correct answer: multistage filtering • Real-world answer: ignore the problem I(i, j) h(x-i, y-j) I’(x,y)= h(x-i, y-j) David Luebke 811/17/2014
Recap: Antialiasing and Texture Mapping • Texture mapping is uniquely harder • Potential for infinite frequencies • Texture mapping is uniquely easier • Textures can be prefiltered David Luebke 911/17/2014
Recap: Antialiasing and Texture Mapping • Issue in prefiltering texture is how much texture a pixel filter covers • Simplest prefiltering scheme: MIP-mapping • Idea: approximate filter size, ignore filter shape • Create a pyramid of texture maps • Each level doubles filter size David Luebke 1011/17/2014
Recap: Mip-Mapping • Tri-linear mip-mapping • Pixel size depth d • Linearly interpolate colors within 2 levels closest to d • Linearly interpolate color between levels according to d David Luebke 1111/17/2014
Distributed Ray Tracing • Distributed ray tracing is an elegant technique that tackles many problems at once • Stochastic ray tracing: distribute rays stochastically across pixel • Distributed ray tracing: distribute rays stochastically across everything David Luebke 1211/17/2014
Distributed Ray Tracing • Distribute rays stochastically across: • Pixel for antialiasing • Light sourcefor soft shadows • Reflection function for soft (glossy) reflections • Time for motion blur • Lens for depth of field • Cook: 16 rays suffice for all of these • I done told you wrong: 4x4, not 8x8 David Luebke 1311/17/2014
Distributed Ray Tracing • Distributed ray tracing is basically a Monte Carlo estimation technique • Practical details: • Use lookup tables (LUTs) for distributing rays across functions • See W&W Figure 10.14 p 263 David Luebke 1411/17/2014
Backwards Ray Tracing • Traditional ray tracing traces rays from the eye, through the pixel, off of objects, to the light source • Backwards ray tracing traces rays from the light source, into the scene, into the eye • Why might this be better? David Luebke 1511/17/2014
Backwards Ray Tracing • Backwards ray tracing can capture: • Indirect illumination • Color bleeding • Caustics • Remember what a caustic is? • Give some examples • Remember where caustics get the name? David Luebke 1611/17/2014
Backwards Ray Tracing • Usually implies two passes: • Rays are cast from light into scene • Rays are cast from the eye into scene, picking up illumination showered on the scene from the first pass David Luebke 1711/17/2014
Backwards Ray Tracing • Q: How might these two passes “meet in the middle?” David Luebke 1811/17/2014
Backwards Ray Tracing • Arvo: illumination mapstile surfaces with regular grids, like texture maps • Shoot rays outward from lights • Every ray hit deposits some of its energy into surface’s illumination map • Ignore first generation hits that directly illuminate surface (Why?) • Eye rays look up indirect illumination using bilinear interpolation David Luebke 1911/17/2014
Backwards Ray Tracing • Watt & Watt, Plate 34 • Illustrates Arvo’s method of backwards ray tracing using illumination maps • Illustrates a scene with caustics • Related idea: photon maps David Luebke 2011/17/2014
Advanced Ray Tracing Wrapup • Backwards ray tracing accounts for indirect illumination by considering more general paths from light to eye • Distributed ray tracing uses a Monte Carlo sampling approach to solve many ray-tracing aliasing problems David Luebke 2111/17/2014
Next Up: Radiosity • Ray tracing: • Models specular reflection easily • Diffuse lighting is more difficult • Radiosity methods explicitly model light as an energy-transfer problem • Models diffuse interreflection easily • Shiny, specular surfaces more difficult David Luebke 2211/17/2014
Radiosity Introduction • First lighting model: Phong • Still used in interactive graphics • Major shortcoming: local illumination! • After Phong, two major approaches: • Ray tracing • Radiosity David Luebke 2311/17/2014
Radiosity Introduction • Ray tracing: ad hoc approach to simulating optics • Deals well with specular reflection • Trouble with diffuse illumination • Radiosity: theoretically rigorous simulation of light transfer • Very realistic images • But makes simplifying assumption: only diffuse interaction! David Luebke 2411/17/2014
Radiosity Introduction • Ray-tracing: • Computes a view-dependent solution • End result: a picture • Radiosity: • Models only diffuse interaction, so can compute a view-independent solution • End result: a 3-D model David Luebke 2511/17/2014
Radiosity • Basic idea: represent surfaces in environment as many discrete patches • A patch, or element, is a polygon over which light intensity is constant David Luebke 2611/17/2014
Radiosity • Model light transfer between patches as a system of linear equations • Solving this system gives the intensity at each patch • Solve for R, G, B intensities and get color at each patch • Render patches as colored polygons in OpenGL. Voila! David Luebke 2711/17/2014
Fundamentals • Theoretical foundation: heat transfer • Need system of equations that describes surface interreflections • Simplifying assumptions: • Environment is closed • All surfaces are Lambertian reflectors David Luebke 2811/17/2014
Radiosity • The radiosity of a surface is the rate at which energy leaves the surface • Radiosity = rate at which the surface emits energy + rate at which the surface reflects energy • Notice: previous methods distinguish light sources from surfaces • In radiosity all surfaces can emit light • Thus: all emitters inherently have area David Luebke 2911/17/2014
Radiosity • Break environment up into a finite number n of discrete patches • Patches are opaque Lambertian surfaces of finite size • Patches emit and reflect light uniformly over their entire surface • Q: What’s wrong with this model? • Q: What can we do about it? David Luebke 3011/17/2014
Radiosity • Then for each surface i: Bi = Ei + i Bj Fji(Aj / Ai) where Bi, Bj= radiosity of patch i, j Ai, Aj= area of patch i, j Ei= energy/area/time emitted by i i = reflectivity of patch i Fji = Form factor from j to i David Luebke 3111/17/2014
Form Factors • Form factor: fraction of energy leaving the entirety of patch i that arrives at patch j, accounting for: • The shape of both patches • The relative orientation of both patches • Occlusion by other patches David Luebke 3211/17/2014
Form Factors • Some examples… Form factor: nearly 100% David Luebke 3311/17/2014
Form Factors • Some examples… Form factor: roughly 50% David Luebke 3411/17/2014
Form Factors • Some examples… Form factor: roughly 10% David Luebke 3511/17/2014
Form Factors • Some examples… Form factor: roughly 5% David Luebke 3611/17/2014
Form Factors • Some examples… Form factor: roughly 30% David Luebke 3711/17/2014
Form Factors • Some examples… Form factor: roughly 2% David Luebke 3811/17/2014
Form Factors • In diffuse environments, form factors obey a simple reciprocity relationship: Ai Fij = Ai Fji • Which simplifies our equation:Bi = Ei + i Bj Fij • Rearranging to:Bi - i Bj Fij = Ei David Luebke 3911/17/2014
Form Factors • So…light exchange between all patches becomes a matrix: • What do the various terms mean? David Luebke 4011/17/2014
Form Factors 1 - 1F11 - 1F12 … - 1F1n B1E1 - 2F21 1 - 2F22 … - 2F2n B2E2 . . … . . . . . … . . . . . … . . . - pnFn1- nFn2 … 1 - nFnn Bn En • Note: Ei values zero except at emitters • Note: Fii is zero for convex or planar patches • Note: sum of form factors in any row = 1 (Why?) • Note: n equations, n unknowns! David Luebke 4111/17/2014
Radiosity • Now “just” need to solve the matrix! • W&W: matrix is “diagonally dominant” • Thus Guass-Siedel must converge • End result: radiosities for all patches • Solve RGB radiosities separately, color each patch, and render! • Caveat: actually, color vertices, not patches (see F&vD p 795) David Luebke 4211/17/2014
Radiosity • Q: How many form factors must be computed? • A: O(n2) • Q: What primarily limits the accuracy of the solution? • A: The number of patches David Luebke 4311/17/2014
Radiosity • Where we go from here: • Evaluating form factors • Progressive radiosity: viewing an approximate solution early • Hierarchical radiosity: increasing patch resolution on an as-needed basis David Luebke 4411/17/2014
The End David Luebke 4511/17/2014