Poly Cube Maps
Poly Cube Maps
Poly Cube Maps
X T3 X T2
Figure 2: A polycube that consists of 10 cubes (left) and the parti-
Figure 1: Cube maps can be used to seamlessly texture map an ap- tion of its surface into cells as explained in Section 3 (right).
ple (left). In this case, the 3D texture domain T3 is the surface of
a single cube that is immersed in the 3D texture space T3 (mid- X T2
dle) and corresponds to a 2D texture domain T2 that consists of six
square images (right). T3
XX 3
T XX
1.2 Overview
In principle, these seamless parameterization methods could also be
used for texture mapping. Colour information could be defined on
the domain triangles of the base complex and the parameter values Figure 3: The 2D analogue of our method: the projection P maps
of the mesh vertices could be used to linearly map the colour to the each point (or fragment) in T3 onto the 3D texture domain T3 (left).
mesh triangles. However, difficulties arise when the vertices of a The mapping M can then be used to look up the texture information
mesh triangle have parameter values on different domain triangles from the 2D texture domain T2 . PolyCube-Maps are not tied to the
and their linear interpolation is a secant triangle that falls outside mesh structure and work for different mesh representations (right).
the surface on which the colour information is defined.
Our approach is similar to the idea that we just sketched, but in-
stead of using a triangulated base complex we use the surface of a vT 3 = (vr , vs , vt ) ∈ T3 . At rendering time, the vertices and their 3D
polycube as texture domain. The special structure of this surface texture positions are fed to the graphics pipeline and the rasterizer
not only allows to efficiently store and access the colour informa- interpolates the latter ones to get a 3D texture position fI3 for ev-
tion in a standard 2D texture, but also to handle the problem of ery produced fragment f and passes it on to the fragment shader.
secant triangles by simply projecting them onto the texture domain. Even if all 3D texture positions vT 3 lie on T3 , this is not necessar-
Both this projection and the colour access are simple enough to ily the case for the interpolated 3D texture position fI3 . Therefore,
be implemented in currently available graphics hardware. As a re- the fragment shader applies a projection P : T3 → T3 to map fI3
sult we have a new seamless texture mapping technique. But let us to a point fT 3 in the 3D texture domain. It further uses a second
start by explaining the basic idea behind our PolyCube-Maps which mapping M : T3 → T2 to determine the colour information at fT 3
stems from the concept of cube maps. that is stored in the 2D texture domain T2 (see Figure 3 for the 2D
analogue). In our case, T2 is one single rectangular texture image
2 PolyCube-Maps with a packing of several square patches.
The most important feature of PolyCube-Maps is that the 3D
Cube maps are commonly used for environment mapping, but they texture coordinates vary continuously over the surface of the object
can also be used to define a seamless texture mapping for, say, an and therefore enable a seamless texture mapping even though the
apple (see Figure 1). In fact, all we need to do is to assign to each texture information itself is stored as a collection of square images.
vertex of such a 3D model a 3D texture position (which can differ
from the vertex position). We call the space of possible texture posi-
tions the 3D texture space and denote it by T3 to distinguish it from
3 How PolyCube-Maps Work
the object space R3 that contains the vertex positions. The cube Let us now explain in detail how we define the functions P and M .
map mechanism will then use a simple central projection to project Remember that we want to use PolyCube-Maps for the purpose of
the texture position of every rendered fragment onto the surface of texture mapping and both P and M must be computed in the frag-
a unitary cube with its centre at the origin. Let us call the surface of ment shader which is the tighter sub-loop of the graphics pipeline.
this cube the 3D texture domain and denote it by T3 with T3 ⊂ T3 . Therefore their implementation must be as simple and quick as pos-
The cube map mechanism will further associate each point of T3 sible. To achieve this, we define both mappings piecewise over an
with a position in a 2D texture space, which in this case is a col- adequate partition of T3 .
lection of six planar square texture images, one for each face of
the cube. We denote this 2D texture domain by T2 . The resulting
mapping will be seamless and will avoid all the drawbacks that we
sketched in the introduction. However, this use of cube maps is
fairly uncommon because it works only for quasi-spheres and our
main idea is to extend this concept to more general shapes.
For our PolyCube-Maps we use as 3D texture domain T3 the
surface of a polycube rather than a single cube. A polycube is a
shape composed of axis-aligned unit cubes that are attached face
to face (see Figure 2, left). In order to get the best results, the used Figure 4: Another 2D analogue: we roughly approximate the object
polycube should very roughly resemble the shape of the given mesh surface with a polycube (left), consider the dual space of unit cubes
and capture the large scale features. centered in the corners of the polycube (middle), and finally have
Once the polycube is defined, we proceed as follows. First we for each non-empty cube a projection function that assigns each
assign to each vertex v of the mesh a unique 3D texture position point inside a cube to the polycube surface (right).
type 3 type 4a type 4b type 5 type 6a type 6b
Figure 5: Six basic configurations can occur (up to rotations and reflections) in a non-empty cell. Top: sub-part of the polycube surface T3
inside the cell with different colours for the individual facelets. Centre: projection lines of P inside the cell; they are orthogonal to the shown
surfaces. Bottom: packing of squarelets into patches; the colour of the squarelets corresponds to the colour of the associated facelet.
p –1
p
defined differently for the basic cases and it would be sufficient to
ar
ar
w
w
execute only the code that implements the case e.C, we cannot do
this because the shading languages lack a general branching con- T3 optimize
struct. Instead we compute all cases in sequence and use a condi-
tional assignment at the end of each case to record only the result
of case e.C in a register.
Since all cases are computed anyway, it is profitable to identify
common subexpressions that are shared by different branches so
as to reduce the number of overall instructions. Actually, we took T3 (d) (e) (f)
care of maximizing the number of common subexpressions, when Figure 7: The 2D analogue of our technique to assign 3D texture
we decided on the default orientation of the basic cases and the positions to the vertices of a mesh (a): we first warp the poly-
packing of squarelets into patches. cube (d) close to the mesh (b), then we project the vertices in the
A side effect of this non-branched architecture is that the cost of normal direction onto the warped polycube surface (c), warp the re-
processing a fragment depends on the total number of instructions sult back (e), and finally optimize the texture positions. The meshes
needed to cover all basic cases. Moreover, the cases 6a and 6b in the top row are in R3 while those in the bottom row are in T3 .
are the most complex and the least beneficial, as they hardly ever
occur in useful polycubes. And since their implementation in the
fragment shader would have burdened the execution for all the other 6.1 Construction of the poly-cubic parameterization
cases as well, we decided to leave them out of our implementation.
This choice implies a limitation on the polycube layout, but when The first step is to assign to every vertex v of the given mesh M a
we constructed polycubes for real-world meshes (see Section 6) we 3D texture position vT 3 ∈ T3 . As we have seen in Section 2, this can
found the practical effect of this limitation to be negligible. be done by a simple central projection if the mesh has a sphere-like
shape and T3 is a surrounding cube. For more complex meshes we
propose the following procedure that is illustrated in Figure 7.
5.3 Filtering and mip-mapping We start by defining a polycube that has roughly the same shape
as M and captures all the large scale features. For example, the
When the final texel value is fetched from T2 in the last step of polycube for the bunny has two stacks of 4 cubes that resemble the
the algorithm, the mip-mapping mechanism still works (including ears, a 3×3×4 block for the head, and so on (see Figure 10).
the linear interpolation between different mip-map levels), because Next we warp the surface T3 of the polycube from its axis-
the size and the positions of squarelets are both powers of 2. The aligned position in the 3D texture space T3 to the object space R3 .
only difference with respect to the default is that the mip-map level We manually move its vertices close to the mesh and take care that
selection must be set so that it is based on the speed of the texture the large scale features of the warped polycube surface and those
positions fI3 in T3 , rather than the final texture position in T2 . of the mesh are roughly aligned. For some meshes a simple scal-
In contrast, bilinear interpolation cannot be performed as usual, ing, rotation, and translation of the polycube surface can serve as a
because the interpolation would mix texels that belong to different warp function. For example, this was the case for the Laurana and
squarelets whenever the border of a squarelet is accessed. However, the 3-holes object (see Figure 10).
we can still run the code multiple times and manually interpolate the Then we establish a correspondence between both surfaces by
fetched texels in the fragment shader. In this way, bilinear interpo- moving every vertex v of M along the surface normal direction onto
lation can be performed without adding any texels at squarelet bor- the deformed polycube. This projection may generate fold-overs,
ders, because the fragment shader “knows” about the patch bound- mostly in regions with small scale features, but before we attend
aries. This method requires to turn off the automatic bilinear inter- to this matter, we apply the inverse warp function to the projected
polation, which can be done in current fragment languages as they vertices and map them to T3 .
explicitly allow this kind of “do-it-yourself” interpolation. These initial 3D texture positions vT 3 usually do not define a
The complete scheme costs 4·54 instructions for computing the good parameterization, in other words, the piecewise linear func-
2D texture positions plus 4 for the texture fetches and 3 for the bi- tion that maps each triangle of M to the corresponding parameter
linear interpolation itself. But it is possible to compromise between triangle in T3 deforms the shape of the triangles considerably and
quality and efficiency by using an anti-aliasing schemes that ac- may not even be one-to-one in some parts. We therefore imple-
cesses and interpolates a smaller number of texels. Of course, each mented a simple iterative procedure to optimize the texture posi-
texture fetch can be mip-mapped automatically. tions and to minimize the overall distortion of the parameterization.
For each vertex v we consider the local mapping between the
one-ring of v in M and the one-ring of vT 3 in T3 . Then we compute
6 Construction of a PolyCube-Map the gradient of the deformation energy of the local mapping with
respect to vT 3 and a simple one-dimensional line-search along this
So far we described the mechanism of PolyCube-Maps and we direction gives us a new position vT 3 . If the one-ring of vT 3 is
will now sketch a method that can be used for the construction of not flat, then vT 3 may not lie on T3 and we use the projection P
a PolyCube-Map for a given triangle mesh. We used this semi- to map it back onto T3 in that case. By iterating over the vertices
automatic technique to produce all the examples that are shown in and applying these local optimizations, we successively improve
this paper. the quality of the poly-cubic parameterization globally.
projection mean value MIPS extended MIPS
7 Experimental Results
To test the potential of PolyCube-Maps, we produced a few exam-
ples (see Figures 10 and 12) with the method described in Section 6.
The texel values of the texture map T2 have been filled using either
a regular pattern or the shading of the mesh at highest resolution
as in [Cignoni et al. 1999]. Note that our method is not limited to Figure 10: Examples of models with poly-cubic parameterizations:
closed surfaces. In fact, the Laurana model is open at the bottom the original model (left), using the PolyCube-Map to texture it with
and we can still use PolyCube-Maps as long as the polycube surface a regular grid (middle), and shaded parameterization of the mesh
is open at the bottom, too (see Figure 11). over the polycube surface (right).
Figure 11: Our method also allows to handle open meshes as
long as the polycube captures this feature and is open, too. The
facelets of the polycube and the corresponding parts on the mesh
are coloured according to the cell configuration.