• 沒有找到結果。

1 Introduction

1.3 Thesis Organization

The thesis is organized as follows. In chapter 2, we address some fundamental

background for understanding the implementation in chapter 3. First, we talk about the

measurement of light and rendering equation. Then, the Monte Carlo integration and a

few path sampling methods will be introduced. At last, we spend a little time on the

concept of vertex connection and merging. In chapter 3, we describe the detail

implementation of bidirectional path tracing with MIS and our path reuse way when

encountering the SDS situation. In chapter 4, some figures and tables are shown to make

comparisons among path tracing, bidirectional path tracing, vertex connection and

merging method and our method. Finally, we summarize what has been achieved in the

thesis and describe a few ideas of possible areas of future improvements.

Chapter 2

Background

2.1 Measurement of Light Transport

2.1.1 Irradiance and Radiance

The energy of light passes through the space is called flux, denoted Φ. Irradiance E is

the radiant flux received by a surface per unit area

( ) d E x dA

 . (2.1)

Radiance L is the radiant flux received by a surface, per unit projected area per unit solid

angle

By using angle θ between surface normal and reversed (or reflected) light direction, the

projected area can be derived asAAcos . Therefore, radiance L can be written as

2

Figure 1.1 shows the relation among these definitions.

Figure 1.1: Radiance and Irradiance.

2.1.2 Bidirectional Reflectance Distribution Function

We are able to distinguish between a plastic chair and a wooden chair even though they

are the same color is because that each material has its own reflection properties called

bidirectional reflection distribution function (BRDF) [DBK13]. The definition of BRDF

is the exitant radiance from direction ωe over the incident irradiance ωi at a point x

   

Physically based BRDFs has three conditions [DBK13]:

1. fr

x, i, e

0 (Positivity)

2. fr

x, i, e

fr

x, e, i

(Helmholtz’s reciprocity)

3. e, fr

x, i, e

cos id i 1

 (Conservation of energy)

The first condition is BRDFs must be greater than or at least equal to 0. The second

condition is no matter which the incident and exitant are of the two constant directions,

the amount of the reflected light is always the same. The third condition is the integration

result of all the reflected light at a point x cannot be greater than 1.

2.1.3 Rendering Equation

The rendering equation, which was introduced by Kajiya [Kaj86], is based on the

conservation of energy. The equation states that the exitant radiance is equal to the

emitted radiance and the integral of radiance from all incident directions

( , ) ( , ) ( , ) ( , , ) cos

o e e e i i r i e i i

L x L x L x f x d

   

    . (2.5)

2.2 Monte Carlo Integration

Suppose we have a real number domain x and codomain f(x) and we are going to

calculate the integration result of integrand f(x). Sometimes, due to reality considerations,

we do not use all the data to compute the result. We only randomly sample some of them

and expect to get the acceptable approximation. This is the basic idea of Monte Carlo

integration [GRS96] [Vea97] [KPR12].

To estimate the integration result, we are going to use the estimator f(x)/p(x), and the

possibility to be sampled which is called the probability density function (PDF) denoted

by p(xi). Figure 1.2 shows the relationship among xi, f(xi), and p(xi).

Figure 1.2: f(x) and probability density function.

We say an estimator is unbiased when the expected value of it equals to the value of the

integration result being estimated which means on average it produces the correct result

 

E I  

f x dx. (2.7)

2.2.1 Importance Sampling

In general, the bigger the number of samples, the better the result is. However, the

purpose of using MC integration is to reduce the cost. Importance sampling [Vil14] is a

sampling technique which makes the approximation converge quicker by choosing PDF

p(x) similar to the integrand f(x) [Vea98]. It is known that the best choice is p(x)=cf(x).

The constant c can be written as

 

c 1

f x dx

. (2.8)

Then the value of estimator will become

   

1

 

f x f x dx

p x  c

, (2.9)

which is exactly the value we are trying to estimate. Unfortunately, to do so, we must

know the value of the integral in advance, but it is not possible in reality. Typically, we

use an approximated function g(x) which is obtained by f(x).

2.2.2 Multiple Importance Sampling

Though importance sampling is a good way to choose an estimator, it is hard to find a

PDF that fit a complex multimodal integrand f(x), like Figure 1.3.

Figure 1.3: A multimodal function.

There are two peaks in function f(x). Two PDFs pa(x) and pb(x) mimic each of the peaks.

It is obvious that choosing only one of the PDFs would cause an extremely high variance.

Veach and Guibas introduced a way called multiple importance sampling (MIS) [VG95].

It combines different PDFs to obtain a new estimator to do MS integration

   

,

where m is the number of sampling techniques, ni is a number of samples of a technique,

and wi is a weighting function. In order to get the correct result, the weighting function

must follow two conditions [Vea98]:

1.

2.3 Path Sampling Methods

2.3.1 Photon Mapping

Photon mapping is a two-pass method which estimates the global illumination by

collecting little quanta of energy called photon [Jen01] [JC07]. In the first pass, photons

are emitted from the light source and transported through the scene. When the photon

hits a surface, mostly diffuse surfaces, the information of energy is stored in a data

structure called the photon map.

In the second pass, the eye ray is casted from the view point into the scene. We estimate

the exitant radiance at any surface location x according to the formula

2

where r is the radius of the disk which contains N photons, as shown in Figure 2.1. What

needs to be noticed is that photon mapping is a biased approach because of this formula

do the interpolation. The image rendered by photon mapping is often blurry. Hachisuka,

T., et al. and Vorba, J. [HOJ08] [Vor11] have made some research on this topic.

2.3.2 Path Tracing

The path integral formulation [VG95] [Vea98] [KGKC14] evaluates the value of a pixel

in an image as an integral over all light transport paths of all lengths in the scene.

   

j j

I

f x dx . (2.12)

In the equation, j denotes a pixel, x means a full path from the light source x0 to the

eye xk, and f(x) is the measurement contribution function for a pixel.

The definition of the measurement contribution function is defined as the emitted

radiance Le at the first vertex, times the sensitivity or called the emitted importance W e

at the last vertex, times the path throughput T

 

e

0 1

   

e k 1 k

f xL xx T x W xx . (2.13)

After expanding T, the equation becomes

Figure 2.2: Measurement contribution function.

2.3.3 Bidirectional Path Tracing

It is easy to implement the path tracing, but if a ray passes through the scene and does

not hit any light source, the pixel would still be black. In bidirectional path tracing, we

divide the entire path into eye sub-paths and light sub-paths. Besides this, other

calculations remain the same. Once the connection between eye paths and light

sub-paths succeeds, it guarantees the pixel will get the illumination from the light source,

which helps to improve the efficiency of the process. Choosing different connection

points will get various results, as shown in Figure 2.4, so how to pick a good connection

point is crucial.

Figure 2.3: Different kinds of path tracing. (a)(b) Light tracing. (c) Virtual point light.

(d) Bidirectional Path Tracing. (e)(f) Path tracing.

2.4 Vertex Connection and Merging

The vertex connection and merging method was introduced by Iliyan Georgiev, et al.

[GKDS12], aiming to deal with the SDS problem. It is approached by combining vertex connection from bidirectional path tracing with vertex merging from photon mapping

by MIS.

The vertex connection part in this algorithm is the same as it was in bidirectional path

tracing. The PDF of the connected path with s light and t eye vertices as

     

, ,

vc s t s t

p xp y p z , (2.15)

where y and z are light and eye sub-path PDFs.

Vertex merging path sampling technique determines whether light and eye sub-path

vertices should be merged by checking if eye path vertex is within the acceptance radius.

The PDF of the path uses vertex merging is

     

sub-path, which is the connection point, and x*s is the photon (light vertex) from the light

sub-path, as shown in Figure 2.5. By MIS, the multi-sample estimator would look like

   

Figure 2.4: Vertex connection and merging.

xs-1

xs

xs*

Chapter 3

Implementation

3.1 SmallVCM

SmallVCM is a small physically based renderer that implements the vertex connection

and merging algorithm from the paper, Light Transport Simulation with Vertex

Connection and Merging [GKDS12]. Though SmallVCM is a light renderer, we chose

it as a tool because it had already implemented the basic part of bidirectional path tracing,

so we could just focus on modifying the algorithm. Except bidirectional path tracing and

vertex connection and merging method from the paper, SmallVCM also contains some

common path sampling methods, such as path tracing and photon mapping, which lets

us easily verify our result with the others. SmallVCM uses a data structure called

bounding box to accelerate the ray intersection test. OpenMP is the abbreviation of Open

Multi-Processing is an API used in the program to implement the parallel computing by

CPU.

3.2 Bidirectional Path Tracing Algorithm

3.2.1 Naïve Way

Without using the MIS, the naïve approach of bidirectional path tracing is sampling by

the BRDF, which means that it only samples according to the law of reflection and

refraction. Unfortunately, if the vertex connection position is at a specular surface, it is

very likely that the connection would fail. There would be no energy contributes from

the light source to the eye.

Figure 3.1: Naïve bidirectional path tracing.

3.2.2 Implementation in Practice

To avoid the situation of tracing over the scene for nothing, we use the MIS to sample

the BRDF and the light source at the same time. First, we generate the light sub-path

that walks through the scene, and then the eye sub-path starts from the eye. Each vertex

from the eye sub-path is connected to each vertex of the light sub-path.

Figure 3.2: MIS bidirectional path tracing.

3.2.3 Vertex Connection

In this session, we are going talk about the detail of vertex connection in bidirectional

path tracing. The rendering is divided into two stages. In the first stage, we trace the light

sub-path from light sources and store their vertices by performing a random walk. We

use the same number of the light sub-path as the number of pixels. The vertices are stored

only on the diffuse surface since only this kind of type can be connected. The specular

surface PDF for any arbitrary direction is zero, except for exactly the one of specular

reflection direction.

In the second stage, we trace the eye sub-path for each pixel. Upon sampling a vertex on

a light source, we accumulate the emitted radiance. If the sampled vertex is not on a light

source, it is connected to all vertices of a light sub-path.

Pseudocode for vertex connection

function VertexConnection() // Light path sampling for i = 0 to numPixel do

lightVertex = TraceRay(SampleLightPoint()) while lightVertex is valid do

if lightVertex is not specular then if lightVertex is not first then

lightPaths[i] += lightVertex end if

// Vertex connection: project light vertex to camera pixel lightVertexOnCamera = ConnectToCamera(lightVertex) while cameraVertex is valid do

// Vertex connection: random light hit, unidirectional sampling if cameraVertex is emissive then

Accum(cameraVertex, j) end if

// Vertex connection

for lightVertex in lightPaths[j] or SampleLightPoint() do Accum(Connect(cameraVertex, lightVertex), j)

pdf = Pdf(path)

weight = PowerHeuristic(path, pdf) image[i] += weight * contrib / pdf end function

3.3 The Specular-diffuse-specular Problem

Though bidirectional path tracing is much more powerful than other rendering methods,

it still struggles with some lighting effects, the most common of which are SDS paths

corresponding to reflected caustics. As shown in Figure 3.3, there are three surfaces, one

is diffuse and the rests are specular. Due to the law of reflection, only the black path can

receive the illumination form the light source. Once we sample other directions, the light

sub-path and eye sub-path would not be able to connect each other.

Figure 3.3: SDS situation.

3.4 A Path Reuse Method

We have known to exert the full strength of vertex connection. The saved vertices in

light sub-paths and eye sub-paths is better mostly on the diffuse surface in order to higher

the opportunity of successful vertex connection.

When the eye sub-path exceeds the maximum length and it cannot connect to the light

sub-path to obtain the energy, rather than abandoning the two paths, we take over the

information the eye sub-path has gained, and continue tracing it until it reaches the

maximum length of light sub-path. The total length of the whole path remains unchanged.

In the process, we sample the BRDF and the light source at the same time according to

MIS.

There are two situations we expect to happen while reusing the eye sub-path. The first

situation is as shown in Figure 2.4 (a). After hitting the specular surface, the ray obey

the law of reflection, which means it samples the BRDS, and hit the light source. This

is more likely to happen if the light source is not a point light. The second situation is as

shown in Figure 2.4 (b). In the real world, scenes are complicated. Just a little adjustment,

the ray will not hit the specular surface traced by the light sub-path. If the ray hit a diffuse

surface, we can sample the light source to gain the illumination.

(a) Sample the BRDF

(b) Sample the light source Figure 3.4: A path reuse method.

Chapter 4

Results

This chapter presents the results obtained by our modified path tracer. All renderings

were performed on a PC running Windows 10 x64 with Intel Xeon E4405 2.13GHz CPU

and 6GB DDR3 1333MHz RAM.

4.1 Test Scenes

There are two test scenes used to show our method and also compared with other

rendering methods. The first one is a general empty Cornell Box. The second scene is a

Cornell Box with two spheres in it, one is made of mirror and the other is made of glass.

The scene has been slightly modified. The right wall of the Cornell box has been changed

to a mirror in order to show the SDS problem. Although the Cornell Box is a simple

scene, it is a classic benchmark for rendering.

4.2 Analysis

In the tests, the resolution of images is 512x512, and we set the maximum length of

paths at 8, which means that we would force the tracing process to stop when it exceeds

the maximum length and shows what it has got. We set the maximum light sub-path

length and eye sub-path length of bidirectional path tracing at 3 and 4 respectively. After

the vertex connection, the whole path length will remain 8 because the extended path is

added to the light sub-path and eye sub-path.

4.2.1 Empty Cornell Box

Figure 4.1 shows empty Cornell Box scene images generated by renderers using 100

iterations. Each image is rendered by a different rendering technique, which are path

tracing, bidirectional path tracing, vertex connection and merging, and our path reuse

method respectively. The rendering time is shown as Table 4.1.

Rendering Technique Time

Path Tracing 55.35 sec

Bidirectional Path Tracing 103.72 sec Vertex Connection and Merging 170.19 sec Our Path Reuse Method 105.57 sec

Table 4.1: Empty Cornell Box.

(a) Path tracing (b) Bidirectional path tracing

(c) Vertex connection and merging (d) Our path reuse method Figure 4.1: Empty Cornell Box.

4.2.2 Cornell Box with Spheres and Mirrors

Figure 4.2 shows the Cornell Box scene with a mirror replacing the right wall. The mirror

sphere is placed on the ground of the box and the glass sphere is floating to generate a

We show the rendering results of path tracing, bidirectional path tracing, vertex

connection and merging, and our path reuse method by using 200 iterations per pixel.

Because we have modified the scene to reveal the SDS problem, we not only record the

rendering times of each technique, but also the amount of failed vertex connection in

bidirectional path tracing.

(a) Path tracing (b) Bidirectional path tracing

(c) Vertex connection and merging (d) Our path reuse method Figure 4.2: Modified Cornell Box.

Rendering Technique Time

Path Tracing 90.22 sec

Bidirectional Path Tracing 136.00 sec Vertex Connection and Merging 234.57 sec Our Path Reuse Method 155.12 sec

Table 4.2: Modified Cornell Box.

4.3 Performance

In the first test scene, according to Figure 4.1 and Table 4.1, the scene generated by path

tracing consumes less time than the others, but we can see obvious noise on the ceiling.

Though the rest methods take more time, noise is hardly seen in the results. Due to no

SDS situation, the path reuse method is not triggered. The time taken by bidirectional

path tracing and our path reuse method are almost the same. Vertex connection and

merging method consumes the most time among the others.

In the second test scene, as shown in Figure 4.2, we just focus on the images rendered

by bidirectional path tracing, vertex connection and merging, and our path reuse method.

Because of the SDS problem, the vertex connection of bidirectional path tracing cannot

work properly. Thus, the reflected caustic cannot be seen in the mirror, and the reflection

on the mirror sphere of the glass sphere is much darker than it should be. The resolution

of the image is 512x512, and we made 200 iterations for each pixel, which means there

are 52,428,800 paths generated, but according to our record, 419,430,400 paths failed in

vertex connection step, which is roughly 12.5% of generated paths. With our path reuse

method, more time is spent, as shown in Table 4.2, but we can render what the scene

should be. It is worth mentioning that the whole path length remains to be 8. Though the

image rendered by vertex connection and merging method looks better than our path

reuse method, the time consumption of it is about 51.22% more than ours.

Chapter 5

Conclusions and Future Work

This thesis has provided an overview of basic concepts related to physically based image

synthesis and some popular sampling techniques. From the way of measuring the energy

of light to the sampling method based on statistics, and then some popular practical

implementations. At last, we introduced an alternative way to deal with the SDS problem

while the bidirectional path tracing method does not work.

Though we have used the MIS to higher the contribution from the light source, it still

fails in some situations. The idea called Light Propagation Volume, which is used by

non-physically based rendering to achieve the global illumination effect, comes to mind.

By using Light Propagation Volume, the space is divided into grids. The information of

light sources is spread into space, just like the first step in photon mapping. The spread

information is compressed and stored in grids by Spherical Harmonics. The energy of

bidirectional path tracing, we can take these grids as a part of samples according to MIS.

It is also convenient to reuse the grids structure to implement some acceleration data

structure, e.g., bounding box and k-d tree.

Bibliography

[DBK13] B. Duvenhage, K. Bouatouch, and D. G. Kourie, "Numerical verification of bidirectional reflectance distribution functions for physical plausibility,"

presented at the Proceedings of the South African Institute for Computer Scientists and Information Technologists Conference, East London, South Africa, 2013.

[Fau10] W. Faure, "Quality improvement in interleaved shading to solve the many light problem," M.S. thesis, Dept. Computer Science and Information Engineering, National Taiwan Normal University, Taiwan, 2010.

[GKDS12] I. Georgiev, J. Krivánek, T. Davidovic, and P. Slusallek, "Light transport simulation with vertex connection and merging," ACM Trans. Graph., vol.

31, p. 192, 2012.

[GRS96] W. R. Gilks, S. Richardson, and D. J. Spiegelhalter, "Introducing markov chain monte carlo," Markov chain Monte Carlo in practice, vol. 1, p. 19, 1996.

[Gla89] A. S. Glassner, An introduction to ray tracing: Elsevier, 1989.

[HKD14] T. Hachisuka, A. S. Kaplanyan, and C. Dachsbacher, "Multiplexed metropolis light transport," ACM Trans. Graph., vol. 33, pp. 1-10, 2014.

[HOJ08] T. Hachisuka, S. Ogaki, and H. W. Jensen, "Progressive photon mapping,"

ACM Trans. Graph., vol. 27, pp. 1-8, 2008.

[HPJ12] T. Hachisuka, J. Pantaleoni, and H. W. Jensen, "A path space extension for robust light transport simulation," ACM Trans. Graph., vol. 31, p. 191, 2012.

[Jen01] H. W. Jensen, Realistic image synthesis using photon mapping vol. 364:

Ak Peters Natick, 2001.

[JC07] H. W. Jensen and P. Christensen, "High quality rendering using ray tracing and photon mapping," presented at the ACM SIGGRAPH 2007 courses, San Diego, California, 2007.

[Kaj86] J. T. Kajiya, "The rendering equation," SIGGRAPH Comput. Graph., vol.

[Kaj86] J. T. Kajiya, "The rendering equation," SIGGRAPH Comput. Graph., vol.

相關文件