• 沒有找到結果。

Global Illumination in dynamic scenes

CHAPTER 2 Related Works

2.4 Global Illumination in dynamic scenes

In Stochastic Progressive Photon Mapping[5], Weiss and Grosch[20] proposed methods to reduce the cost of the computation in dynamic scene like objects moving on a pre-defined path, and material/texture changes. They first load both the static scene and the dynamic geometry for all K frames into main memory. By re-using photon and hit point information for multiple frames, the computation time can be reduced. But there is a big limitation that it can only compute the objects on pre-defined path.

Dachsbacher[4] proposed the antiradiance to reduce the computation time of explicit visibility. They observe that if visibility is ignored, some light is transmitted extraneously through opaque objects and needs to be canceled out. This is why they introduce a new quantity called antiradiance which corresponds to the light that needs to be removed. It shifts visibility computation to simple local iterations by maintaining additional directional

8

antiradiance information with samples in the scene which is easy to parallelize on a GPU. Our proposed method use a similar idea to create the compensation photon which reduces the radiance which exists in the scene at the previous frame and does not exist at the current frame.

9

Chapter 3 Algorithm

In this chapter, we discuss our proposed algorithm to speed up the progressive photon mapping. We render direct illumination by using a similar phong lighting model based on the demo of progressive photon mapping of NVIDIA Optix. We only implement our algorithm on indirect illumination and rigid body object. The following figures in this chapter are shown as the indirect illumination part of the scene. All the processes are performed on the GPU.

Before the objects move, we perform the following steps for a static frame:

1. Ray tracing pass.

2. Photon tracing pass.

3. Gathering pass.

4. Iterate photon tracing and gathering pass until enough photons emitted.

When we start to move the objects, we perform:

1. We emit the compensation photons towards the area where the moving objects may affect the illumination in the scene.

2. Gathering the compensation photons to render the scene.

After we move the objects, for the dynamic frames, we perform:

1. Update the information of hit points.

2. We emit the positive radiance photons to compensate the indirect radiance that the next frame needs.

3. Gathering the positive radiance photons to render the scene.

4. Repeat step 6 until enough photons emitted.

10

3.1 Overview

In this section, we describe our concept of our algorithm. In progressive photon mapping, if objects are moved in the scene, it would do the algorithm again and do not keep any information of previous frame. The concept of our algorithm is to keep the information of previous frame and use the information to render the next frame effectively. Most important information in the scene is the radiance. We only discuss indirect radiance in our algorithm.

How we keep the indirect radiance is to eliminate the different indirect radiance between two frames.

In figure 1.1, we introduced overview of our algorithm. The key points in our algorithm are eliminating illumination and compensating the scene. We describe the process of these two parts more detail here. To eliminate the indirect radiance, we divide the indirect radiance into two parts. The first part is the indirect radiance bounced by moving volume. Before the objects are moved, we emit compensation photon towards the moving volume to bounce the photons to eliminate the indirect radiance. So we first define the emitting region of compensation photons, then we emit the photons within this region. We discuss more detail in section 3.3. After each compensation photon tracing pass, we calculate the radiance in gathering pass. The other part is the indirect radiance bounced to the moving volume of moving objects. We directly update the hit points in the moving volume to set the radiance to zero. The flow chart of eliminating radiance is shown as figure 3.1. We update the hit points after objects are moved.

11

Figure 3.1 The flow chart of eliminating radiance.

To compensate the radiance the next frame needs, we also compensate two parts of indirect radiance. To compensate the radiance on moving volume, we use testing photons to get the directions. We use these directions to emit the positive radiance photons to bounce the photons to the moving volume. We discuss more detail in section 3.5. To compensate the indirect radiance outside the moving volume, we emit the positive radiance photons towards the moving volume by using the same emitting region of compensation photons. The flow chart of compensating the scene is shown as figure 3.2.

Figure 3.2 The flow chart of compensating the scene.

12

3.2 Data Structures

Similar to the progressive photon mapping, for each hit point, we store its coordinate and the normal vector, the ray direction, scaling factors including BRDF, the associated pixel location, a radius, the intercepted flux, and the number of photons within the radius.

After the ray tracing pass, we get the information of each hit point. Then we trace the photons along the scene. At each hit point, we obtain the energy from light source. In order to attach photons on object surface, we build an one-dimensional buffer called photon map. The size of photon map depends on the number of the photons emitted in each pass. All of the ray tracing, photon tracing, and gathering passes are performed on GPU by using Nvidia Optix[13].

We use a list to store the serial number of the hit points which we update. We discuss this in section 3.4. We store the directions of testing photons emitted from light source. We discuss this in section 3.5.

3.3 Compensation Photon

In the progressive photon mapping, if there is an object moved in the scene, the algorithm will do the ray tracing pass again and emit all the photons. We found that, when the objects moved in the scene, the radiance in the scene may not change at every frame. So we need to detect and keep the same radiance between the current frame and the next frame.

We propose a new type of photon called the compensation photon. We use this photon to eliminate the indirect radiance in the scene that is not needed for the next frame. Then we can get a frame, which only contains the same radiance between two frames. We observe that

13

the most difference between the current frame and the next frame is the indirect radiance bounced to the moving volume of the moving objects, as the yellow area shown in Figure 3.3.

We set the size and the position of the moving volume in ray tracing pass. We compare the positions of hit points in the current frame with the positions of hit points in the next frame.

The area where the positions of the hit points are different is called moving volume.

Furthermore, the indirect radiance produced by photons hitting on the moving volume and bounced to side is also different. The major function of the compensation photon is to eliminate the indirect radiance produced by the moving volume.

Figure 3.3 Two images only render indirect illumination. (a) Before tall box moves. (b) After tall box moves.

To eliminate the indirect radiance outside the moving volume, we should emit the compensation photons towards the moving volume. The compensation photons hit the moving volume and bounced to side to eliminate the indirect radiance. Before we emit the compensation photons, we store the vertices of the object moved before and after. We use a point light to emit the compensation photons. If the light source of the scene is area light, we put the point light on the central of the area light. We should limit the emitting region of the

14

point light. To define the region where we should emit the photons, first we set the direction of the point light by connecting the central of the vertices with the point light. And then we project the vertices on the plane. The plane’s normal is the direction of point light. To set the position of plane, we set the plane through the central of the vertices. To project the vertices, we connect the vertices with point light and use the connection to calculate the intersection with the plane. We use a bounding rectangular to enclose all the vertices on the plane as moving area of moving objects as shown in Figure 3.4. Finally, we randomly emit the compensation photons through this bounding rectangular to eliminate the indirect radiance. In each compensation photon pass, we emit 256x256 photons. In Figure 3.3, the radiance of yellow areas is eliminated by the compensation photons. Note that we trace the compensation photons before the objects moved, because we need to eliminate the indirect radiance produced by moving objects before the objects move.

Figure 3.4 (a) Set the bounding rectangular from the point light’s view. (b)Emit the compensation photons in the region of moving volume.

Point light The projection plane

Bounding rectangular

15

3.4 Update Hit Points

After we trace the compensation photons, we move the objects. In Section 3.2, we mentioned that the most different part between two frames is the indirect radiance bounced to the moving volume of the moving objects. The hit points in the moving volume are almost changed. If we use the compensation photons to eliminate the radiance in this volume, it would be inefficient. Due to this, we directly update the information of hit points in the moving volume, and the information of other hit points remains the same. There is a black area in Figure 3.5 that shows the hit points we update.

Note that, during updating the hit points, we still loop through all the hit points to tag which hit point we have updated. Because the radiance of these hit points is set to zero, we should compensate these hit points more radiance then others hit points in next step. We use a list to store the serial numbers of the hit point we have updated.

Figure 3.5 The image after emitting the compensation photon and update the hit points.

16

3.5 Compensate The Scene

After we move the objects, there are two parts in the scene where we should compensate in this pass. One is the indirect radiance bounced to the moving volume. The other is the indirect radiance produced by moving objects. To compensate the indirect radiance produced by the moving objects, we emit the photons with the path same as the path of the compensation photons as the green dashed region shown in Figure 3.6.

Figure 3.6 The tracing paths are used to trace the photons to compensate the indirect radiance.

To compensate the indirect radiance bounced to the moving volume, we can not just emit the positive radiance photons with the path same as the path of the compensation photons. In Figure 3.7, the orange dashed lines represent the photon tracing path inside the region, and the blue dashed lines represent the photon tracing path outside the region. It shows that there are a lot of photons accumulated by the hit point and the tracing path outside the region.

Before we move the objects, we emit the testing photons into the scene and store the The

moving volume

17

directions of the photons emitted from light source. In Section 3.3, we stored the serial numbers of the hit points we have updated. We only use these stored hit points to accumulate the testing photons in the gathering pass. Therefore, we can get the directions from these accumulated testing photons. Then we can emit the photons to compensate the radiance by these directions effectively. Besides, we only use stored hit points to accumulate the positive photons in gathering pass. In the progressive photon mapping, it repeats the photon tracing pass many times. If we use these directions repeatedly, it will cause that the photons are over accumulated by some hit points and there would be a lot of highlight in the image, as shown in Figure 3.10. To solve this artifact, we jitter the directions respectively within a cone with opening angle α of the cone in each photon tracing pass. According to the experiments, if α is too large, the indirect radiance is compensated inefficiently. And if α is too small, the artifacts still exist. So we define the region of α within 10 In Figures 3.8 and 3.9, we can observe that we compensate the indirect radiance of the moving volume by these directions more effectively.

Figure 3.7 The tracing path of the photons, and the photons are accumulated by the hit points in the moving volume.

The moving volume

18

Figure 3.8 The scene is compensated by the photons which tracing path only within the bounding rectangular.

Figure 3.9 The scene is compensated by the photons which tracing path include the directions we record.

19

Figure 3.10 The artifact is caused by the directions of tracing photons without jittering.

3.6 Radiance Evaluation

In the progressive photon mapping, it emits positive radiance photons in each photon tracing pass. After each photon tracing pass, it accumulates the photons to evaluate the radiance by looping through all the hit points and render an image in gathering pass. In each gathering pass, it does three steps. The first step is radius reduction. Each hit point has a radius. While the number of photons accumulated within this radius increases, the radius needs to be reduced. The second step is flux correction. When a hit point receives new photons, it needs to accumulate the flux carried by those photons. So it needs to adjust this flux to take into account the radius reduction. The third step is radiance evaluation. By using the radius, the current flux multiplied by the BRDF, and the total number of emitted photons

20

in order to normalize the flux, it can evaluate the radiance at each hit point.

In our approach, after we emit the positive radiance photons in the photon tracing pass, the radiance evaluation in the following gathering pass is the same with the progressive photon mapping. But we should reformulate the radiance evaluation after we emit our negative power compensation photons in each photon tracing pass.

For radius reduction, we reformulate this to radius addition. When the hit points accumulate the compensation photons, we reduce the number of the photons accumulated within the radius. The number is computed as follows:

N̂(x) = N(x) − αM(x) (5)

whereN(x) is the current number of the photons accumulated, M(x) is the additional number of the photons accumulated, andα, 0 < 𝛼 < 1, is only a fraction

By reducing the number of the accumulated photons, we can increase the radius as follows:

R̂(x) = R(x) + 𝑑R(x) = R(x)√N(x)−αM(x)N(x)−M(x) (6)

If we over accumulate the negative power photons, it may cause the R(x) to turn to negative. We should clamp the value of the radius to one, if the value of the radius is less than zero.

For flux correction, we reformulate the flux evaluation as follows:

τN̂(𝑥, 𝜔⃑⃑ ) = τN−M(𝑥, 𝜔⃑⃑ )N(x)−αM(x)N(x)−M(x) (7)

21

where the quantity τ is represented as flux. If we over accumulate the negative radiance photons, it may cause the value of flux to be less than zero. We clamp the value of flux to zero, if the value of flux is less than zero.

For radiance evaluation, we use the Equation 4. mentioned in Section 2.2.

22

Chapter 4

Implementation and Results

Our results are rendered on a desktop PC with Intel Core i7 930 CPU 2.8GHz and NVIDIA GeForce GTX 480 video card. All results are rendered at 768 x 768 pixels.

In the progressive photon mapping, direct illumination and indirect illumination are rendered by tracing the photons in photon tracing pass. In our approach, we render direct illumination by using a similar phong lighting model based on the demo of progressive photon mapping of NVIDIA Optix. We only implement our algorithm on indirect illumination.

GPUs are best at exploiting very high degrees of parallelism, and ray tracing fits that requirement perfectly. Optix is a simple but powerful abstract model of a ray tracer running entirely on the NVIDIA CUDA compute architecture. So we implement our approach by OpenGL, and the major computation part is performed by Optix engine including the ray tracing pass, the photon tracing pass, and the gathering pass. To store the data of each hit point and each photons, we use the buffer stored in GPU memory designed by Optix. This buffer can be accessed by CPU and GPU, and then we can access the data efficiently. In program, when we render the scene, we only compute the photon map on CPU. Other works are performed by GPU.

When sending mesh data into Optix, we should construct the geometry group in Optix context first. As shown in Figure 4.1, a geometry group can contain many geometry instances.

23

Each geometry group needs to have an acceleration object assigned for ray traversal to intersect. Each geometry instance represents a coupling of a single geometry node with a set of materials. Each geometry node is bounded with intersect program and bounding program.

In intersect program, we compute the position of intersection of ray and geometry. In bounding program, we bound primitive data. In any-hit program and closet-hit program, we can trace the ray to obtain the external material such like shadow or indirect light. The difference between any-hit and closet-hit is using the ray payload or not. We use closet-hit program to obtain the information of ray payload such like color, normal. And any-hit program can only return hit geometry or not.

Figure 4.1 Optix data structure

24

We render the scenes by the progressive photon mapping all in 15 seconds before the objects move. After the objects move, we spend 8 seconds rendering the next frame. In order to highlight our contribution, we show comparison images with the same performance. One uses our algorithm to render the scene. The other uses the progressive photon mapping to render the scene with same performance.

Figure 4.3, 4.6, and 4.9 display the moving objects moved in the scenes rendered using the progressive photon mapping. Figure 4.4, 4.7, and 4.10 display the moving objects moved in the scenes rendered by our algorithm. Figure 4.2, 4.5, and 4.8 display the ground truth of the scenes. Figure 4.2 - 4.4 display basic cornell box scene. Figure 4.5 - 4.7 display cornell box scene containing a complex model. Figure 4.8 - 4.10 display the effect of caustic in the wedding -band scene.

25

Figure 4.2 The ground truth of tall box moving in cornell box scene.

Figure 4.3 Tall box moves in cornell box scene using PPM.

26

Figure 4.4 Tall box moves in cornell box scene using our method.

Figure 4.5 The ground truth of bunny moving in cornell box scene.

27

Figure 4.6 Bunny moves in cornell box scene using PPM.

Figure 4.7 Bunny moves in cornell box scene using our method.

28

Figure 4.8 The ground truth of middle ring moving in wedding-band scene.

Figure 4.9 Middle ring moves in wedding-band scene using PPM.

29

Figure 4.10 Middle ring moves in wedding-band scene using our method.

Figure 4.10 Middle ring moves in wedding-band scene using our method.

相關文件