Real-Time Rendering of Bumpmap Shadows Taking Account of Surface Curvature
Total Page:16
File Type:pdf, Size:1020Kb
Real-time Rendering of Bumpmap Shadows Taking Account of Surface Curvature Koichi Onoue Nelson Max Tomoyuki Nishita The University of Tokyo University of California, Davis The University of Tokyo 5-1-5 Kashiwanoha,Kashiwa, P. O. Box 808, L-560, 5-1-5 Kashiwanoha,Kashiwa, Chiba, Japan Livermore, CA 94551, U.S.A Chiba, Japan Phone: +81.4.7136.3946 Phone: +1.925.422.4074 Phone: +81.4.7136.3942 Fax: +81.4.7136.3943 Fax: +1.925.422.6287 Fax: +81.4.7136.3943 [email protected] [email protected] [email protected] Abstract faces cast by other objects [4]. Forsyth [5] used a three- dimensional texture to implement Max’s method in graph- The bump-mapping technique is often used to represent ics hardware. However his method did not take account of bumps on objects such as bark on trees and craters on the surface curvature. Shadows of the bumps on bump-mapped moon. In order to render shadows cast by bumps, the hori- surfaces are called bumpmap shadows in the rest of this pa- zon map method was proposed. The horizon map is a table per. which has, for each of a small collection of azimuthal direc- In this paper, we propose to render bumpmap shad- tions, slopes from each viewpoint on the bump map (height ows more precisely by taking account of surface curvature. field) to the corresponding horizon point, which is the high- When bump mapping is used, surfaces facing away from est viewable point seen from that viewpoint. In this paper, the light source are not lit, and the shading process is usu- we propose a more precise method for rendering bumpmap ally skipped. However if the bumps on a curved surface shadows using a both a horizon map and a distance map, are tall enough, parts of the bumps on the back-facing sur- to take curvature of surfaces into consideration. The dis- faces may be lit. Similar cases of the illumination of bumps tance map is a table which has, for each azimuthal direc- beyond the shadow terminator were considered by Koen- tion, horizontal projected distances from each point of the derink et al. [6]. The presentation of that paper inspired our bump map to its corresponding horizon point. The pro- implementation, which can render such effects in graphics posed method can render shadows efficiently by using pro- hardware using a programmable shader. grammable graphics hardware. The rest of this paper is organized as follows. First, re- keywords: shadows, bump-mapping, horizon map, curva- lated work is introduced in Section 2, and the extended algo- ture, graphics hardware rithm for horizon mapping is explained in Section 3. Ren- dering results of bumpmap shadows are shown in Section 4. Conclusions and future work are described in Section 5. 1 Introduction 2 Related Work In order to render realistic images, shadows are indis- pensable. In the field of computer graphics, many re- Max [3] proposed horizon mapping as a method of searchers still study shadow rendering methods [1]. On the adding a shadow effect to the bump mapping that Blinn [2] other hand, bump mapping [2], which is a method to repre- had proposed. The horizon map is a table, which has slopes sent and render bumps efficiently, is widely used. Further- from each viewpoint on the bump map (height field) to the more, since the performance of graphics hardware (GPU) highest point seen from that viewpoint. Shadows are cal- has increased rapidly, bump mapping can now be processed culated by comparing the slopes stored in the horizon map on the graphics hardware. There has also been previous with the slope of the ray to the light source. work on the shadows of bumps. Max [3] proposed the Sloan et al. [7] proposed a method to implement horizon horizon map to render shadows cast by bumps. Noma pro- mapping in graphics hardware. They store horizon map as posed a rendering method of shadows on bump-mapped sur- multiple two-dimensional textures indexed by the azmuthal angle, and render shadows by interpolating between the two used as in [2] to determine the bump shading, and all three appropriate textures using multiple rendering passes. Kautz tables are used for the bump shadows. et al. [8, 9] approximated, with an elliptical cone, the set of light directions which can illuminate each point of a bump 3.1 Local Curvature map. Shadows are rendered by detecting whether the light direction is included the elliptical cone. These methods The proposed method renders bumpmap shadows taking need multiple rendering passes, so rendering costs are high. account of surface curvature. Our method of calculating the The other method to represent bumps is displacement principal curvatures at a point is the same as the one used in mapping [10]. This method subdivides the surfaces of ob- Wang et al.’s paper [14]. jects and displaces the generated vertices. In order to ren- For each vertex, principal curvatures κ1,κ2 and principal der the shadows of the bumps, displacement mapping can directions ϕ1,ϕ2 on the (u, v) plane are calculated. The be combined with rendering methods for geometry-based vectors V1 and V2 on the surface in the principal directions shadows, such as the shadow map method [11, 12] and the are perpendicular on a curved surface, but their projections shadow volume method [13]. However, this subdivision are not always perpendicular on the (u, v) plane. Therefore, greatly increases the number of vertices and polygons, and in order to calculate the local curvature in a direction V therefore their associated access, transformation, and set- which is the projection of L onto tangent plane at P , the up costs in the graphics hardware. Wang et al. [14] pro- following method is used. posed a displacement mapping method without increasing First, we precompute V1 and V2 at each vertex of the the number of polygons. They store as textures visibility polygonal surface. Then V1 and V2 at P are calculated information for a height field seen from some sample di- at each pixel fragment by interpolation. After calculating rections, and do take some account of curvature. However cos ϕ =(V · V1)/(|V ||V1|) and sin ϕ =(V · V2)/(|V ||V2|), their method needs a lot of memory to store the textures. we use the following formula: Although they propose a compression method for the vis- 2 2 ibility information, the amount of memory consumption is κ = κ1 cos ϕ + κ2 sin ϕ. (1) still much greater than that of the horizon map. ϕ Forsyth [5] proposed a method to implement the hori- Note that need not be calculated, only the expressions cos2 ϕ sin2 ϕ zon map by using a three-dimensional texture, which is now and need to be calculated. These expressions cos ϕ sin ϕ supported by commodity graphics hardware. Bumpmap use squares of and , so the square root need not shadows can be rendered in one pass by his method, which be calculated when normalizing the vectors. That is, instead |V |, |V |, |V | |V |2, |V |2, |V |2 is simple and easy to implement. However, Forsyth’s of 1 2 , only 1 2 are calculated. R P V method does not consider the surface curvature of objects The radius of curvature at in direction , that is, so the shapes of the shadows are not accurate. the radius of curvature of the intersection curve of the plane P N L In this paper, we propose a method for rendering through including and , and the curved surface S(u, v) R =1/κ bumpmap shadows which is an extension of Forsyth’s , is given by . method and takes account of surface curvature. 3.2 Horizon Angles Taking Account of Curvature 3 Bumpmap Shadows The calculation of the horizon angle β taking account of curvature is considered in the following two cases. In this paper, as in Max [3], we use a local coordinate First, in the case shown in Fig. 2, the horizon angle is P ,P ,N/|N|1/2 P P system whose axes are u v . Here, u and v calculated by using the distance d to the horizon Q. Let are partial derivative vectors along texture coordinates, and H = d tan β be the difference of the height at Q and that at N = P × P L L u v. Let the light vector converted into this P (see Fig. 1). We calculate a decrease of the height at the θ L N ϕ coordinate system, be an angle between and , and horizon Q according to curvature of the surface as follows P L P ,P be an angle from u when is projected onto the ( u v) (see Fig. 2): plane. Forsyth implemented the horizon mapping by storing the d horizon map β(u, v, ϕ) as three-dimensional texture. Here, d = γR, γ = = κd we use in addition a distance map d(u, v, ϕ) storing hor- R γ izontal distances between the projections of S(u, v) and CA =2(R + h) sin Q 2 its horizon point , as shown in Fig. 1. In short, three γ γ γ h(u, v) BC = CAcos =2(R + h) sin cos tables are used: the bump map , the distance map 2 2 2 d(u, v, ϕ), and the horizon map β(u, v, ϕ). These tables are γ γ h(u, v) AB = CAsin =2(R + h) sin2 stored on the GPU memory as textures. The table is 2 2 2 bumped surface A h ’ h P bumped surface H R h+H d ’ R geometry PQ Q O Figure 1.