Environment Mapping Good for ? with the Help of Environment Mapping, an Object Can Reflect the Environment
Total Page:16
File Type:pdf, Size:1020Kb
Environment Mapping good for ? With the help of environment mapping, an object can reflect the environment. For that Simone Kriglstein texture mapping can be used. But some problems Günter Wallner are occurring. The problem how the textures are saved must be solved (i.e. to save memory). The second problem is that the calculation of mapping Abstract the 2-dimensional to 3-dimensional coordinates must be possible in a short time, so that these In this paper environment mapping is presented. techniques can be used in interactive applications. First we will discuss environment mapping in For parameterization three different kinds are general and the methods of parameterization like, existing. The most famous methods are spherical, sphere -, cubic –and parabolic maps. For sphere, cube and parabolic maps. We will discuss each of parabolic and cubic maps the way of indexing is the methods mentioned above and enumerate the shown. Then ways of prefiltering of environment advantages and disadvantages of those maps are shown. In detail we present how this can parameterizations. Since there are different kinds of be done with the Phong reflection model and how surfaces (wood, plastic,...) with different kinds of the Fresnel term can be used. In addition reflection properties (Figure 1.2 shows a very good environment mapping with the help of BRDF´s is example of reflection), these properties should be presented. Also environment mapped bump taken into account when generating an environment mapping (EMBM) will be discussed. In this chapter map. The reflection properties can be divided into we discuss mainly how the environment is mapped three parameters: diffuse, glossy and mirror. For on an object with a structured surface. In the last metallic surfaces a Fresnel term can be used. Those chapter an introduction into environment mapping properties are applied to the environment map in a with OpenGL is given. prefiltering step. For glossy surfaces we will explain the widely used Phong model. This model is physically not correct, because it makes some simplifications. But, it is simple and the quality is 1 Introduction good enough for most graphic applications. The aim of the game designer is to design games, which get more and more realistic and that can not be done without environment mapping. It has the appearance for everybody that this method is not so important. However, can you imagine a motor racing game in which the surroundings are not reflected on the car body (in Figure 1.1 you can see, how the surrounding is reflected on a bonnet) or a hero of an action game which does not have a reflection on the water. Modern 3D hardware accelerators are supporting a lot of gadgets, such as texture mapping, bump mapping, pixel shading, lighting effects, shadow mapping, T&L, environment mapping and so on. Games which are released know or in future are using these techniques to provide a realistic Figure 1.2 environment as possible. To get attention, new Reflection with environment mapping games have new and improved graphic effects. Things on that we do not concentrate in real life, We will also take a closer look on how to represent are missed immediately in games or other BRDF´s with environment mapping. A BRDF interactive applications. describes how much light is reflected when light Surfaces that are reflecting the environment, makes contact with the surface. correctly broken shadows and many other small In chapter 10 of the paper we will discuss things are making the game experience perfect. environment mapped bump mapping. These technique allows us to model surfaces with bumps. Examples of use are bark, metal sheet, scratch and so on. Figure 1.1 Car which reflects the environment In our paper we will discuss mainly environment mapping. But for what is environment mapping - 1 - Figure 2.1 Example of reflection with environment map What exactly is environment mapping now? Environment mapping [10] is used to reflect the surroundings on an object. Thus, an object must be covered with a texture of the real object surface as well as with the environment texture. A good example of environment mapping is shown in Figure 2.1. Environment mapping is a separate technique rather than as a category of texture mapping. This method was first developed by Blinn and Newell in 1976 Figure 1.3 [17]. Top: without bump mapping Bottom: with bump mapping Environment maps are particular textures that describe for all directions the incoming or outgoing Scenes can be represented more realistically by light at one point in space. environment mapped bump mapping (EMBM). This method is particularly used for water effect. Environment mapping [2] may be achieved through Figure 1.3 shows how a scene looks better when texture mapping in different ways. One way EMBM is used. requires six texture images, each corresponding to a The wall looks much more realistic with reflections face of a cube, that represent the surrounding and structures. The ground was also changed, it has environment. At each vertex of a polygon to be a structure at the lower picture. environment mapped, a reflection vector from eye In the last chapter environment mapping with off of the surface is computed. This reflection OpenGL is presented. vector indexes one of the six texture images. As long as all the vertices of the polygon generate reflections into the same image, the image is 2 Environment Mapping mapped onto the polygon using projective texturing. If a polygon has reflections into more „ Projection of the whole environment on a texture than one face of the cube, then the polygon is surface “ subdivided into pieces, each of which generates reflections into only one face. Because a reflection For us reflection effects are a normal thing and not vector is not computed at each pixel, this method is many people are thinking about this phenomena. not exact, but the same results are quite convincing But games without reflections are boring or bad. when the polygons are small. Reflections are making the games look realistic Another way is to generate a single texture image and exciting. of a perfectly reflecting sphere in the environment. This image consists of a circle representing the hemisphere of the environment behind the viewer, surrounded by an annulus representing the hemisphere in front of the viewer. At each polygon vertex, a texture coordinate generation function generates coordinates that index this texture image, and these are interpolated - 2 - across the polygon. If the (normalized) reflection 3 Parameterization vector at a vertex is r = (x y z) Equation 1 A parameterization is a mapping from directions to and texture coordinates. This mapping should meet m = 2(z +1) Equation 2 some properties in order to be useful in interactive rendering: then the generated coordinates are x/m and y/m • for walkthroughs of static environment, it when the texture image is indexed by coordinates should not be necessary to create a new map ranging from –1 to 1 (the calculation is diagrammed every frame in Figure 2.2). • it should be easy to create a new environment map from perspective images of the scene • calculating the texture coordinates should be easy and simple to implement in hardware Three methods which have gained some importance in hardware accelerated and interactive rendering are: spherical maps, cube maps and parabolic maps which will be explained in the following. 3.1 Spherical Environment Maps Spherical environment mapping (see [3,4,14]) is Figure 2.2 Spherical reflection geometry based on the analogy of a infinitely small, perfectly mirroring metal ball centered around the object. The distance between viewer and object is The environment map is the image that a important, because this is the reason for distortions. orthographic camera sees when looking at the ball Because there is a singularity in the viewing from a certain viewing direction. A sample of a direction, since all points where the viewing vector spherical map is shown in Figure 3.1.1. is tangential to the sphere show the same point of This kind of parameterization has two big environment. Moreover, the object can not reflect disadvantages. First, it is not suitable for viewing itself, because the calculations can not be directions other than the original one and second, it performed in real time. But, it is possible with ray tracing algorithms [16]. There are many different techniques for implementing environment mapping like cube mapping [see Figure 2.3, see also chapter 5 ], spherical mapping [ for more information about this method see chapter 4] and parabolic mapping [see chapter 6]. Figure 2.3 Example for cube environment mapping Figure 3.1.1 Top: Spherical environment map Bottom: Reflecting Teapot - 3 - does not reflect changes in the scene, as they happen. The major reason why spherical environment mapping is still used is, that the lookup can be calculated efficiently with simple operations in hardware. Also, they are good enough to create cheap static reflections which are in most cases good enough for game reflections. Now, how does this lookup process works ? In Figure 3.1.2 a image of the lookup process is shown. A spherical environment map which has been generated for a camera pointing in direction vo, stores the corresponding radiance information at the point where the reflective sphere has the normal Figure 3.1.4 Cross section of a sphere on which the environment is mapped h. If vo is the negative z- Axis then the 2D texture coordinates are the x –and y- axis of the normalized First the environment in which the reflective model halfway vector h. If the direction is close to the should be placed must be rendered as viewed from viewing direction distortions are likely to appear, the desired position of the model.