Real-Time Rendering Of Mesostructures - UNC Computer Science

2 downloads 5529 Views 3MB Size Report
... the award of the degree of Bachelor of Technology in Computer Science and Engineering, is a record of bona fide ... 2.2.2 Computing ray-mesostructure intersection . ..... The online part of the algorithm traverses the .... Results. The technique proposed has been implemented as a Shader Model 4.0 fragment program. All.
Real-Time Rendering Of Mesostructures

Ravish Mehra1 Indian Institute of Technology

Advisor : Dr. Subodh Kumar2

1 e-mail: 2 e-mail:

[email protected] [email protected]

Certificate

This is to certify that the project titled Real-Time Rendering Of Mesostructures being submitted by Ravish Mehra to the Indian Institute of Technology Delhi, for the award of the degree of Bachelor of Technology in Computer Science and Engineering, is a record of bona fide project work carried out by them under my guidance and supervision at the Department of Computer Science and Engineering, Indian Institute of Technology, Delhi.

Prof. Subodh Kumar Department of Computer Science and Engineering Indian Institute of Technology Delhi

i

Abstract

In this thesis, we describe an efficient technique for rendering rich geometric details (e.g., surface mesostructure) of complex surfaces. We use sphere-tracing aided by directional distance maps (DDMs) for quickly finding ray-mesostructure intersections. High accuracy is achieved by analytically detecting such intersections. Further, space requirement is kept low by adaptively sampling the distance field, and employing off-the-shelf hardware texture compression. Our rendering technique can handle complex detailed scenes containing mesostructures in real time with correct self-occlusion, self-shadow, interpenetrations and silhouettes. We demonstrate our algorithm on a variety of test scenarios.

ii

Acknowledgements

It has been a great privilege to work with our advisor, Prof. Subodh Kumar. I have benefited enormously from his knowledge and guidance. We also thank Prof. Niloy J. Mitra, Prof. Prem Kalra, and Prof. Subhashis Banerjee for their valuable feedback during the presentations. We are thankful to Mr. Kaliram R. Kaushik, in-charge of the Graphics and Vision Laboratory for his assistance in carrying out the project.

Ravish Mehra Department of Computer Science and Engineering Indian Institute of Technology, Delhi

iii

Contents 1

Introduction 6 1.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2 Existing techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.3 Report Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2

Technique and Modules 2.1 Review: Sphere tracing using distance map. . . . . . . . . . . . . . . . . . . 2.2 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Data structure : Directional Distance Map with Surface Approximation parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.2 Computing ray-mesostructure intersection . . . . . . . . . . . . . . . 2.3 Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.1 Quality improvement. . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.2 Faster convergence and better Silhouettes. . . . . . . . . . . . . . . . 2.3.3 Only a few directions can produce vast improvement. . . . . . . . . .

11 . 11 . 12 . . . . . .

13 14 15 15 16 16

3

Distance map compression 17 3.1 Compression Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4

Detail based LOD 19 4.1 LOD Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.2 Speed Improvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

5

Results 5.1 Text Demo . . . . . . . . 5.2 Bunny and Shape Demo 5.3 Maze demo . . . . . . . 5.4 Performance Comparison 5.5 LOD demo . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

1

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

21 21 22 22 23 23

5.6 6

Compression Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Conclusions and Future Work

25

2

List of Figures 1.1 1.2

2.1

2.2 2.3 2.4

Block artifacts caused by discrete distance map. . . . . . . . . . . . . . . . . . Sphere tracing near mesostructure boundaries. Due to local surface details or roughness, sphere tracing can take only small steps resulting in slow progress. . Sphere tracing algorithm steps. If any outside point pi is at a distance d from the surface, then for any ray direction r we can proceed to p + dr without missing any surface intersection. . . . . . . . . . . . . . . . . . . . . . . . . Directional distance maps for the 2D case . . . . . . . . . . . . . . . . . . . Comparison between a) Sphere tracing b) Sphere tracing + parametric intersection with closeups shown for better comparion. . . . . . . . . . . . . . . . . Faster convergence of DDM near mesostructure boundary. . . . . . . . . . .

8 9

. 12 . 14 . 15 . 16

3.1 3.2

Original DDMs in uncompressed state . . . . . . . . . . . . . . . . . . . . . . 18 Original DDMs in compressed state using common LOOKUP GRID and TEXTURE ATLAS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.1

Detail based LOD scheme: Left: Rendered without LOD scheme at 48fps. Right: Rendered at 78 fps. Finely detailed areas using a higher resolution(marked by red) DDM followed by successively lower detailed areas using low resolution DDMs(marked as yellow, purple, white in decreasing order). Smaller figures on bottom shows number of iterations ranging from low to high in color order of blue, green, red, yellow, white respectively. . . . . . . . . . . . . . . 20

5.1

Quality comparison a) Top: Rendered using Sphere tracing with Distance map b) Bottom: Rendered using DDMs with parametric approximation . . . . . . . 21 Left: Bunny rendered as a non-height field mesostructure on a flat polygon, a 3D imposter effect. Right: Shapes demo - Sphere tracing with DDM and parametric intersection : note the absence of artifacts present in Figure 1.1. . . 22

5.2

3

5.3

5.4

Siggraph Asia scene with a non-height field spherical ball moving in a height field maze rendered at 145 FPS with screen resolution 1024×768 using a directional distance map (DDM) of resolution with 8×2 direction cones. Parametric approximation is done at 128 × 128 resolution. . . . . . . . . . . . . . . . . . 22 Detail based LOD scheme: Left: Rendered without LOD scheme at 24fps. Right: Rendered at 40 fps. We show the number of iterations ranging from low to high in color order of blue, green, red, yellow, white respectively. . . . . . . 23

4

List of Tables 2.1

Performance(in FPS) improvement for Sphere tracing with DDMs with varying number of directional cones. Bunny and buddha demos use DDMs at resolution of 256 × 256 × 64 whereas Shape and Maze demo are at 128 × 128 × 32. Screen resolution of 1024 × 768 is chosen. Direction cone 1 × 1 row denotes performance of sphere tracing with distance map. . . . . . . . . . . . . . . . . 16

5.1

Performance(in FPS) comparison for Sphere tracing with DDMs, & Sphere tracing with DDMs and Quadric Parametric Intersection by varying number of DDM directional cones. Screen resolution chosen is 1024 × 768 and DDMs are calculated at resolution 1282 × 32. Figure 5.3 shows the test scene . . . . . . . 23 Compression efficiency of DDMs with varying number of directional cones. Bunny and buddha use DDMs of resolution 2562 × 64. Screen resolution of 1024 × 768 is chosen. Lookup grid resolution chosen is 41 × texture resolution in each dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Compression efficiency of DDMs with varying number of directional cones. Golden maze ball and Shape demo use DDMs of resolution 1282 × 32. Screen resolution of 1024×768 is chosen. Lookup grid resolution chosen is 41 × texture resolution in each dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

5.2

5.3

5

Chapter 1 Introduction 1.1

Problem Statement

Displacement mapping [3] is a powerful and popular technique for adding rich geometric detail to surfaces to obtain realistic images. While traditionally displacements are restricted along surface normals, more general displacements can be used for even richer effects. We generally classify such surface details into microstructures, mesostructures and macrostructures. Microstructures are small details, and can be satisfactorily approximated by bump mapping [2], or normal maps, or even standard texture maps. Traditional displacement maps [3], or height fields can represent macrostructures. Mesostructures are fine scale geometric details on the surface which are smaller than macrostructures but larger than microstructures. They are generally non-height fields which can significantly alter shadows, occlusion and silhouettes. One way to render such details is to tessellate the surface and modify the geometry to include the detail. This tends to be rather inefficient due to the large number of micropolygons generated. As a result, per-pixel computation of detail has recently become popular. Height maps can be represented using 2D texture maps [17, 11, 8]. For efficient rendering, additional lower-resolution maps [16] are sometimes employed. Non-height map structures, on the other hand, require 3D texture maps [18, 4] to represent them, becoming memory limited. Still, the richness of this representation makes it attractive. The focus of this paper is on accurate, fast, and memory-efficient rendering of mesostructures – and, in general, any model represented as a distance field. Such 3D fields have even been used to represent entire geometry [6]. The basic algorithms for hardware assisted rendering of height field as well as non-height field

6

mesostructures are similar. We generate fragments by using one or more quadrilaterals covering the detailed geometry on screen. Subsequently, for each pixel, we modify its color (and depth) by intersecting the ray from the eye to that pixel with the detailed geometry. The differences among the algorithms lie primarily in the intersection computation – in particular, marching along the ray until an intersection is found. Such intersection computation is employed in other applications including per-pixel terrain rendering and GPU assisted ray-tracing. Broadly, GPU based ray object intersection algorithms employ two strategies. They attempt to bracket intersection between two ray points and then search for the root using techniques like bisection [11] or the secant method [12]. This process of bracketing intersection requires a non-robust and inefficient linear stepping which introduces various artifacts and missed intersections. Space skipping techniques [4, 1], on the other hand, use pre-computed data structures to store “safety regions," where no intersection is possible. The search of the intersection then proceeds by marching along the ray, skipping successive safety regions. In contrast to the bracketing algorithms, these region skipping algorithms converge rather slowly near the surface and may never find the exact intersection. We base our algorithm on the sphere tracing technique [4] to skip past areas of no intersection. The original idea of this technique is to sample the safety radius at a 3D regular grid, and use 3D textures to store these radii. The main drawback of this technique lies in the high memory requirement in storing the 3D texture1 and the strong dependence of rendering quality on the texture resolution. Furthermore, sampling of the distance map at discrete locations introduces noticeable aliasing artifacts as highlighted in Figure 1.1. We present an algorithm that addresses these drawbacks. In particular, we make the safety regions conservative in order to improve accuracy. We also decompose them into view directionspecific regions (cf. [18]), thus ensuring significantly faster convergence. Further we improve the accuracy of the approach by performing exact geometric intersection tests. Finally, to address the memory requirements we make the directional distance maps multi-resolution, storing detail only where necessary thus providing a new detail based LOD approach. We lay out the texture into an atlas in a memory coherent manner. Furthermore, this organization is able to effectively take advantage of hardware texture compression. The main contributions of this work include: • A viewing direction dependent sphere tracing technique which converges to the intersection point in fewer iterations. • An efficient parametric surface approximation technique that finds accurate intersection point resulting in significant improvement in rendering quality. 1

Recall that algorithms employing 2D textures are unable to render non-height maps.

7

Figure 1.1: Block artifacts caused by discrete distance map. • A novel detail based hardware friendly LOD approach that boosts the overall rendering performance.

1.2

Existing techniques

Mesostructures can be classified as either height field or non-height field. In recent years, significant research effort has been given to their rendering, and various techniques have been proposed to render both types of mesostructures. We first discuss the height field case: Relief mapping [11] employs a two step intersection algorithm, which first performs a linear search to find a point inside the height field, and then converges to the final intersection using a mid-point binary search. Other variants of this technique replace the binary search in the second step with convergence using tangents, secants [12], or piecewise linear curve approximation [15]. The overall quality and performance of this method depends on the step size chosen in the linear step. For smaller step size we get better rendering quality, but at the cost of reduced performance. On the other hand, with larger step sizes we can miss small features thus compromising on quality. [8] used maximum mipmapped height maps to move from cell to cell skipping empty regions to reach the intersection point. [15] switched to a bump mapping if the distance between intersection point and viewer exceeded some threshold value. [16] further improved this approach by providing a distance based LOD approach to truncate the height field hierarchy traversal based this distance. All these techniques are characterized by smaller pre-processing time and 8

use of 2D textures, but are limited to only height field rendering. We now come to the non-height field case: Policarpo and Oliveira [10] extended the traditional relief mapping for the non-height field mesostructures by using multi-layered relief maps and performing the intersection computation parallelly on the GPU. However, the aliasing artifact due to linear search still remains. Generalized displacement maps (GDM) [18] uses a five dimensional displacement map, which stores for each sample point (x, y, z) the minimum distance to the mesostructure in various sampled directions (θ, φ). This technique can be used to render non-height field mesostructures and converges quickly providing interactive rendering speed. However, the costs include an exorbitantly large dataset (5D GDM) and a large pre-processing time. To reduce the size of the texture memory for this 5D data, lossy compression based on singular value decomposition is employed. However, the decompression algorithm is not hardware friendly, and suffers from incoherent memory accesses. Since GDM is calculated at a pre-computed sampling of (θ, φ), it does not support arbitrary close-up views. Finally, the rendered quality suffers due to relatively low sampling imposed by high dimensionality, inaccurate intersection computation, and lossiness of the compression. Cone-step mapping proposed by [5] uses a cone, instead of a sphere, as a measure of safety volume in order to find the ray-height field intersection. However, this approach requires a large pre-processing time.

Figure 1.2: Sphere tracing near mesostructure boundaries. Due to local surface details or roughness, sphere tracing can take only small steps resulting in slow progress.

9

1.3

Report Overview

Our report is organized as follows: In Chapter 2, we present our main algorithm and its various improvements over other techniques. We describe the distance map compression in Chapter 3 followed by LOD scheme in Chapter 4. We present results in Section 5, and conclude in Section 6.

10

Chapter 2 Technique and Modules We first review the basic sphere tracing algorithm that our algorithm is based on.

2.1

Review: Sphere tracing using distance map.

Sphere tracing was first proposed by [7] for accelerating ray-surface intersection for ray-tracing of implicit surfaces. The main idea is simple: If the nearest surface-point from a given point p outside any object is at a distance d, any ray in unit direction r passing through p is ensured of no surface intersection before point p + dr. Hence, p can then be advanced to p + dr, and the process repeated. Figure 2.1 explains the steps of the algorithm. Donnelly [4] extended this approach for rendering displacement-mapped mesostructures on surfaces using a 3D texture that stores the distance to the closest surface-point from the center of each voxel. The method is more efficient if applied in the local tangent space [9] of arbitrary geometry. The main drawbacks of this method are as follows: a) The quality of rendering achievable by this method is sensitive to the resolution of the 3D texture used for storing the distance function. For achieving high rendering quality, we require dense sampling, and thus a large texture memory. b) For points close to the mesostructure, especially near silhouettes, the method progresses too slowly due to smaller values of distance function (see Figure 1.2). c) The ray-marching must be stopped once the safety radius is zero (or small). A point in the resulting voxel is then chosen as the point of intersection. However, there may not actually be an intersection in that voxel. This causes severe artifacts near silhouettes (see Figure 1.1). 11

Figure 2.1: Sphere tracing algorithm steps. If any outside point pi is at a distance d from the surface, then for any ray direction r we can proceed to p + dr without missing any surface intersection. Distance function defined in this manner for rendering height field mesostructures can easily be employed for non-height field mesostructures as well. This ability to render both types of mesostructures, along with recent improvements in algorithms to compute distance-fields [14, 13] and increasing GPU memory, makes this method an attractive rendering technique.

2.2

Algorithm

There are two main steps to our algorithm. In the preprocessing step, a multi-resolution directional distance field is created and stored in a 3D texture atlas. The online part of the algorithm traverses the data structure to a leaf node. (This traversal can be pruned for nodes that are small on the screen to improve the speed further.) Once a voxel with the intersection is located, the actual intersection is computed by an approximate ray-bilinear patch intersection algorithm. Finally the fragment is shaded by the color of the point of intersection. Shadows can be further computed by tracing a ray from the point of intersection to the light. Listed below are the steps in each part.

12

2.2.1

Data structure : Directional Distance Map with Surface Approximation parameters

A Directional Distance Map(DDM) is a 3D dataset that is computed along a voxel grid in texture space, and for each voxel p stores the minimum distance from p to the nearest point of the mesostructure in a given viewing direction cone. It is the similar to the original distance map defined in [4] but with constraints on the possible viewing direction and computed conservatively. Conservative computation means that the distance stored at a voxel is not that of the nearest point from its center, but to the nearest point from anywhere within the voxel. We divide the spherical angles (θ, φ) covering the entire space into smaller intervals forming directional cones. Distance map is calculated along each of these directional cones separately. For any voxel ~p(x, y, z) in the texture space, mesostructure M and directional cone with spherical angles in range [θ1 θ2 ] × [φ1 , φ2 ], DDM is defined as: DDM(~p, [θ1 , θ2 ], [φ1 , φ2 ]) = min{d(~q, ~p) ∀~q ∈ M, st.(~q − ~p) lies inside angular cone([θ1 , θ2 ] × [φ1 , φ2 ])}. Notice that for voxels which have a mesostructure surface passing through them, the DDM value is zero. For such voxels, we approximate the surface patch passing through each voxel with either a plane or a quadratic surface. Parameters of this approximation are stored in a 2D texture called parameter map, and passed onto the GPU during the rendering stage. The equations chosen for the approximation are: Z = Ax + By + C for plane, or, Z = Ax2 + By 2 + Cxy + Dx + Ey + F for quadric surface where the approximation is made using least squares fitting. DDMs are organized as several 3D textures stored in a texture atlas in a coherent manner which allows us to use hardware texture compression. The overall texture memory is managed by our novel distance map compression scheme explained later. It is worth noting that only a few directions suffice. Any more sampling in the directions leads to diminishing returns. Also note that a ray only needs to access a single direction’s texture. Moreover, there is coherence in directions of rays from pixel to pixel. As a result the DDMs memory access pattern is highly coherent. The property of the leaf nodes in the multi-resolution tree is that there is a single bilinear patch inside it. 13

Figure 2.2: Directional distance maps for the 2D case

2.2.2

Computing ray-mesostructure intersection

We start by first rendering the bounding box for the detailed mesostructure geometry. For each fragment f generated by this process with a texture coordinate say t1 , we trace a ray in the viewing direction r as follows: Algorithm 1 Sphere Tracing using DDM with Approximation Parameters 1: dir_cone = CONE(r) 2: for i = 0 to N U M do 3: d = DDM(dir_cone, ti ) 4: if d = 0 then 5: if PARAM_INTERSECTION(r, t) = true then 6: exit 7: else 8: t = WALL_INTERSECTION(r, t) 9: else 10: t = t + dr 11: Use t for accessing the color texture, normal texture etc In the sphere tracing step, we first determine the direction cone in which the viewing ray belongs. This step needs to be done only once in the beginning. We access the corresponding DDM to find the safety radius d in the viewing direction cone. If this safety radius is non-zero we move by the distance d in the direction r. Otherwise, if d = 0, we have reached a voxel through which the mesostructure surface passes and we need to perform the analytical rayparametric surface intersection to see if the ray hits the mesostructure surface. If it evaluates to TRUE we exit the loop, and use this intersection point for shading. Else, we will hit the walls 14

of that voxel and start sphere tracing from that point again. Note that Donnelly’s [4] distance map based algorithm will exit when d = 0, making the accuracy of the result dependent upon the resolution of the distance map texture.

2.3

Improvements

Benefits of this approach are straightforward.

2.3.1

Quality improvement.

Since the distance map is based on sampling, the details that are finer than sampling resolution are difficult to capture using distance map alone. To improve rendering quality, we have proposed a parametric surface approximation and intersection approach. Figure 2.3 compares the rendering quality of sphere tracing alone with that of sphere tracing followed by parametric surface intersection . It is clearly visible that our approach removes the artifacts caused due to sampling error of the discretised distance map. While doing the surface fitting, parametric surface approximation does the appropriate smoothening by itself, thereby removing the need of approximate techniques like bilinear interpolation for magnification as given in [8]

Figure 2.3: Comparison between a) Sphere tracing b) Sphere tracing + parametric intersection with closeups shown for better comparion.

15

2.3.2

Faster convergence and better Silhouettes.

With DDMs we are not limited by regions outside our viewing-direction cone. For places near the boundary of the mesostructures, DDMs perform better than distance maps for the same number of iterations. Since the ray near the boundary comes close to mesostructure, the sphere tracing algorithm is slowed by the smaller distance map values, even when the ray has crossed the mesostructure (see Figure 1.2). But as Figure 2.4 shows, DDMs only consider the mesostructures in the viewing-direction cone, ignoring those that have already passed and can have no intersection.

Figure 2.4: Faster convergence of DDM near mesostructure boundary.

2.3.3

Only a few directions can produce vast improvement.

Table 2.1 show that using only a few direction cones can increase the performance significantly.

1×1 2×2 4×2 8×2

Bunny 757 912 953 1035

Buddha Shapes demo Maze demo 772 140 230 890 149 280 932 155 282 960 157 290

Table 2.1: Performance(in FPS) improvement for Sphere tracing with DDMs with varying number of directional cones. Bunny and buddha demos use DDMs at resolution of 256 × 256 × 64 whereas Shape and Maze demo are at 128 × 128 × 32. Screen resolution of 1024 × 768 is chosen. Direction cone 1 × 1 row denotes performance of sphere tracing with distance map.

16

Chapter 3 Distance map compression One important shortcoming of 3D texture based rendering techniques is large memory requirement. To counter it, these techniques propose compression schemes which are either lossy, causing reduced rendering quality, or induce incoherent memory accesses, which are not hardware friendly and hence slow. We propose a new compression scheme for our distance field data which addresses both these drawbacks.

3.1

Compression Technique

In this approach, we first construct a low resolution 3D lookup grid in the same texture space as the distance map. For each cell of this lookup grid, we find distance map voxels lying inside this cell and calculate their minimum value. If it is non-zero, we store this minimum value at this cell location. Otherwise if it is zero, we store all the voxels of the distance map inside this cell in the texture atlas starting at location (x,y,z) and store this location in the grid cell. Therefore the texture atlas stores distance map voxels of only those cells which have a mesostructure surface passing through them (min value 0) achieving compression. Figure 3.1 and 3.2 explains it intuitively. Tables 5.2 & 5.3 give the compression efficiency we get with this scheme on our data. In sphere tracing, we replace DDM access with two level access of lookup table and texture atlas. For cells that don’t have a mesostructure surface passing through them, we store the minimum value. It makes this scheme conservative thus preventing any missed intersections caused due to inaccurate linear interpolation at low resolution. And for cells that have a mesostructure surface passing through them, we first access the texture atlas location from the lookup grid and then using this location, access the corresponding voxel from the atlas.

17

Figure 3.1: Original DDMs in uncompressed state

Figure 3.2: Original DDMs in compressed state using common LOOKUP GRID and TEXTURE ATLAS.

18

Chapter 4 Detail based LOD Details present on the mesostructure surface are spatially varying. There are areas which are highly detailed and there are some which are flat. For correctly rendering the high detail areas both the distance map and the surface approximation parameters needs to be at high resolution. But for flat areas, we can get away with using a much lower resolution distance and parameter map. We exploit this to further reduce the total texture memory required and propose a novel detail based LOD approach which decides the resolution based upon the detail present.

4.1

LOD Approach

In this approach, we hierarchically subdivide the voxels (of texture space) in regions of high detail if required. If the mesostructure within a voxel can be well approximated by a bi-linear patch, it need not be subdivided. We compute error maps to decide when a set of voxels can be well approximated by a bi-linear patch. Error maps are created from parameter maps at various resolutions by calculating the difference in the surface patches between consecutive resolutions. These provide the total error incurred if we stop sphere-tracing and switch to parametric intersection at that resolution. Our detail based LOD approach uses the DDMs and parameter maps at appropriate resolution such that the total error is small and bounded. We compute error maps to decide when a set of voxels can be well approximated by a bi-linear patch. Denote volume covered by surface patch Sij created by parameter map at level i as Vol(Sij , i) and error map at level i as ErrorM aplodi . For surface patch Si,j , ErrorM aplodi (Si,j ) =

19

ErrorM aplodi+1 (S2i,2j ) + ErrorM aplodi+1 (S2i+1,2j ) + ErrorM aplodi+1 (S2i,2j+1 ) + ErrorM aplodi+1 (S2i+1,2j+1 ) + V ol(Si,j , i) − {V ol(S2i,2j , i + 1) + V ol(S2i+1,2j , i + 1) + V ol(S2i+1,2j+1 , i + 1) } This error map stores the cumulative error at each level i.e. the total error incurred with respect to the parameter map at higher resolution. In the original compression scheme, for a grid cell which had mesostructure surface passing through it, we stored all the voxels (of highest resolution) of the grid cell in the texture atlas. But now these voxels are stored at an appropriate resolution decided by error maps giving us increased compression efficiency.

4.2

Speed Improvement

Our level of detail method finds an approximate intersection. However, that approximation is appropriate for the region with that detail. This error is relatively small. Figure 4.1 and 5.4 shows the speed-up obtained by incorporating LOD. The speed-up clearly depends on the detail variation on the mesostructure surface.

Figure 4.1: Detail based LOD scheme: Left: Rendered without LOD scheme at 48fps. Right: Rendered at 78 fps. Finely detailed areas using a higher resolution(marked by red) DDM followed by successively lower detailed areas using low resolution DDMs(marked as yellow, purple, white in decreasing order). Smaller figures on bottom shows number of iterations ranging from low to high in color order of blue, green, red, yellow, white respectively.

20

Chapter 5 Results The technique proposed has been implemented as a Shader Model 4.0 fragment program. All the timings given in the paper(including the video) were produced on Intel PentiumD 3.4GHz machine with 2 GB RAM and Geforce 8800 GTS GPU. In the accompanying video, we have compared the previously proposed technique of sphere tracing using distance maps with our proposed DDM technique. We also compare the quality of the results achievable by both the techniques. Our method converges much faster near the mesostructure boundary with improved accuracy.

5.1

Text Demo

Figure 5.1: Quality comparison a) Top: Rendered using Sphere tracing with Distance map b) Bottom: Rendered using DDMs with parametric approximation

21

5.2

Bunny and Shape Demo

Figure 5.2: Left: Bunny rendered as a non-height field mesostructure on a flat polygon, a 3D imposter effect. Right: Shapes demo - Sphere tracing with DDM and parametric intersection : note the absence of artifacts present in Figure 1.1.

5.3

Maze demo

Figure 5.3: Siggraph Asia scene with a non-height field spherical ball moving in a height field maze rendered at 145 FPS with screen resolution 1024 × 768 using a directional distance map (DDM) of resolution with 8 × 2 direction cones. Parametric approximation is done at 128 × 128 resolution.

22

5.4

Performance Comparison

Maze scene

(θ × φ)

ST + DDM

1x1 2x2 4x2 8x2

230 220 282 290

ST + DDM + Quadric 135 140 145 145

Table 5.1: Performance(in FPS) comparison for Sphere tracing with DDMs, & Sphere tracing with DDMs and Quadric Parametric Intersection by varying number of DDM directional cones. Screen resolution chosen is 1024 × 768 and DDMs are calculated at resolution 1282 × 32. Figure 5.3 shows the test scene

5.5

LOD demo

Figure 5.4: Detail based LOD scheme: Left: Rendered without LOD scheme at 24fps. Right: Rendered at 40 fps. We show the number of iterations ranging from low to high in color order of blue, green, red, yellow, white respectively.

23

5.6

Compression Efficiency Uncompressed

1×1 2×2 4×2 8×2

2562 × 64 4 MB 2562 × 128 8 MB 2562 × 256 16 MB 2562 × 512 32 MB

Compressed LOOKUP

Bunny ATLAS

642 × 16 0.1875 MB 642 × 32 0.375 MB 642 × 64 0.75 MB 642 × 128 1.5 MB

1282 × 16 0.25 MB 642 × 64 0.25 MB 1282 × 32 0.5 MB 1282 × 64 1 MB

Compr. LOOKUP Efficiency 1/9.14 642 × 16 0.1875 MB 1/12.8 642 × 32 0.375 MB 1/12.8 642 × 64 0.75 MB 1/12.8 642 × 128 1.5 MB

Buddha ATLAS

Compr. Efficiency 1/12.8

1282 × 8 0.125 MB 642 × 64 1/12.8 0.25 MB 1282 × 32 1/12.8 0.5 MB 1282 × 64 1/12.8 1 MB

Table 5.2: Compression efficiency of DDMs with varying number of directional cones. Bunny and buddha use DDMs of resolution 2562 × 64. Screen resolution of 1024 × 768 is chosen. Lookup grid resolution chosen is 14 × texture resolution in each dimension Uncompressed

1×1 2×2 4×2 8×2

1282 × 32 0.5 MB 1282 × 64 1 MB 1282 × 128 2 MB 1282 × 256 4 MB

Compressed Golden ball Maze scene LOOKUP ATLAS Compr. Efficiency 2 2 32 × 8 16 × 8 1/20 0.023 MB 0.002 MB 322 × 16 162 × 16 1/19.6 0.047 MB 0.004 MB 322 × 32 162 × 32 1/19.6 0.094 MB 0.008 MB 322 × 64 322 × 16 1/19.6 0.187 MB 0.016 MB

LOOKUP

Shape demo ATLAS

322 × 8 0.023 MB 322 × 16 0.047 MB 322 × 32 0.094 MB 322 × 64 0.187 MB

1282 × 8 0.125 MB 642 × 64 0.25 MB 1282 × 32 0.5 MB 1282 × 64 1 MB

Compr. Efficiency 1/3.37 1/3.36 1/3.37 1/3.37

Table 5.3: Compression efficiency of DDMs with varying number of directional cones. Golden maze ball and Shape demo use DDMs of resolution 1282 × 32. Screen resolution of 1024 × 768 is chosen. Lookup grid resolution chosen is 41 × texture resolution in each dimension

24

Chapter 6 Conclusions and Future Work We have presented an efficient and accurate technique for rendering both height field and nonheight field mesostructures. With this, we have been able to achieve artifact-free high quality rendering. Our compression algorithm has considerably reduced the overall memory requirement and brought it under manageable limits. We have also proposed a novel detail based hardware friendly level of detail(LOD) scheme to boost the overall performance. For future work, we would like to extend our surface approximation algorithm for non-parametric mesostructure surfaces. We also want to look into better methods of arranging 3D texture voxels in the texture atlas. Another direction would be to investigate applicability of distance based LOD schemes in our approach.

25

Bibliography [1] Lionel Baboud and Xavier Décoret. Rendering geometry with relief textures. In Graphics Interface ’06, 2006. [2] James F. Blinn. Simulation of wrinkled surfaces. 12(3):286–292, 1978.

SIGGRAPH Comput. Graph.,

[3] Robert L. Cook. Shade trees. SIGGRAPH Comput. Graph., 18(3):223–231, 1984. [4] William Donnelly. Per-pixel displacement mapping with distance functions. GPU Gems 2, 22(3):123–136, 2005. [5] Dummer. Cone step mapping: An iterative ray-heightfield intersection algorithm. 2006. [6] Sarah F. Frisken, Ronald N. Perry, Alyn P. Rockwood, and Thouis R. Jones. Adaptively sampled distance fields: a general representation of shape for computer graphics. In SIGGRAPH, pages 249–254, 2000. [7] J. C. Hart. Sphere tracing: A geometric method for the antialiased ray tracing of implicit surfaces. The Visual Computer, 12(10):527–545, 1996. [8] Kyoungsu Oh, Hyunwoo Ki, and Cheol-Hi Lee. Pyramidal displacement mapping: a gpu based artifacts-free ray tracing through an image pyramid. In VRST ’06: Proceedings of the ACM symposium on Virtual reality software and technology, pages 75–82, 2006. [9] Mark Peercy, John Airey, and Brian Cabral. Efficient bump mapping hardware. In SIGGRAPH ’97: Proceedings of the 24th annual conference on Computer graphics and interactive techniques, pages 303–306, New York, NY, USA, 1997. ACM Press/AddisonWesley Publishing Co. [10] Fabio Policarpo and Manuel M. Oliveira. Relief mapping of non-height-field surface details. In I3D ’06: Proceedings of the 2006 symposium on Interactive 3D graphics and games, pages 55–62, New York, NY, USA, 2006. ACM.

26

[11] Fábio Policarpo, Manuel M. Oliveira, and ao L. D. Comba Jo˙ Real-time relief mapping on arbitrary polygonal surfaces. In I3D ’05: Proceedings of the 2005 symposium on Interactive 3D graphics and games, pages 155–162, New York, NY, USA, 2005. ACM. [12] Eric A. Risser, Musawir A. Shah, and Sumanta Pattanaik. Interval mapping. Technical report, University of Central Florida, 2005. [13] Avneesh Sud, Naga Govindaraju, Russell Gayle, and Dinesh Manocha. Interactive 3d distance field computation using linear factorization. In I3D ’06: Proceedings of the 2006 symposium on Interactive 3D graphics and games, pages 117–124, New York, NY, USA, 2006. ACM. [14] Avneesh Sud, Miguel A. Otaduy, and Dinesh Manocha. Difi: Fast 3d distance field computation using graphics hardware. Comput. Graph. Forum, 23(3):557–566, 2004. [15] Natalya Tatarchuk. Dynamic parallax occlusion mapping with approximate soft shadows. In I3D ’06: Proceedings of the 2006 symposium on Interactive 3D graphics and games, pages 63–69, 2006. [16] Art Tevs, Ivo Ihrke, and Hans-Peter Seidel. Maximum mipmaps for fast, accurate, and scalable dynamic height field rendering. In I3D ’08: Proceedings of the 2008 symposium on Interactive 3D graphics and games, pages 183–190, 2008. [17] Lifeng Wang, Xi Wang, Xin Tong, Stephen Lin, Shimin Hu, Baining Guo, and HeungYeung Shum. View-dependent displacement mapping. ACM Trans. Graph., 22(3):334– 339, 2003. [18] Xi Wang, Xin Tong, Stephen Lin, Shimin Hu, Baining Guo, and Heung-Yeung Shum. Generalized displacement maps. Computer Graphics Forum, 22(3):334–339, 2004.

27