• Aucun résultat trouvé

Environment Mapping

Dans le document Real-Time Volume Graphics (Page 150-153)

Local vs. Global Volume Illumination

5.7 Environment Mapping

The idea of environment mapping is to either capture or pre-compute com-plex illumination scenarios. The usefulness of this approach derives from its ability to approximate local illumination with an infinite number of lights and arbitrary types of light sources in real time. Environment map-ping [87] in general is a two-stage process that involves the construction of a reflection map and/or an irradiance map as a pre-computation step.

5.7 Environment Mapping 133

Figure 5.7. Examples of a reflection map (left) and a corresponding irradi-ance map (right). (Eucalyptus Grove Light Probe Image c1998 Paul Debevec, www.debevec.org.)

Environment maps store the light intensity emitted into, or arriving from, all spherical directions around a point in 3D space. Storing an en-vironment map thus requires a 2D parameterization of a spherical surface.

In practice, different representations of environment maps exist.

Spherical mapsstore the entire incoming illumination in a single cir-cular image. An example is displayed in Figure 5.7. The basic idea is that when a perfectly mirroring sphere is rendered (or, as an approxi-mation, photographed) with an orthographic projection, the resulting image contains the reflection of almost all spherical directions around a point. In the limit, where the sphere is infinitely small, a spherical map actually captures all spherical directions. However, with this approach distortions for directions behind the view direction are very severe, and thus a spherical map can only be used for the view direc-tion for which it has been generated or for very similar direcdirec-tions.

Dual paraboloid maps reduce the distortions of spherical maps by mapping all spherical directions to two circular images. The param-eterization corresponds to the orthogonal projection of a paraboloid for each of these two images.

Cube mapsstore all spherical directions in the six faces of a cube. For each of these faces, standard rendering and projection of the environ-ment with a field of view of 90 degrees can be used, and thus cube maps are extremely easy to generate on-the-fly on GPUs. Because of this property, cube maps are currently the most versatile repre-sentation for real-time rendering. They can be easily updated every

i i

i i

i i

i i

134 Local Volume Illumination

frame. For example, in order to capture the volumetric illumination of a volume light source, the volume simply has to be rendered from six sides.

Spherical harmonics are a frequency-based approach for representing spherical functions. Spherical harmonic coefficients correspond to fre-quencies and also have the same property that low-frequency signals

// irradiance and reflection mapping with // post-classification using 3D textures half4 main (half3 texUV : TEXCOORD0, float3 position : TEXCOORD1, uniform float3 Kd, // diffuse, uniform float3 Ks, // specular uniform float3 eyePosition, uniform sampler3D volume texture, uniform sampler1D transfer function, uniform samplerCUBE irradiance map,

uniform samplerCUBE reflection map) : COLOR {

float4 sample = tex3D(volume texture, texUV);

// expand and normalize the normal vector float3 N = normalize(2.0*sample.xyz - 1..xxx);

// calculate viewing and reflection vectors float3 V = normalize(eyePosition - position);

float3 R = reflect(V,N);

// sample irradiance map (normal direction) float3 diffuse = Kd * texCUBE(irradiance map,N);

// sample reflection map (mirrored viewing direction) float3 specular = Ks * texCUBE(reflection map,R);

// emission and absorption from transfer function half4 result = tex1D(transfer function, sample.w);

// add illumination

result.rgb += diffuse + specular;

return result;

}

Listing 5.9. Cg fragment program for local volume illumination with environment mapping. The specular term is looked up in a reflection cube map, and the diffuse term is obtained from a pre-computed irradiance cube map.

5.8 High Dynamic Range Illumination and Volume Rendering 135 can be represented quite accurately by storing only a few coefficients and setting high frequencies to zero. Thus, spherical harmonics are especially powerful in the case of low-frequency lighting or diffuse lighting. For example, an environment map that will be used only in conjunction with diffuse reflection can be represented with a very small number of spherical harmonic coefficients without almost any noticeable error.

Environment maps can be used to efficiently implement different illu-mination effects. In general, they cache the incident illuillu-mination from all directions at a single point in space. The light reflected into our eye by a perfect mirror comes from exactly one spatial direction. For a perfect mirror, the incident illumination can thus directly be looked up in an en-vironment map using the reflection directionras in Equation 5.22.

Lambertian reflection requires integration of the incident illumination over the hemisphere centered about the normal vector. Such an integration can again be pre-computed as a so-calledirradiance map, which stores the value of the integral over the hemisphere as function of the normal direction.

An example of such an irradiance map is displayed in Figure 5.7 (right).

Nonperfect specular reflection can be implemented by pre-filtering en-vironment maps for isotropic BRDFs and a rotational symmetric specular lobe. Just as in standard polygon-based rendering, environment maps can also be used in volume rendering to capture the entire external illumi-nation surrounding a volume. Theory and practice of diffuse and glossy pre-filtering of environment maps can be found in [202]. An example im-plementation of local volume illumination using an irradiance map for the diffuse term and a reflection map for the specular term is given in List-ing 5.9. In a reversed sense, environment maps can also be used to capture the entire illumination emitted by a volume into the surrounding space.

5.8 High Dynamic Range Illumination

Dans le document Real-Time Volume Graphics (Page 150-153)