



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of environment mapping in computer graphics, which involves precomputing and storing the colors incoming towards a reflective object along different rays. It discusses two specific examples of environment mapping: spherical and cubical. Spherical environment mapping uses a photograph or synthetic image of a mirror sphere to store colors incoming along rays of all possible directions. Cubical environment mapping records colors incoming towards a point from every direction and paints them onto the cube's surface. The document also explains how to use texture coordinates with spherical environment mapping and how to convert normals to texture coordinates in cubical environment mapping.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Figure 1: Eye rays reflected from an object. The reflected rays are shown as blue arrows. Red arrows are the normal vectors. Given the normal vectors, one can compute the reflected rays using the formulas we used to do Phong shading. Note that environment mapping will not produce correct results for rays which have to bounce from the object several times before escaping to the environment (like one of the rays shown above).
Consider an ideally reflective object and a ray through a pixel. What color should one use for that pixel? The same as the color incoming to the reflection point from the direction of the reflected ray (see Figure 1). Therefore, if one is able to precompute and somehow store the colors incoming towards the reflective object along different rays, rendering would be really simple. In environment mapping, one stores the colors arriving at a 3D object from different directions in one or more textures. Typically, one assumes that colors incoming to different points along parallel rays are the same. This means that we need to keep a color for each incoming ray direction rather than for every possible incoming ray. Below we discuss two specific examples.
Imagine a photograph (or a synthetic image, e.g. rendered using ray tracing) of a mirror sphere. This image stores colors incoming along rays of all possible directions (Figure 2). It is directly used as texture for spherical environment mapping. Such a texture might look like the one shown in Figure 3. To simplify things, let’s say that the sphere is exactly inscribed into the (square) photograph.
Figure 2: A mirror sphere. Any direction is a direction of a certain reflected horizontal ray. Spherical environment mapping is based on mapping colors from a photograph of a reflective ball onto a 3D object. If the photograph is taken from infinite distance, colors incoming from all directions are present on that photograph. Of course, there are two caveats here: (1) the distance between the viewpoint and the sphere is finite – a typical photograph is a perspective image rather than a parallel projection based image; in particular, some directions are not represented on the image; we’ll just sweep this problem under the carpet here, saying that if the photograph is taken from far away, the projection is close to parallel; (2) the photograph will not really store colors for every ray, but only at rays through pixels and the density of sampling of the space of directions will not be uniform; we’ll just hope that interpolation will solve this problem.
(0,0) (1,0)
(0,1) (^) (1,1)
Figure 3: An example of a texture for use with spherical environment mapping and a 3D model with this spherical environment mapping.
P
color incoming from direction of v to P
v
Figure 4: Cubical texture mapping.
bottom front^ top back
left
right
Figure 5: Flattening the cube environment map.
Cubical environment map is more flexible (there is no problem with applying it to views from different directions, for example) but it its hardware implemen- tation is slightly more complicated. One possible scenario is as follows. For each vertex, use texture coordinates equal to the coordinates of a unit vector pointing in the direction symmetric to the view vector about the normal of that vertex (this is the direction of the incoming color we want to use). Send this texture coordinate to the rasterizer and let it linearly interpolate to fragments. At the fragment processing stage, convert the interpolated normal to ‘real’ tex- ture coordinates (in the texture space) and look up color from texture. The conversion of normal to coordinates in the image basically maps that normal to the corresponding point on the cube and finds the corresponding point on the texture. Formulas for this conversion are not hard to find.