• 沒有找到結果。

Exploiting Visibility Coherence

Chapter 4 Algorithm

4.2 Exploiting Visibility Coherence

After calculating the product of the SRBFs, we will have multiple SRBF kernel functions. Now we must decide how many samples should be taken from each SRBF kernel. We employ the mixture model for taking samples from the SRBFs. To generate a new sampling direction, we first select a SRBF l with probabilityP(l). Then we generate a sampling direction for shadow ray against the center of SRBF. In the original Tsai’s paper, P(l) is determined by

where I is the integral of SRBF i. The integral represents the total energy gathered i from all directions. Therefore, the meaning of Eq. 9 is to allocate samples according to the energy of each SRBF with respect to the total energy of all SRBFs.

To consider the visibility, we introduce a visibility term V into Eq. 9. The i probability of choosing the SRBF l from the multiple SRBF kernel functions becomes:

the visibility term V stands for the visibility weight of the SRBF i . It is determined i according to the previous sampling history. In the following, we will demonstrate how to keep the history and derive the visibility weight.

To build the history, we create a visibility cache to keep a list of invisible directions for shadow rays. In the original Monte Carlo ray tracing algorithm, several

20

shadow rays are generated sequentially to sample the lighting contribution from the environment map when a view ray hits the scene object. Then the average is calculated as the outgoing radiance along the camera ray. Our algorithm takes advantage of this sequential property. If the sampling direction fails in the visibility test, we record its direction in the cache. When taking next sample, the content in the cache is used to adjust the probability P(l) of each SRBF. By keeping the results of visibility tests in visibility cache, we can avoid redrawing samples in invisible directions with respect to this ray-tracing point. We define the visibility term as follows:

where Num(dir) represents the number of directions which are close to the center of the SRBF l , and k is a constant to control the decreasing slope.

For each SRBF l , we determine whether the invisible directions in the visibility cache and the center of SRBF are close or not. If the angle between these two directions is smaller than a threshold, we increase Num(dir). This will lower the visibility term V , meaning the SRBFs with their centers close to the invisible l directions will have smaller probability to be chosen. Now the problem is how to determine the threshold? Instead of using a fixed threshold, we construct a bandwidth function to determine the threshold. We assume the angle between the center of a SRBF and an invisible direction in the visibility cache is a normal distribution, we can evaluate the standard deviation of angle with some appropriate simplification as follows:

21

where x is cosine value of the angle between two directions, B is the bandwidth of the SRBF, and Lns is a normalization term which can be calculated as:

2 1

The bandwidth represents the influence of the SRBF. We can use the standard deviation to cut a fixed percentage of directions from different SRBF by evaluating the bandwidth function.

Now consider Figures 4.3 ~ 4.8, we show an example to explain how our algorithm works. Figure 4.3 shows a scene with a bunny in a room. Light sources coming from environment map can only illuminate the scene through the window on the wall. The visibility cache is empty initially and updated through the progress of sampling. As shown in Figure 4.4, when a view ray hits the surface, we first evaluate the product of BRDF and illumination to generate a multiple kernel SRBF. As shown in Figure 4.5, since at beginning the visibility cache is empty, the SRBF with larger coefficient among the multiple kernel functions has higher probability to be chosen (SRBF1 in Figure 4.5). A sampling direction is then generated from SRBF1. In Figure 4.6, the direction fails in visibility test. We record its direction (Direction1 in Figure 4.6) in the visibility cache. When we continue to generate the next sample, the visibility cache is used to adjust the coefficient of SRBFs. As shown in Figure 4.7, the coefficient of SRBF1 is reduced so that we have higher probability to select SRBF2 for sampling. Finally, as shown in Figure 4.8, since Direction2 passes the visibility test, we do not need to update the cache. From this example, we can conclude that more samples are concentrated in the visible directions like Direction2.

22

Figure 4.3: Run-time example 1: The scene objects and light source. The visibility cache is empty at the beginning.

Figure 4.4: Run-time example 2: Multiple SRBF kernel functions are generated for a ray-tracing hit.

23

Figure 4.5: Run-time example 3: The visibility cache is empty and the SRBF with larger coefficient has higher probability to be chosen. An illumination sampling ray is then generated according to the SRBF.

Figure 4.6: Run-time example 4: The ray generated from SRBF1 fails in the visibility test. Its direction is then recorded in the cache.

24

Figure 4.7: Run-time example 5: When taking next sample, the content in the visibility cache is used to lower the probability of SRBF1. As a result, SRBF2 has higher probability to be chosen.

Figure 4.8: Run-time example 6: The ray generated from SRBF2 (Direction2) passes the visibility test. Therefore, there is no need to update the cache.

25

相關文件