• No results found

5.6 Results

6.2.6 Using the Ambient Grid

During rendering, the ambient grid is used to contribute indirect lighting to regions that are not covered by the samples in Q, such as dynamic geometry. Ir- radiance atpis coarsely estimated from the ambient contributions by performing trilinear interpolation between adjacent cells of the grid. Let fl(x, y, t) linearly

interpolate between xand y, fort [0,1], such that:

fl(a,b, t) =a(1−t) +tb. (6.4)

A bilinear function, fb, can be constructed from the product of two linear interpolations (see Figure 6.7), such that:

fb(a0,a1,a2,a3,t) = fl(fl(a0,a1, tx), fl(a2,a3, tx), ty). (6.5)

Subsequently, a trilinear interpolation function ft can be constructed from

the linear interpolation of the output of two bilinear interpolation functions (see Figure 6.7):

6. Remote Asynchronous Indirect Lighting (RAIL) 139

Algorithm 7 Propagation of ambient contribution values to empty cells.

1: procedure Propagate(grid,iterations)

2: Ac[· · ·]←1

3: for 1n iterationsdo

4: for each pgrid∧ ¬ isEmpty(p)do

5: cells FilterNeighbours(p)

6: for each ccells isEmpty(c) do

7: Ae[cx, cy, cz]←Ae[cx, cy, cz] +Ae[px, py, pz]

8: inc Ac[cx, cy, cz]

9: end for

10: end for

11: for each pgriddo

12: Ae[px, py, pz]←Ae[px, py, pz]/Ac[px, py, pz] 13: end for 14: end for 15: end procedure 16: procedure FilterNeighbours(p) 17: nAn[px, py, pz] 18: cells← ∅ 19: if nx >= √13 then

20: cellscells rightNeighbours(p)

21: else

22: if nx<=−√13 then

23: cellscells leftNeighbours(p)

24: end if

25: end if

26: if ny >= √13 then

27: cellscells topNeighbours(p)

28: else

29: if ny <=−√13 then

30: cellscells bottomNeighbours(p)

31: end if

32: end if

33: if nz >= √1

3 then

34: cellscells frontNeighbours(p)

35: else

36: if nz <=−√13 then

37: cellscells backNeighbours(p)

38: end if

39: end if return cells

6. Remote Asynchronous Indirect Lighting (RAIL) 140 1 √ 3

n

z (px, py, pz + 1) (px+ 1, py, pz + 1) (px+ 1, py, pz)

Figure 6.6: Selection of neighbouring cells for propagation. The cells indicated by the arrows are added to the propagation set cells when the normal vector n

falls within the designated region R+z, that is, nz p1/3.

Figure 6.7: Trilinear filtering is used to interpolate between the ambient com- ponent values stored at adjacent cells in the ambient grid A. The function

ft is a composition of linear interpolation functions fl. For convenience, fb

is defined as the composition of two linear interpolation functions, such that

fb(· · ·) =fl(fl(· · ·), fl(· · ·),· · ·), and subsequently,ft is defined in terms of both

linear and bilinear interpolation functions. The interpolation space is assumed to be a unit cube.

6. Rem ote Async hro nous Indirect Ligh ting (RAIL) 141

(a) No ambient value.

Ae[i−1, j+ 1] Ae[i, j+ 1]

(b) 1st iteration.

Ae[i−1, j+ 1] Ae[i, j+ 1]

(c) 2nd iteration.

Figure 6.8: Iterative propagation process for ambient lighting. In 6.8a, cells that contain no samples (and hence no ambient value) are marked in white. Ae[i, j] marks the weighted mean of irradiance values, which is used to propagate indirect lighting to adjacent cells. In 6.8b, one iteration of propagation has been performed, and the empty cells adjacent to (i, j) which face the hemisphere of directions aroundAn[i, j] have received indirect lighting. Particularly, An[i, j] acts as an occluder of sorts,

to stop propagating values in its opposite direction. Cells that do not have a normal vector defined due to being empty of irradiance samples propagate values in all directions, that is, to all empty adjacent cells. 6.8c shows the ambient grid after two iterations of propagation, where all the empty cells are now populated with an ambient value.

6. Remote Asynchronous Indirect Lighting (RAIL) 142

Thus, the higher-order ambient function, Fa(A,p), is given by:

Fa(A,p) = ft(Ae[rx, ry, rz], Ae[rx+ 1, ry, rz], Ae[rx, ry + 1, rz], Ae[rx+ 1, ry+ 1, rz], Ae[rx, ry, rz+ 1], Ae[rx+ 1, ry, rz+ 1],

Ae[rx, ry+ 1, rz+ 1], Ae[rx+ 1, ry + 1, rz+ 1],s), (6.7)

where r = int(p), which returns the integer part of the components of p, such that (rx, ry, rz) is the index of the grid cell containing point p; s = f rac(p),

which returns the fractional components of p, such that sx, sy, sz ∈ [0,1). The

application ofFato an object subject only to direct lighting can be seen in figures

6.9a and 6.9b. In the first figure, the object is illuminated only by means of direct light; since the light is partially occluded, a great part of the object is depicted in black. In the second figure the black patches on the object are now lit via the ambient function, albeit the latter does not take into account surface occlusion. Thus, a heavily occluded point receives the same contribution as one that is less occluded, leading to a loss of perception of the shape of the object, as can be observed in Figure 6.9b. In order to curtail a point’s exposure to ambient lighting and provide a better perception of the shape of geometry (Langer & B¨ulthoff, 1999), ambient occlusion (AO) is applied to Fa. The extension to the ambient

function is thus: Fao(A,p) = Fa(A,p) π Z Ω V(p, ω) ω·Np dω. (6.8)

AO being a global method, it requires access to scene geometry in order to com- pute point visibility, which makes it less suitable for use in rasterisation. Instead of traditional AO, screen space ambient occlusion (SSAO) is used, which is a faster approximation that computes occlusion from neighbouring pixel depths rather than scene geometry (Mittring, 2007). The application of the new am- bient function Fao can be seen in 6.9c, where the AO term is evaluated using

SSAO. Figure 6.10 shows how a typical dynamic object affects and is in turn affected by indirect lighting during rendering; the scene is entirely lit using the spatially-varying ambient function.

6. Remote Asynchronous Indirect Lighting (RAIL) 143

(a) Direct lighting

(b) 1st Step: Trilinear interpolation across am- bient terms of adjacent cells using uses Fa.

(c) 2nd Step: Ambient occlusion using Fao.

Figure 6.9: Indirect lighting function for dynamic objects, where 6.9a is the base direct lighting, 6.9b shows the object shaded with the spatially-varying ambient term, and 6.9c augments the result of 6.9b with screen space ambient occlusion.

6. Remote Asynchronous Indirect Lighting (RAIL) 144

Figure 6.10: Dynamic object contributing to and receiving diffuse indirect light- ing. The entire scene has been visualised using the coarse grid described in§6.2.4 and does not use irradiance information contained in point cloud Q.