• Aucun résultat trouvé

Phase Functions

Dans le document Real-Time Volume Graphics (Page 161-167)

Global Volume Illumination

6.2 Phase Functions

Figure 6.4. An example of a volume rendering with direct lighting.

The modification of the slicing axis provides the ability to render each slice from the point of view of both the observer and the light, thereby achieving the effect of a high-resolution shadow volume without the requirement of pre-computation and storage.

Volumetric shadows can be implemented very efficiently on graphics hardware using multipass, slice-based volume-rendering techniques. The approach requires an additional pass for each slice, updating the light in-tensities for the next slice. Each slice is first rendered from the eye’s point of view, where the light intensity at each sample on the slice is acquired by sampling the position it would project to in the light’s buffer. This light intensity is multiplied by the color of the sample, which is then blended into the eye’s buffer. This step is illustrated in Figure 6.3 (left). Next the slice is rendered into the light buffer, attenuating the light by the opacity at each sample in the slice. This step is illustrated in Figure 6.3 (right). List-ing 6.1 shows the algorithm in pseudo code. An example of direct lightList-ing in volume-rendering applications can be seen in Figure 6.4.

6.2 Phase Functions

The role of the phase function in volume light transport is similar to that of the bidirectional reflectance distribution function (BRDF) in surface-based

i i

i i

i i

i i

144 Global Volume Illumination

ω { ω r ' Θ

Figure 6.5. An example of a symmetric phase function plotted in polar coordi-nates. The incoming directionωis fixed, whereas outgoing directionωvaries over all directions.

light transport problems. It describes the distribution of light after a scat-tering event for each outgoing directionωgiven an incoming light direction ω. Whereas the BRDF is only defined over a hemisphere of directions rel-ative to the surface normal, the phase function describes the distribution of light over the entire sphere of directions. Phase functions are generally only dependent on the cosine of the angle between the incoming and out-going directionsωandω: cosθ=ω·ω. Although true phase functions are normalized,

P(ω, ω)dω = 1, this is not required (or even useful) for interactive graphics applications. We will discuss this issue further in the next section (6.2.1). Figure 6.5 shows a plot of a simplified phase function in polar coordinates. The radius r is essentially the weighting for a par-ticular direction. Notice that the phase function is wavelength dependent, indicated by the colored contours. This class of phase functions is referred to as symmetric phase functions because the distribution of scattered en-ergy is rotationally symmetric about the incoming direction. Symmetric phase functions are valid for spherical or randomly oriented particles. For most applications, this class of phase functions is quite adequate.

Symmetrical phase functions can be implemented in conjunction with direct lighting by computing the dot product of the unit vector from the sample to the eye with the unit vector from the light to the sample, and then using this scalar value as an index into a 1D look-up table, i.e., this dot product is used as texture coordinate for reading from a 1D texture that stores the phase function term. The light and view directions can be computed for each vertex that defines the corners of the current slice being rendered and assigned to texture coordinates for each vertex. These coordinates are interpolated over the slice during rasterization. In the fragment program, we need to renormalize these vectors and compute the dot product between them. Because the range of values resulting from the

6.2 Phase Functions 145

Figure 6.6. Phase-function effects on a spherical cloud. The images use the Henyey-Greenstein phase function with g = 1 −α, i.e., the phase-function anisotropy is proportional to the transparency at each sample. Notice that the back-lit cloud (upper-left) has very bright fringes, whereas the front-lit cloud (upper-right) has dark fringes. This is because these regions have a highly forward peaked phase function. The center of the cloud has an isotropic phase function, which makes it brighter in the front-lit clouds. The lower-left image shows the spherical cloud lit at a 45angle to the viewer. The lower-right image was rendered using the Henyey-Greenstein phase function plus a Mie phase function generated using MiePlot; it is the Mie phase function that creates the subtle glory effect.

dot product are [1..1], we first scale and bias the values (x= (x+1)/2), so that they are in the range [0..1], and then read from the 1D phase function texture. The result is then multiplied with the direct lighting and reflective color. Figure 6.6 shows some effects of phase functions.

i

Figure 6.7. Henyey-Greenstein phase functions. Each graph plots multiple phase functions withgvarying from 0 to .9. The plot on the left shows phase functions that integrate to 1 over the sphere (normalized). The plot on the right shows phase functions that have been “renormalized” into the range [0..1] for use in interactive graphics with generic lighting.

6.2.1 Henyey-Greenstein Phase Function

For most purposes, wavelength dependence is not an important character-istic of the phase function. In general, we need the phase function only to describe the degree to which the scattering of light prefers forward (or backward) scattering. In this case, the Henyey-Greenstein phase function is an excellent choice:

G(θ, g) = 1−g2

4π(1 +g22gcosθ)1.5, (6.1) wheregis theanisotropyof the phase function. Wheng= 0, the scattering of light is equal in all directions, positive values ofgin the range [0..1] indi-cate forward scattering. Figure 6.7 plots two phase functions using different g values. Note that this phase function is normalized,

P(ω, ω)dω= 1.

The units of thisprobability density functionare 1/steradian or sr1 (stera-dians are the units associated with solid angles, a sphere has 4πsteradians).

This is not exactly a quantity we are accustomed to dealing with in inter-active graphics. A normalized phase function is really only meaningful if the light intensity is expressed in terms of radiometric irradiance, which has the units of watts per square meter. When the phase function and ir-radiance are multiplied together we get the ir-radiance for a scattering event, which has the units of watts per steradian per meter squared. The prob-lem is twofold: (1) in interactive graphics applications, we are generally using some generic light intensity, restricted to the range [0..1] for eachRGB color component, with no real associated units, and( 2) the shading models we use, e.g., Blinn-Phong, do not conserve energy. These issues becomes

6.2 Phase Functions 147 clear when we attempt to use a normalized phase function in this “generic light” setting. If we take a white light (I={1,1,1}) and use the isotropic phase function G(0,0) to compute light scattered in the forward direction (Iforward = IG(0,0))), we get the value Iforward = {0.079,0.079,0.079}, which is nearly black when displayed as a color. In contrast, if we com-pute the forward scattered light using a forward peaked phase function, G(0, .8), we get the value Iforward={3.58,3.58,3.58}, which is not even a displayable color besides the fact that this implies we are scattering three times as much light in the forward direction than we had to begin with.

Even though the Blinn-Phong shading model does not (necessarily) con-serve energy, it does not reflect more light than it began with. How can we take advantage of these phase functions in interactive rendering that does not deal directly with radiance and irradiance? Obviously, the phase function should be limited to the range [0..1] for any given phase angle, and we do not require it to integrate to unity over the sphere of directions.

We could renormalize for our generic light environment by dividing the phase function by its maximum value. Because we know that the Henyey-Greenstein phase function will always have a maxima at the 0 phase angle for positive values ofg, the renormalized phase function is

G(θ, g) =G(θ, g)

G(0, g), (6.2)

where negative values ofg(back-scattering) would have a maxima at 180 and therefore requireG(180, g) in the denominator. Here’s the rub: renor-malizing the phase function in this way will eliminate the essential inten-sity differences between isotropic scattering and forward scattering at the 0 phase angle. That is, G(0, g) = 1 for all g greater than or equal to 0, which means that there will be no difference in the scattered intensity for different phase functions when the phase angle is 0. However, this is probably not an issue, as this situation requires the material to be back-lit and even then, only a single pixel in the image plane will have a zero phase angle. This is not unlike the specular highlight in the Blinn-Phong shading model; regardless of what specular power is specified, the specular weight in the direction of the reflection vector will always be 1.

In practice, it is useful to cache a range of these phase functions in a 2D texture, where the first index is based on the phase angleθ(scaled and biased to the [0..1] range) and the second texture coordinate is thegvalue.

When we are rendering a volume using phase functions, thegterm can be specified as an additional optical property in the transfer function along with color and opacity. This is useful when rendering clouds, since the less dense outer fringes will have a highly forward peaked phase function, while the dense interior will have an isotropic phase function. In this case, one could set the gvalue to 1−αand achieve excellent results, as seen in

i i

i i

i i

i i

148 Global Volume Illumination

Figure 6.6. Notice that when the light is coming from behind the viewer, the outer fringes of the cloud are darker than the interior, while a back-lit cloud has very bright fringes.

6.2.2 Mie Scattering Phase Functions

Wavelength-dependent phase functions come into play when we are seek-ing the more exotic scatterseek-ing effects like rainbows and glories. The reason that these phenomena are so exotic or rare is that they require very spe-cific physical conditions, i.e., raindrops of a relatively uniform size or a very fine mist of relatively uniform water particles suspended in air. The phase functions themselves require very sophisticated physically based sim-ulation over hundreds of individual wavelengths to compute. Fortunately, a tool exists for computing, visualizing, and analyzing these complicated effects. MiePlot by Philip Laven is an excellent tool for generating these special-purpose phase functions. Keep in mind that, while this tool can generate scattering functions for specific wavelengths, a three-wavelength phase function (one for each of red, green, and blue) will not produce very good results for rendering. The reason for this is that the RGB channels that we use for display are meant to cover three wavelengthintervals, not three individual wavelengths. Also, this tool is designed to simulate scat-tering effects for water particles of very specific sizes, and changing the size of particles can result in very different phase functions. This tool al-lows one to simulate scattering for a distribution of particle sizes; when this is done, we can observe that increasingly heterogeneous particle sizes result in phase functions that have little or no wavelength dependence.

Figure 6.8.A glory effect computed using MiePlot (inset) overlaid with a real pho-tograph of the phenomena. The phase function required a simulation involving 200 individual wavelengths of light and a uniform water particle size of 4.8 mi-crons.

Dans le document Real-Time Volume Graphics (Page 161-167)