k. h. ko school of mechatronics gwangju institute of science and technology

56
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Hybrid Algorithms K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

Upload: ruby

Post on 12-Jan-2016

23 views

Category:

Documents


0 download

DESCRIPTION

Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Hybrid Algorithms. K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology. Hybrid Algorithms. There are two of the most popular global illumination algorithms: ray tracing and radiosity. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

Photo-realistic Rendering and Global Illumination in Computer Graphics

Spring 2012

Hybrid Algorithms

K. H. Ko

School of MechatronicsGwangju Institute of Science and Technology

Page 2: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

2

Hybrid Algorithms There are two of the most popular global

illumination algorithms: ray tracing and radiosity. A ray-tracing algorithm computes radiance

values for every pixel in the final image by generating paths between the pixel and the light sources.

A radiosity algorithm computes a radiance value for every mesh element in the scene, after which this solution is displayed using any method that can project polygons to the screen.

There are algorithms which try to combine the best of both worlds.

Page 3: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

3

Final Gathering Once a radiosity solution is computed and an

image of the scene is generated, Gouraud shading is often used to interpolate between radiance values at vertices of the mesh, thus obtaining a smoothly shaded image. This technique can miss significant shading features. It is often difficult to generate accurate shadows.

Shadows may creep under surfaces. Mach band effects may occur. Other secondary illumination effects containing

features with a frequency higher than that which the mesh can represent are also possible.

One way of solving this is to consider the radiosity solution to be a coarse precomputed solution of the light distribution in the scene.

Page 4: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

4

Final Gathering During a second phase, when the

image is actually generated, a more accurate per-pixel illumination value is computed, which is based on the ray-tracing algorithm.

The ray-tracing set-up for computing the radiance for a pixel is given by

Page 5: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

5

Final Gathering L(p->eye) equals L(x->Θ) with x being the

visible point in the scene and Θ the direction from x towards the eye.

Suppose we have a precomputed radiance solution in a diffuse scene, given by L(y) for every surface point y. We can then acquire the value of L(x->Θ) by writing

the rendering equation, approximating the radiance distribution in the kernel of the transport equation by L(y).

Page 6: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

6

Final Gathering This integral can now be evaluated using

Monte Carlo integration. The main difference with the stochastic

ray-tracing algorithm is that there is no recursive evaluation of the radiance distribution, since it is substituted by the precomputed radiosity solution.

Thus one gains the advantage of using an accurate per-pixel method, using a fast precomputed finite element method.

Page 7: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

7

Final Gathering Various sampling strategies can be

used to evaluate either of the two integrals.

In a diffuse scene, with a constant radiance value Lj for each surface element j, the equation can also be rewritten as

Page 8: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

8

Final Gathering Sampling Strategy

Simple Hemisphere Sampling The most straightforward approach is to sample

random directions over the hemisphere and evaluate L at the nearest intersection point.

It is very similar to simple stochastic ray tracing and will result in a lot of noise in the final image.

Light sources will be missed by just randomly sampling the hemisphere.

Splitting the integral into a direct and indirect term is a good approach for increasing the accuracy.

Page 9: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

9

Final Gathering Sampling Strategy

Importance Sampling This approach can be used to evaluate

Construct a probability density function that matches the kernel of the integral as closely as possible.

Since we have a precomputed solution, it can be used to sample surface elements and directions to bright areas in the scene.

Page 10: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

10

Final Gathering Sampling Strategy

Importance Sampling Depending on the radiosity algorithm used, the

following data may be available to construct a PDF: Average radiance value for each surface element j.

The form factors Fi->j between surface elements i and j. This is only the case in classic radiosity, in which links between surface elements are stored explicitly.

kA

y

~

jj

~dA)y(L

AL

1

Page 11: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

11

Final Gathering Importance Sampling

An importance sampling procedure can be constructed by first selecting a surface element, and then sampling a surface point within that surface element.

1. The probability of picking surface element j should be proportional to

with surface element i containing point x.

Page 12: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

12

Final Gathering Importance Sampling

An importance sampling procedure can be constructed by first selecting a surface element, and then sampling a surface point within that surface element.

1. Thus, each surface element j is assigned a probability

Page 13: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

13

Final Gathering Importance Sampling

2. The second step then involves the evaluation of

For the surface element j selected in Step 1.

Page 14: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

14

Final Gathering Importance Sampling

Several methods for evaluating this integral are possible.

Choosing a sample point y with uniform probability 1/Aj on surface element j. The total estimator is then given by

Page 15: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

15

Final Gathering Importance Sampling

Several methods for evaluating this integral are possible.

An algorithm is available to sample a random direction with uniform probability 1/Ωj on a spherical triangle Ωj. This sampling procedure can be used to sample a surface point y by first selecting a direction Θx ∈ Ωj ; y is the point on surface element j along Θx. The total estimator is then

Page 16: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

16

Final Gathering Importance Sampling

Several methods for evaluating this integral are possible.

The cosine factor cos(Nx,Θx) can be taken into account as well by using rejection sampling. A direction is sampled on a bounding region on the

hemisphere. The bounding region needs to be chosen such that

sampling according to a cosine distribution is possible.

If the sampled direction falls outside Ωj, the estimator evaluates to 0.

Alternatively, one can also generate samples until a nonrejected sample is generated.

Page 17: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

17

Final Gathering Importance Sampling

Several methods for evaluating this integral are possible.

When surface element j is fully visible from point x, the point-to-surface form factor can be computed analytically, and thus no Monte Carlo sampling is needed.

Page 18: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

18

Final Gathering Results

Left: the precomputed radiosity solution. Meshing artifacts in the shading and

shadows are clearly visible. Right: the solution using final

gathering. All illumination features are much more

smooth.

Page 19: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

19

Final Gathering Final gathering techniques can also be

extended for scenes with nondiffuse surfaces.

In this case, the nondiffuse BRDF should be included in the integral evaluation.

Page 20: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

20

Multipass Methods A multipass method uses various

algorithms (finite-element-based, image-based) and combines them into a single image-generation algorithm.

Care has to be taken that light transport components are not counted twice since this would introduce errors in the image.

At the same time, all possible light transport modes need to be covered by at least one pass.

A good multipass algorithm tries to exploit the various advantages of the different individual passes.

Page 21: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

21

Multipass Methods Regular Expressions

Regular expressions are often used to express which light transport modes are covered by which pass.

Notations L: One of the light sources in the scene. D: A diffuse reflection component of the BRDF. G: A semidiffuse or glossy reflection component of the

BRDF. S: A perfect specular component of the BRDF. E: The eye or virtual camera.

LD+E. A light transport path between a light source and the

camera, only reflecting at diffuse surfaces D+ indicates the path bounces off of at least one diffuse

surface.

Page 22: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

22

Multipass Methods Regular

Expressions LDSE

A diffuse surface, reflected in a visible specular material, would be described by the path of type LDSE.

L(D|G|S)*E All possible paths

in the scene. * indicates zero or

more reflections.

Page 23: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

23

Multipass Methods Algorithms can now be characterized by

describing what light transport paths they cover.

Radiosity algorithms cover all paths of type LD*E, or all diffuse bounces.

A classic ray-tracing algorithm, stopping the recursion of reflected rays at nonspecular surfaces, covers all paths of type LD0…1(G|S)E, with D0…1 indicating 0 to 1 reflections at a diffuse surface.

Page 24: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

24

Multipass Methods Construction of a Multipass Algorithm

A multipass algorithm usually starts with one or more object-space methods, which store a partial approximation of the light transport in the scene.

A radiosity method might only store the diffuse light interactions and might ignore all other types of light transport.

The image-space algorithms compute radiance values per pixel, but they rely on the partially computed and stored light transport approximations of the previous passes.

To access these stored solutions, they need a read-out strategy.

Page 25: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

25

Multipass Methods Construction of a Multipass Algorithm

This read-out strategy might itself include some computations or interpolations.

It is determined by the nature of the stored partial solution.

It also determines the nature of the paths that are covered by the image-space pass.

Page 26: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

26

Multipass Methods Construction of a Multipass Algorithm

Some typical read-out strategies include: Direct visualization of the stored solution

For each pixel, the stored light transport solution is accessed directly and the resulting value attributed to the pixel.

Radiosity solutions are often displayed this way. The covered light transport paths are exactly the

same as those covered by the object-space pass.

Page 27: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

27

Multipass Methods Construction of a Multipass Algorithm

Some typical read-out strategies include: Final gathering

The final gathering method reconstructs the incoming radiance values over the hemisphere for each point visible through the pixel.

These radiance values are read from the stored radiance solution.

Suppose the stored radiance solution only covers paths of type LD*. Because the final gathering takes into account

the full BRDF at the visible point through the pixel, the paths covered by this multipass algorithm are of type LD*(D|G|S)E, and LE when the light sources are directly visible.

Page 28: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

28

Multipass Methods Construction of a Multipass Algorithm

Some typical read-out strategies include: Recursive stochastic ray tracing

A recursive ray-tracing algorithm is used as a read-out strategy, but paths are only reflected at those surfaces; use only those reflection components that are not covered by the object-space pass.

Ex: If the first pass stores a radiosity solution, covering all paths of type LD*, then the recursive ray-tracing pass would only reflect rays at G or S surfaces. At each D surface, the stored value in the

precomputed solution is read out and incorporated in the estimator at that reflection point.

Thus, the covered paths are of type LD*(G|S)*E.

Page 29: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

29

Multipass Methods Most multipass strategies make sure

that the light transport paths covered in the different passes do not overlap.

Otherwise, some light transport might be counted twice and the resulting image will look too bright in some parts of the scene.

Every pass of the multipass algorithm covers distinct, separate types of light transport.

Page 30: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

30

Multipass Methods Weighted Multipass Algorithms

An alternative approach is to have some overlap between the different passes, but weigh them appropriately.

The correct image is still obtained. The problem is now to find the right weighting heuristics such

that the strengths of each individual pass are used in the optimal way.

A very good strategy assigns weights to the different types of paths in each pass based on the respective probability density functions for generating these paths.

Thus, caustic effects might predominantly use their results from a bidirectional ray-tracing pass, while direct illumination effects might originate mostly from a ray-tracing or radiosity pass.

Page 31: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

31

Multipass Methods A total of three

passes are used. First, a radiosity

solution is computed, which is subsequently enhanced by a stochastic ray tracer.

This specific example covers only paths of type LD(G|S)(D|G|S)*E.

Page 32: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

32

Multipass Methods A total of three

passes are used. A third pass

involves a bidirectional ray tracer, which generates paths of the same type but with different probabilities due to the nature of the sampling process.

Page 33: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

33

Multipass Methods The sum of the two weighted images

yields the final image.

Page 34: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

34

Multipass Methods When applying the weighting heuristic, one can

see that the caustic on the floor (due to refraction through the glass sphere) is mostly assigned to bidirectional path tracing, while the direct illumination is mostly assigned to the radiosity and stochastic ray-tracing solution.

Page 35: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

35

Multipass Methods Some difficult effects, which are not well

covered by either method, are weighted more equally, such as the reflection in the right wall of the white panel above the light source.

Page 36: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

36

Global Reflectance Distribution Function (GRDF) Given the transport equation of L->,it is

obvious that each single radiance value in the scene is dependent on the initial distribution given by L e

->. Such dependency is expressed by the

importance function W<-. A direct function, not a recursive one, is

introduced which expresses the relation between a single L(x->θ) value at an arbitrary chosen point, and the initial L e

-> distribution. This function is called global reflectance

distribution function or GRDF.

Page 37: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

37

Global Reflectance Distribution Function (GRDF) The GRDF is a four-dimensional transfer

function that describes the entire light transport in a three-dimensional scene between two pairs (x,θ) and (y,ψ).

It has the characteristics of both an incident and an exitant function, since the transfer can happen in both directions.

The GRDF is written as Gr(x<- θ,y->ψ).

Page 38: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

38

Global Reflectance Distribution Function (GRDF) The Gr(x<- θ,y->ψ) describes some sort of

global transport between two point-direction pairs and can be thought of as the contribution one pair makes, if it would act as a differential source of transport quantity, to the transport quantity measured at the other pair.

Namely, the GRDF is given by

Page 39: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

39

Global Reflectance Distribution Function (GRDF) Gr(x<- θ,y->ψ) expresses the influence of the

total power leaving dAx through a solid angle dωθ on the final value of the radiance measured at y in direction ψ , through any number of reflections on intermediate surfaces.

Therefore, it can be considered as some kind of response function in the three-dimensional environment.

In mathematical physics, a function like the GRDF is called the Green’s function of a problem.

Page 40: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

40

Global Reflectance Distribution Function (GRDF) Since the transport is reciprocal, a

similar equation for the importance is obtained:

Differentiating the given equations yields

Page 41: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

41

Global Reflectance Distribution Function (GRDF) The expression is very similar to the definition

of the common BRDF, which describes a similar property for exitant radiance and incident irradiance at a single surface point.

The GRDF extends this concept and describes the relationship between any two radiance or importance values, taking into account all possible reflections in the scene.

The BRDF can be considered as a special case of the GRDF.

Page 42: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

42

Global Reflectance Distribution Function (GRDF) The GRDF allows us to describe the global

illumination problem in a very short and elegant format, independent of any initial distributions for self-emitted radiance or importance.

The GRDF is only dependent on the geometry of the scene and the reflective properties of the surfaces.

No positioning of light sources is assumed, nor is it assumed that we know where we will place the sources of importance for which flux values need to be computed.

Page 43: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

43

Global Reflectance Distribution Function (GRDF) If the GRDF would be known, it is possible to

compute various fluxes for a number of light sources and importance distributions.

It suffices to evaluate

Which is a nonrecursive integral. In practice, this may be difficult to achieve, since the

GRDF has as arguments two positions and two directions.

Storing the GRDF is memory intensive.

Page 44: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

44

Bidirectional Tracing Ray tracing traces paths through the scene

starting at the surface points, which eventually end at the light sources.

Light tracing, another path-tracing algorithm, does the opposite: paths start at the light sources and end up in any relevant pixels.

Bidirectional ray tracing combines both approaches in a single algorithm and can be viewed as a two-pass algorithm in which both passes are tightly intertwined.

Bidirectional ray tracing generates paths starting at the light sources and at the surface point simultaneously and connects both paths in the middle to find a contribution to the light transport between the light source and the piont for which a radiance value needs to be computed.

Page 45: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

45

Bidirectional Tracing Bidirectional tracing combines the

specific advantages of ray tracing as well as light tracing.

Bidirectional path tracing is one of the few algorithms that start from the formulation of the global reflection distribution function (GRDF).

The flux Ф(S) is given by

Page 46: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

46

Bidirectional Tracing The core idea of the algorithm is that one has

the availability of two different path generators when computing a Monte Carlo estimate for the flux through a certain pixel:

An eye path is traced starting at a sampled surface point y0 visible through the pixel.

By generating a path of length k, the path consists of a series of surface points y0, y1, …, yk.

The length of the path is controlled by Russian roulette. The probability of generating this path can be composed

of the individual PDF values of generating each successive point along the path.

Similarly, a light path of length l is generated starting at the light source. This path, x0, x1, …, xl, also has its own probability density distribution.

Page 47: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

47

Bidirectional Tracing By connecting the endpoint yk of the eye

path with the endpoint xl of the light path, a total path of length k+l+1 between the importance source S and the light sources is obtained.

The probability density function for this path is the product of the individual PDFs of the light and eye paths.

An estimator for the Ф(S) using this single path is given by

Page 48: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

48

Bidirectional Tracing Paths of a certain length can now be

generated by using different combinations.

Example A path of length 3 could be generated by a

light path of length 2 and an eye path of length 0.

Or by a light path of length 1 and an eye path of length 1

Or by a light path of length 0 and an eye path of length 2.

Page 49: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

49

Bidirectional Tracing Stochastic ray tracing and light tracing

are special cases of bidirectional ray tracing.

When tracing a shadow ray in stochastic ray tracing, we actually generate a light path of length 0, which is connected to an eye path.

Page 50: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

50

Bidirectional Tracing

Page 51: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

51

Bidirectional Tracing Depending on the light transport

mode, and the sequence of G, V, and fr functions, some light distribution effects are better generated using either light paths or eye paths.

When rendering a specular reflection that is visible in the image, it is better to generate those specular bounces in the eye path.

The specular reflections in caustics are better generated in the light path.

Page 52: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

52

Bidirectional Tracing Generally, it is better to use the BRDF fr

to sample the next point or direction if fr has sharp peaks.

If fr is mainly diffuse, the energy transport along the connection between the two paths will not be influenced by the value of the BRDF and thus will not possibly yield a low contribution to the overall estimator.

Another advantage is that if light sources are concealed, it might be easier to generate light paths to distribute the light, rather than count on shadow rays to be able to reach the light source.

Page 53: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

53

Bidirectional Tracing When implementing bidirectional

path tracing, an eye or light path of length k-1 can be extended to a path of length k.

Use the same subpath more than once. Intuitively, this means that if we

have a light path and an eye path, we not only connect the endpoints, but also all possible subpaths to each other.

Page 54: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

54

Bidirectional Tracing

Page 55: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

55

Bidirectional Tracing

In the images, the total number of paths is the same, so each image took an equal time to compute.

Page 56: K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

56

Bidirectional Tracing The left image

shows a picture generated by bidirectional ray tracing, with a significant amount of caustics, which would have taken a long time to generate using stochastic ray tracing only.