Professional Documents
Culture Documents
5
ISSN: 1828-6003
Abstract – The technique of cone tracing, used for rendering very detailed surface in real-time,
is certainly among the best techniques at the present time. But unfortunately, in its two versions,
conservative and relaxed, this technique suffers from a heavy pre-processing having a quadratic
complexity. Moreover, the processing of non-square textures remains a problem. In this article we
introduce a new linear complexity algorithm for generating relaxed cone maps. Additionally, we
propose to use the Height Distributional Distance Transform HDDT for creating conservative
cone maps. The HDDT is a linear algorithm used in terrain rendering. We also introduce a new
method for supporting non-square textures using an elliptical rectification. Finally, we suggest
using the cones’ radius instead of their ratio. This eliminates the constraint limiting the cones’
apex angle to π/4 which significantly improves the performance of the cone tracing technique.
Nomenclature
r r
V , V xy vector, sub-vector
Vx ,V y ,V z vector components
r r
V the Euclidean norm of V
Fig. 1. Image (a) represents a plan with texture mapping. Image (b)
dist e ( p, q ) the Euclidean distance between p and q shows the combination with per-pixel displacement mapping. As we
can notice, in both images, the mesh density is the same, but the
displacement mapping allows rendering very detailed geometry.
I. Introduction
can be used to store other data used in some techniques
Per-pixel displacement mapping is an approach like cone tracing. In that case the displacement map may
stemmed from the texture mapping. It is used to add be named according to its technique as, for example, the
very fine scale to polygonal meshes without increasing cone map.
their density (i.e. number of vertices and triangles) (see
Fig. 1). This technique allows rendering scenes with rich
visual effects while avoiding the bottleneck problem I.2. Tangent Space
caused by the huge number of data to be submitted to The tangent or TBN space (Tangent, Binormal, and
the graphics card. Normal) is a local modeling space attached to each
The displacement mapping technique is based on vertex of the mesh. This particular space is built
three main principles: the displacement map, tangent according to the normal of vertices and their texture
space and inverse ray tracing. coordinates. During the rendering stage, the tangent
space is interpolated for each fragment. TBN space is
very useful since the normals stored in the displacement
I.1. The Displacement Map map are naturally expressed in this space and it may be
The displacement map, also known as height map or very costly to transform each normal to another
depth map, is a two-dimensional image whose pixels are coordinate system. However, the lights and view vectors
not used to store colors but several data, to be specific, must be expressed in this space too.
depths and normals. The depths of the relief to be
mapped onto the 3D surface are often placed in the I.3. Inverse Ray Tracing
alpha channel. The other three channels: red, green and
blue are used to store the three coordinates x, y, and z of The main problem of the displacement mapping
the normals calculated from depths. But as the z technique is illustrated in Fig. 2. It lies in finding the
coordinate can be found from the two others, its channel first intersection point of the viewing ray with the
Manuscript received 5 Aug. 2008, revised 16 Oct. 2008 Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved
A. Halli, A. Saaidi, K. Satori, H. Tairi
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
the idea of using per-Pixel (i.e. inverse) displacement correct, smooth and optionally curved shell mapping.
mapping. View-Dependent Displacement Mapping [29] and
Relief mapping [14], an extended technique of relief Generalized Displacement Mapping [30] do a pre-
texture mapping [15], performs an image space search to process shell space ray tracing and store the result as a
find the intersection point between the viewing ray and a five-dimensional function that can be queried during
2D depth map. It begins with a linear search using rendering time. These methods produce very nice results
regular intervals followed by a binary search to refine but require significant pre-processing and storage to
the intersection point. This technique correctly handles operate.
self-occlusions, shadows and inter-penetrations.
However some artefacts become visible at grazing
angles, especially with thin structures. Similar III. Cone Tracing
approaches to relief mapping were presented in [16], To find the first intersection between the viewing ray
[17], [18] and [19]. and the depth field surface, some techniques use unsafe
Instead of using unsafe approach, Donnelly [20] uses approaches (i.e. linear, binary or secant search).
sphere tracing. He creates a 3D distance map that gives Unfortunately, while these methods do not require
a measure of the distance between points in space and preprocessing and thus no additional data than the depth
the displaced surface. In the same way, Dummer [2] map and its derivatives, they may skip the first
uses top-opened cones as empty space bounding intersection point at grazing views or for fine scales,
volumes stored in a 2D cone step map. This idea was which results in important artifacts. To overcome this
first introduced by Paglieroni and Petersen [4] for height problem, some conservative methods were introduced
field ray tracing. Other conservative approaches were (sphere tracing, cylinder tracing, cone tracing or
proposed like the use of pyramidal structure [21], [22]. pyramidal tracing). These techniques compute and store
Baboud et Al [23] introduced the use of relaxed pre- additional data in a pre-processing stage. At the
computed volumes allowing safe binary search. They rendering step, this data is used for space leaping to
used a safety radius allowing cylinder tracing. In the avoid missing the first intersection with the relief. But
same way, Policarpo and Oliveira [3] relaxed the rule of with no guarantee of success especially if the number of
the conservative cones. steps is limited.
To resolve the problem of the flat silhouettes, In this section we first discuss two of these
Oliveira and Policarpo use a quadratic function to conservative techniques, the conservative cone tracing
approximate curved surfaces [24]. Hirche et al [25] and the recent relaxed cone tracing which combine
extrude the triangles of the base mesh along their space leaping with an unsafe method. We, then, propose
respective normal directions, and then the resulting to use cone radius instead of ratio and, finally, we
prisms are rendered by casting rays inside and present an extension to non-square displacement maps.
intersecting them with the displaced surface. The prisms
are subdivided into three tetrahedrons if the main mesh
is not planar. Porumbescu et al. [26] use barycentric III.1. Conservative cone tracing
coordinates of points inside tetrahedra to define a In cone step mapping, Dummer [2] assigns to each
mapping between points in the shell volume and texel of the depth map a top opened cone that represents
corresponding points in a 3D texture. Dufort et al. [27] the empty space above it. The cone ratio is computed
use the same technique with semi-transparent 3D during a pre-processing stage and stored in a free
textures in order to support more advanced features. channel of the displacement map called then the cone
Instead of using tetrahedral, Jeschke et al. [28] use a map.
smooth mapping function and Coons patch to render During the ray tracing stage, the next ray position is
defined as the intersection between the viewing ray and
the cone stored at the current texel. First, we normalize
r r r
the depth of the view ray (i.e. v = V / V z where V is the
normalized view ray). So according to Fig. 3, one can
write:
r
c v xy r
= = v xy
a vz
r
c = a × v xy (1)
Likewise:
Fig. 3. Ray tracing of the depth field using conservative cones. At c
= cone _ ratio
each step, the next ray position Pi+1 is calculated in term of the b
current position Pi, the viewing ray v and the value of a. v is
expressed in the TBN space of the current fragment P0
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
IV. Pre-Processing
Giving a greyscale depth map, the pre-processor
creates the displacement map as an RGB texture that
stores the data used by the cone tracing technique. The
depth is assigned to the alpha channel while its x, y
derivatives are mapped to the [0,1] range and stored
respectively in the red and green channels. During the
rendering stage, the normal will be calculated using the
following formula:
(- scale × d x ,- scale × d y ,1)
N scale =
(- scale × d x ,- scale × d y ,1)
where scale is the depth scale, which can be
modulated in real-time.
Finally, the blue channel is used to store conservative
or relaxed cones using their ratio or radius. In this
section we first describe the existing quadratic
Fig. 5. Comparison between the two approaches for processing non- algorithms and, then we present the linear algorithms.
square maps. (a) A rectangular depth map where the texels r and q are Finally, we discuss the tilling options.
candidates to give the cone based on p (q and r have the same depth).
Here, the point q is the nearest to p so it gives the blue cone. (b)
Normalization before cone processing. In this case the texel r became
closer to p and thus gives the green cone. (c) The rendering stage. We
IV.1. Quadratic Algorithms
can clearly notice that the elliptical cone deduced from the blue cone
will gives the largest steps in all view’s directions (V) except for
directions following the largest dimension (V’), but in that case the Conservative cone Maps
difference is less important.
The pre-processor assigns a cone ratio to each texel
on the viewing ray and the ratio of the map dimensions. of the depth map. This cone represents the largest one
This ratio can be easily calculated from the equation of that does not pierce the relief. Dummer [2] instead of
the ellipse. It can be formulated as: using the HDDT [4] proposed an optimized O(n2)
r
V xy algorithm described as follows: for each texel, look
height
a= with R = outwardly (in expanding squares) for the minimal cone
V +R V
2 2 2 width ratio. This search is stopped when the current cone ratio
x y
where we can verify that: if width=height then =1 Algorithm 2: Relaxed Cones (Quadratic)
(square texture), and when Vy=0 then =1 because we Input : Depth Map D
chose to modulate the distances according to the width. Output : Cone Map C
is calculated only once for a given viewing ray,
equation (4) becomes: for each texel t do
r r r C[t] = MAX_VALUE
Pi +1 = Pi + a × va with va = a × v
for each texel p do
ray = (p.x-t.x, p.y-t.y, D[p]) /* view ray */
ray = ray/ray.z /* scale view ray */
ray = ray × (1-D[p]) /* scale again */
Algorithm 1: Conservative Cones (Quadratic)
step = ray/SEARCH_STEPS /* step length */
Input : Depth Map D
pos = (p.x, p.y, D[p]) + step
Output : Cone Map C
for i=0 to SEARCH_STEPS do
if pos.z ≤ D(pos.xy) then
for each texel t do
pos = pos + step
C[t] = MAX_VALUE
else
for each texel p in each outward square S do
break
if C[t] > S_Radius/(D[t]-D[p]) then
end if
break /* process next texel t */
end for i
else if D[t] > D[p] then
if D[t] > pos.z then
C[t] = min( dist(t,p)/(D[t]-D[p]), C[t] )
C[t]=min(dist(t,pos.xy)/(D[t]-pos.z), C(t))
end if
end if
end for p
end for p
end for t
end for t
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
Fig. 9. Comparison between the linear and the quadratic relaxed cones
algorithms when the depth map includes uniform areas. The quadratic
algorithm results on wider cones (it detects the point r) while the
Fig. 8. The relaxed cone based on the texel t is the most narrow cone linear algorithm take the nearest point q. note that this schema is just
(the blue one) going by a local maximum of the relief (here the a 2D slice, thus for other slices the distance between r and q can be
maximum a) zero.
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
TABLE 1
CONE MAPS PRE-PROCESSING TIMES (IN SECONDS).
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
Fig. 12. Resulting cone maps using the different algorithms described in this paper. We notice that for the conservative cones algorithms, the linear
and quadratic algorithms produce the same cone map. For the relaxed cones, the quadratic algorithm produces wider cones (i.e. brighter areas), this is
due to the approximation of this algorithm which can results in some artefacts shown in Fig. 13.
algorithms. Indeed, we can verify that in the linear case, the same, except for the quadratic conservative
the ratio between the running time of a texture with a algorithm which is clearly slower because the apex angle
given dimension and the texture with the lower is no more limited to π/4.
dimension is equal to 4 (because the total number of The Fig. 12 shows cone maps storing ratios. We
pixels is each time multiplied by 4). notice that the linear and the quadratic conservative
With regard to the conservative algorithms, Table 1 algorithms produce exactly the same map. For the
shows that in the case of the texture a, the speed of the relaxed algorithms, both linear and quadratic generate
quadratic algorithm remains reasonable up to the maps with wider cones (brighter texels) but we can
dimension 1024x1024. It is even faster than the linear clearly notice that the quadratic algorithm produce
version with shifted tilling for dimensions less than larger cones. This is due to the approximation used by
512x512. But for the texture b that contains a spaced this algorithm which results in some artefacts shown in
relief, the quadratic algorithm is much slower from the Fig. 13, even if the binary search tends to rectify most of
256x256 size. these errors.
With regard to relaxed cones algorithms, the linear
one is as fast as its conservative version. On the other
V.2. Rendering
hand, the quadratic algorithm is extremely slow. So, we
only calculated the execution time of the 256x256 maps In order to compare the rendering performance of the
size. Even so, it took 8 hours! For this raison, Policarpo different techniques, we used 20 steps for cone tracing
and Oliveira [3] used a GPU-based pre-processing to and 10 steps for the binary search used by the relaxed
reduce the calculation time. cones algorithms. Fig. 14 shows screen shots of the four
It should also be noted that when we calculate and techniques. We can notice that the use of radii instead of
store radii instead of ratios, the timing results are almost ratios produces appreciably a better convergence
without slowing down the framerate (115 FPS). On the
other hand, using relaxed cones produces sharply better
results, but with the cost of the binary search (94 FPS).
So, running the conservative techniques with additional
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
References
[1] L. Szirmay-Kalos and T. Umenhoffer, Displacement Mapping
on the GPU – State of the Art, Computer Graphics Forum,
preprint, 3 Jan. 2008
[2] J. Dummer, Cone Step Mapping: An Iterative Ray-Heightfield
Intersection Algorithm, Technical Report, Available online at
http://www.lonesock.net/files/ConeStepMapping.pdf, 2006.
[3] F. Policarpo and M.M. Oliveira, Relaxed Cone Stepping for
Relief Mapping, GPU Gems 3, pp. 409-428, 2007.
[4] D.W. Paglieroni and S. M. Petersen, Height Distributional
Distance Transform Methods for Height Field Ray Tracing,
ACM Transactions on Graphics (TOG), Vol. 13, no 4, pp. 376-
399, 1994.
[5] J. F. Blinn. Simulation of wrinkled surfaces, Proc. of Siggraph
1978, ACMPress, pp. 286–292, 1978.
Fig. 15. Comparison between the two approaches for processing
[6] N. Max, Horizon mapping: shadows for bump-mapped surfaces,
rectangular maps. (Left) the standard approach which normalizes the
The Visual Computer, Vol. 4, no. 2, pp. 109–117, 1988.
depth map before cone processing. (Right) our method skips the
[7] P. Sloan, M. F. Cohen, Interactive horizon mapping,
normalization and uses an elliptical rectification during rendering
Eurographics Workshop on Rendering, vol. 2, pp. 281-286,
stage. Note that for the viewing ray V’ which follows the largest
2000.
dimension, the standard approach produces better results but the
[8] W. Heidrich, K. Daubert, J. Kautz, and H. Seidel, Illuminating
difference is hardly visible. But for other directions and especially
micro geometry based on precomputed visibility, Proc. of
according to the direction of the smallest dimension V, the standard
Siggraph 2000, ACM Press, pp. 455–464, 2000.
method looks flat and our method produces sharply better results (see
[9] T. Kaneko, T. Takahei, M. Inami, N. Kawakami, Y. Yanagida,
also Fig. 5.).
T. Maeda, and S. Tachi, Detailed shape representation with
parallax mapping, Proc. of the ICAT 2001, pp. 205–208, 2001.
steps for cone tracing will produce approximately same [10] T. Welsh. Parallax mapping with offset limiting: A per-pixel
results as the relaxed approach, and with the same approximation of uneven surfaces, Infiscape Corp., 2004.
framerate. [11] M. Premecz, Iterative parallax mapping with slope
information, Central European Seminar on Computer Graphics
Fig. 15 highlights the use of non-square textures. As CESCG’06, Available online at http://www.cescg.org/CESCG-
we have described in Fig. 5, we can easily notice that the 2006/papers/ TUBudapest-Premecz-Matyas.pdf, 2006.
normalization of the depth map before the cones pre- [12] R. L. Cook. Shade trees, Proc. of Siggraph 1984, ACMPress,
processing gives slightly better results only when the pp. 23–231, 1984.
[13] J. W. Patterson, S. G. Hoggar, and J. R. Logie, Inverse
viewing ray is almost parallel to the direction of the
displacement mapping, Computer Graphics Forum, Vol. 10, no
biggest dimension. On the other hand, in all other 2, pp. 129–139. 1991.
directions, the elliptical rectification method is sharply [14] F. Policarpo, M.M. Oliveira, and J. L. D. Comba, Real-time
better. relief mapping on arbitrary polygonal surfaces, Proc. of
I3D’05, ACMPress, pp. 155–162, 2005.
[15] M.M. Oliveira, G. Bishop, and D. McAllister, Relief texture
mapping, Proc. of Siggraph 2000, ACM Press, pp. 359–368,
VI. Conclusion 2000.
[16] M. McGuire, Steep parallax mapping, I3D’05 Poster, 2005.
In this paper, we have introduced an novel O(n)
[17] Z. Brawley, N. Tatarchuk, Parallax Occlusion Mapping: Self-
algorithm for generating relaxed cone maps, the proposed Shadowing, Perspective-Correct Bump Mapping Using Reverse
algorithm is obviously faster than the quadratic one, but it Height Map Tracing, ShaderX3, 2004.
can result in smaller cones when the depth map contains [18] N. Tatarchuk, Dynamic parallax occlusion mapping with
uniform areas. We also suggested using the linear algorithm approximate soft shadows, SI3D’06, pp. 63-69, 2006.
[19] F. Policarpo, and M.M. Oliveira, Relief Mapping of Non-
HDDT to create the conservative cone maps. Cone maps Height-Field Surface Details, Proc. of the 2006 Symposium on
are used in the cone tracing techniques at the pre-process Interactive 3D Graphics and Games, pp. 55–62. 2006.
stage. We also proposed a new method for extending these [20] W. Donnelly, Per-pixel displacement mapping with distance
techniques to rectangular textures. Furthermore, we have functions; GPUGems2, Addison-Wesley, 2004.
[21] K. Oh, H. Ki, and C.H. Lee, Pyramidal displacement mapping:
used cone radius instead of ratio, which allows storing A GPU-based artifacts-free ray tracing through an image
cones with an apex angle up to π/2 improving in this way pyramid, ACM Symposium on Virtual Reality Software and
the convergence of the cone tracing. Technology (VRST’06), pp..75–82, 2006.
We are convinced that the passage to a linear [22] A. Tevs, I. Ihrke, and H.-P. Seidel, Maximum Mipmaps for Fast,
Accurate, and Scalable Dynamic Height Field Rendering, Proc.
complexity pre-processing will favor the cone tracing Symp. Interactive 3D Graphics and Games, pp. 183-190, 2008.
technique, which remains one of the best ways to [23] L. Baboud, and X. Décoret, Rendering Geometry with Relief
simulate mesostructure surfaces for real-time rendering. Textures, Proc. of Graphics Interface 2006, vol 137, pp. 195-
Even if the pre-processing does not affect the 201, 2006.
performance of this technique during the rendering
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5
A. Halli, A. Saaidi, K. Satori, H. Tairi
[24] M. M. Oliveira, F. Policarpo, An Efficient Representation for Akram Halli received the bachelor’s and master’s
Surface Details, UFRGS technical report RP-351, 2005 degrees from USMBA-Fez University in 2002 and
[25] J. Hirche, A. Ehlert, S. Guthe, and M. Doggett, Hardware 2004 respectively. He is currently working toward
accelerated per-pixel displacement mapping, Proc. of Graphics the PhD degree in the LIIAN Laboratory
Interface 2004, vol. 62, pp. 153–158, 2004. (Laboratoire d’Informatique, Imagerie et Analyse
[26] S.D. Porumbescu, B. Budge, L. Feng, and K.I. Joy, Shell maps, Numérique) at USMBA-Fez University. His
Proc. of ACM SIGGRAPH 2005, ACM Trans. Graphics , vol. current research interests include real-time
24, pp. 626–633. 2005 rendering, Image-based rendering and virtual
[27] J.-F. Dufort, L. Leblanc, and P. Poulin, Interactive rendering of reality.
meso-structure surface details using semi-transparent 3d
textures, Proc. of Vision, Modeling and Visualization 2005, pp.
399-406. 2005
Abderrahim Saaidi received the bachelor’s and
[28] S. Jeschke, S. Mantler, and M. Wimmer, Interactive smooth and
master’s degrees from USMBA-Fez University in
curved shell Mapping, Rendering Techniques 2007, Proc. of the
1997 and 2004 respectively. He is currently
Eurographics Symposium on Rendering, pp. 351-360, 2007.
working toward the PhD degree in the LIIAN
[29] L. Wang, X. Wang, X. Tong, S. Lin, S. Hu, B. Guo, and H. Y.
Laboratory at USMBA-Fez University. His current
Shum, View-dependent displacement mapping, ACM Trans.
research interests include camera self calibration,
Graphics, vol. 22, no. 3, pp. 334–339, 2003.
3D reconstruction and real-time rendering.
[30] X. Wang, X. Tong, S. Lin, S. Hu, B. Guo, and H. Y. Shum.
Generalized displacement maps, Proc. of the Eurographics
Symposium on Rendering, pp. 227-234, 2004.
[31] E.A. Risser, M.A. Shah, and S. Pattanaik, Interval mapping, Khalid Satori received the PhD degree from the
Symposium on Interactive 3D Graphics and Games (I3D'06 National Institute for the Applied Sciences INSA at
Poster), 2006. Lyon in 1993. He is currently a professor of
[32] P.E. Danielsson, Euclidean Distance Mapping, Computer computer science at USMBA-Fez University. His is
Graphics and Image Processing, Vol. 14, pp. 227–248, 1980. the director of the LIIAN Laboratory. His research
interests include real-time rendering, Image-based
rendering, virtual reality, biomedical signal, camera
Authors’ information self calibration and 3D reconstruction.
1
LIIAN laboratory, Faculty of Science Dhar El Mahraz, P.O. Box
1796, Fez, MOROCCO. Hamid Tairi received the PhD degree from
Akram_halli@yahoo.fr USMBA-Fez University in 2001. He is currently a
professor of computer science at USMBA-Fez
2 University. His is also a member of the LIIAN
LIIAN laboratory, Faculty of Science Dhar El Mahraz, P.O. Box
1796, Fez, MOROCCO. Laboratory. His research interests include image
saaidi.abde@caramail.com processing, biomedical signal, Image-based
rendering, visual tracking for robotic control and
3
LIIAN laboratory, Faculty of Science Dhar El Mahraz, P.O. Box 3D reconstruction.
1796, Fez, MOROCCO.
khalidsatori@caramail.com
4
LIIAN laboratory, Faculty of Science Dhar El Mahraz, P.O. Box
1796, Fez, MOROCCO.
htairi@yahoo.fr
Copyright © 2008 Praise Worthy Prize S.r.l. - All rights reserved International Review on Computers and Software, Vol. 3, n. 5