6
Octahedron Environment Maps Thomas Engelhardt, Carsten Dachsbacher Visualization Research Center, University of Stuttgart Email: {thomas.engelhardt, dachsbacher}@visus.uni-stuttgart.de Abstract In this paper, we examine the octahedron as a parameterization scheme to represent environment maps in real-time rendering applications. We dis- cuss two projection schemes and show two conve- nient unfold mappings to pack the platonic solid into quadratic or rectangular textures. We carry out an analysis and consider rendering performance for interactive applications as well as the quality of representation. We further discuss applications and scenarios which benefit from this parameterization. 1 Introduction Environment mapping is an established and well known technique widely used in rendering. In gen- eral the entire environment seen from one point in space is projected onto a parametric surface and stored in one or more textures which can be easily accessed. It is equally important in interactive ren- dering as an efficient means to approximate reflec- tions of distant objects onto geometry of arbitrary shape, as well as a means for storing directional data in general. It plays an essential role in illumi- nation algorithms capturing environmental lighting and has found further applications, such as omni- directional shadow mapping for example. This paper is structured as follows: First we give a short overview on environment mapping tech- niques and related work. In Section 3 we discuss the new octahedron representation for environment maps and describe the necessary transformations, followed by Section 4 addressing issues which arise when implementing this technique. In Section 5 we present our results concluding with a short discus- sion in Section 6. 2 Previous Work The very first environment map has been introduced by Blinn and Newell [1] who transformed a reflec- tion vector into spherical coordinates to access a two dimensional texture. This method suffers from texture distortions in polar regions and visible tex- ture seams. Williams [12] and Hoffmann [9] in- troduced spherical environment maps storing an or- thogonal view onto a perfect mirror sphere in a tex- ture. This technique was the first to receive hard- ware support, however, this method exhibits strong non-uniform sampling and a singularity in the view- ing direction. Greene [3] introduced the cube map which ma- tured to the most popular technique used today. It neither suffers from severe under-sampling, nor from singularities. It combines speed and ease of use, both in creation and look up. Above all it lends itself to capturing real world as well as synthetic scenarios naturally. Because the cube map consists of six textures (which have to be rendered in dynamic scenes) Hei- drich and Seidel [5] developed the dual-paraboloid map projecting the environment onto two mirror paraboloids. This approach does not share the draw- backs inherent to spherical environment mapping and no singularities or severe undersampling oc- curs. The creation of such maps is rather involved and not without limitations, because the underlying projection does not allow direct creation with cam- eras (no such lenses exist) as cube maps do, and they are not based on a linear perspective projection. That is, either high geometry tessellation to reduce the approximation error or more involved rendering algorithms [2] are necessary. 3 Octahedron Environment Maps The octahedron as a possible parameterization scheme for the spherical domain has already been VMV 2008 O. Deussen, D. Keim, D. Saupe (Editors)

Octahedron Environment Maps - Semantic Scholar...directional shadow mapping for example. This paper is structured as follows: First we give a short overview on environment mapping

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Octahedron Environment Maps - Semantic Scholar...directional shadow mapping for example. This paper is structured as follows: First we give a short overview on environment mapping

Octahedron Environment Maps

Thomas Engelhardt, Carsten Dachsbacher

Visualization Research Center, University of StuttgartEmail: {thomas.engelhardt, dachsbacher }@visus.uni-stuttgart.de

Abstract

In this paper, we examine the octahedron as aparameterization scheme to represent environmentmaps in real-time rendering applications. We dis-cuss two projection schemes and show two conve-nient unfold mappings to pack the platonic solidinto quadratic or rectangular textures. We carryout an analysis and consider rendering performancefor interactive applications as well as the quality ofrepresentation. We further discuss applications andscenarios which benefit from this parameterization.

1 Introduction

Environment mapping is an established and wellknown technique widely used in rendering. In gen-eral the entire environment seen from one point inspace is projected onto a parametric surface andstored in one or more textures which can be easilyaccessed. It is equally important in interactive ren-dering as an efficient means to approximate reflec-tions of distant objects onto geometry of arbitraryshape, as well as a means for storing directionaldata in general. It plays an essential role in illumi-nation algorithms capturing environmental lightingand has found further applications, such as omni-directional shadow mapping for example.

This paper is structured as follows: First we givea short overview on environment mapping tech-niques and related work. In Section 3 we discussthe new octahedron representation for environmentmaps and describe the necessary transformations,followed by Section 4 addressing issues which arisewhen implementing this technique. In Section 5 wepresent our results concluding with a short discus-sion in Section 6.

2 Previous Work

The very first environment map has been introducedby Blinn and Newell [1] who transformed a reflec-tion vector into spherical coordinates to access atwo dimensional texture. This method suffers fromtexture distortions in polar regions and visible tex-ture seams. Williams [12] and Hoffmann [9] in-troduced spherical environment maps storing an or-thogonal view onto a perfect mirror sphere in a tex-ture. This technique was the first to receive hard-ware support, however, this method exhibits strongnon-uniform sampling and a singularity in the view-ing direction.

Greene [3] introduced the cube map which ma-tured to the most popular technique used today.It neither suffers from severe under-sampling, norfrom singularities. It combines speed and ease ofuse, both in creation and look up. Above all it lendsitself to capturing real world as well as syntheticscenarios naturally.

Because the cube map consists of six textures(which have to be rendered in dynamic scenes) Hei-drich and Seidel [5] developed the dual-paraboloidmap projecting the environment onto two mirrorparaboloids. This approach does not share the draw-backs inherent to spherical environment mappingand no singularities or severe undersampling oc-curs. The creation of such maps is rather involvedand not without limitations, because the underlyingprojection does not allow direct creation with cam-eras (no such lenses exist) as cube maps do, andthey are not based on a linear perspective projection.That is, either high geometry tessellation to reducethe approximation error or more involved renderingalgorithms [2] are necessary.

3 Octahedron Environment Maps

The octahedron as a possible parameterizationscheme for the spherical domain has already been

VMV 2008 O. Deussen, D. Keim, D. Saupe (Editors)

Page 2: Octahedron Environment Maps - Semantic Scholar...directional shadow mapping for example. This paper is structured as follows: First we give a short overview on environment mapping

3 7

8 4 2

1

6

5 3 4

7 8 8 7 3 4

6 2 1

5

v1

v3

v4

v5

v6

v1

v2

v3

v4

v6

v5

v5

v5

v5

v5

v4

v6

v3

v3

v2

v2

v1

P

P'

P'' r

r v1

v3

v4

v5

v6

v2

1 - 4: posi�ve hemisphere

5 - 8: nega�ve hemisphere

X

Y

Z

Figure 1: We project the environment on the octahedron, which can be unfolded and packed into a singlequadratic or rectangular texture. We show how to directly render into these textures and how to efficientlylookup octahedron environment maps. For the projection, a point p is first projected onto the octahedronfaces, and next projected orthogonally on the XZ-plane.

used by Praun et al. [10], who utilized the 1-to-1mapping of the spherical domain to a 2D texture tostore spherical geometry images. We examine theoctahedron with regard to the use as environmentmaps for real-time rendering applications, includingthe generation of, and look-up to octahedron envi-ronment maps (OEMs) with graphics hardware (seeFigure 7 for an example application).

Each side of the octahedron represents one oc-tant of directions and we describe two projectionsto map directions to points on the sides. Further,the octahedron sides may be arranged differently intwo-dimensional textures (see Figure 1).

In the following, we assume that all coordinatesare given relative to the octahedron’s coordinatesystem as illustrated in Figure 1 (right). This ofcourse can be easily achieved setting up the appro-priate transformations during rendering.

3.1 Planar Projection

The first projection scheme that we analyze uses aprojection similar to a spherical projection. A pointp = (px, py, pz)

T lies on the sphere with radiusr,if p2

x + p2

y + p2

z = r2. Similarly, for a octahedronwith vertices(±r, 0, 0)T , (0,±r, 0)T , (0, 0,±r)T ,a point resides on the surface of the platonic solid, if|px|+ |py|+ |pz| = r. Thus, we derive this projec-tion scheme, which we denote asplanar projection,for a pointp with (see also Figure 1):

p′ =

p

|px| + |py| + |pz|(1)

To unfold the octahedron into a quadratic texture,points on the positive hemisphere, i.e.py > 0,

are orthogonally projected onto the XZ-plane (Fig-ure 1). The lower hemisphere is unfolded by split-ting all edges adjacent to(0,−r, 0)T . Hence theprojected pointsp′′ are obtained by:

p′′

q =

(p′

x, 0, p′

z)T

p′

y ≥ 0

(σ(p′

x)(1 − σ(p′

z))p′

z, 0

σ(p′

z)(1 − σ(p′

x))p′

x)Tp′

y < 0

(2)whereσ(x) is the sign function.

Our second unfolding approach maps the octa-hedron to a rectangular texture with an aspect ratioof 2 : 1 as shown in Figure 1. First equation 1 isapplied, then the pointsp′ are projected orthogo-nally on the XZ-plane and the coordinates from the2 hemispheres are mapped into the layout by fol-lowing transformations.

p′′

r =

{

(p′

x − p′

z − 1, 0, p′

x + p′

z)T

p′

y ≥ 0

(p′

z − p′

x + 1, 0, p′

x + p′

z)T

p′

y < 0

(3)According to the layout mappingp′′

r ∈ [−2; 2]×[−1; 1] andp′′

q ∈ [−1; 1]2 have to be mapped to therespective texture coordinates for access and ren-dering.

3.2 Perspective Projection

In allusion to the cube map the perspective projec-tion can be thought of as another means to obtainan octahedron environment map. The scene can berendered once for each octahedron side, each setup with its own projection matrix. In this case, thefrusta - in contrast to the cube mapping - are of tetra-hedral shape, i.e., we have a triangular view port, forwhich clipping is not natively supported by graphics

Page 3: Octahedron Environment Maps - Semantic Scholar...directional shadow mapping for example. This paper is structured as follows: First we give a short overview on environment mapping

hardware and has thus to be performed manually,either in object or image space.

The look up to octahedron maps using these pro-jections works analogously to cube maps: First theoctant of a look up vector has to be determined, andnext the the projection transformation and the map-ping to the octahedron layout (as described above)is computed.

We examined this parameterization for the sakeof completeness, but compared to a cube map, thereare no advantages to be expected (8 projections in-stead of 6, plus additional clipping). Thus, in theremainder of this paper, we focus on the planar pa-rameterization, which is simpler and thus beneficialfor some applications.

4 Implementation

4.1 Direct Rendering of Octahedron Maps

The planar projection cannot be expressed with thematrix machinery, as the absolute value (see Eq. 1)cannot be expressed accordingly, however it can beeasily used with programmable graphics hardware.Furthermore, triangles overlapping octant bound-aries cannot be handled correctly: Transformationsand projections on GPUs are performed per-vertexand the scan-line conversion or rasterization stage(assuming linear triangle edges) produces wrong re-sults whenever a triangle intersects more than oc-tant (illustrated in Figure 2). Please note, that thisis somewhat similar to the projection errors withparaboloid mapping. Similarly, we can keep the er-ror low by using finely tessellated geometry, but inorder to produce correct results additional effort isnecessary, which is described in the following.

Boundary Overlapp Per-Vertex Projec�on Correct Projec�on

Figure 2: Ignoring octant boundaries leads to incor-rect projections.

Linear interpolation is correct within each octant,i.e., we can solve the problem by splitting trianglesat octant boundaries. We can leverage this by us-ing geometry shaders: A triangle is split at the XY-, YZ-, ZX-plane into smaller triangles (up to 27),

such that each output triangle resides in a single oc-tant only. After the clipping, the projected coor-dinates are computed and the affine transformationaccording to the layout (quadratic or rectangular) isapplied. Please observe that for point-based render-ing techniques special octant boundary treatmentmay not be mandatory, if the error is neglectable,due to the small size of point sprites.

4.2 Texture Look-ups

Unfiltered Texture Lookup The texture coordi-nates for the lookup into an octahedron map fora given direction vector can be computed analo-gously to the aforementioned projection and layouttransformation. The unfiltered lookup is very effi-cient when used together with the quadratic layout.Computing the texture coordinates for a directionvectord given in the octahedron coordinate systemcan be achieved with the following few instructions(shader pseudo code):// projection onto octahedron

d /= dot( 1, abs(d) );

// out-folding of the downward faces

if ( d.y < 0.0f )

d.xy = (1-abs(d.zx)) * sign(d.xz);

// mapping to [0;1]ˆ2 texture space

d.xy = d.xy * 0.5 + 0.5;

color = tex2D( octaMap, d.xy );

Filtered Texture Lookup For a mip-mappedlookup, we need to consider two aspects. First,when determining the required mip-level for a tex-ture lookup, the decision is based on the extendof the quadrilateral region spanned by the screenspace pixel cell transformed into texture space. It iscomputed from the texture coordinate and its partialderivatives [8]. Please note, that for per-pixel com-puted reflections, the mip-level is typically com-puted manually depending on surface curvature orglossiness. We denote the partial derivatives in tex-ture space bydX anddY . The mip map levell isthen derived by:

e = max(〈dX, dX〉 , 〈dY, dY 〉)l = log

2

√e (4)

However, in the case of the octahedron map thequadrilateral region might cross two adjacent oc-tants which have been separated due to the unfold-ing. For the quadratic layout, this case occurs when

Page 4: Octahedron Environment Maps - Semantic Scholar...directional shadow mapping for example. This paper is structured as follows: First we give a short overview on environment mapping

the quadrilateral resides in the negative hemisphere.A possible situation is depicted in Figure 3 (center)for the quadratic layout, but similar configurationsoccur for the rectangular layout as well.

Thus, we need a special treatment when a cellspans two disjoint regions in the texture space. For-tunately, the symmetry of the octahedron allows usto reflect the coordinates of pixel cells in the lowerto the upper hemisphere, thus resulting in a contigu-ous quadrilateral which is then used to compute thecorrect mip-level (Figure 3, right). In practice, wecompute the mip-level of both, the original and themirrored cell, and use the minimum of both values.

For the rectangular layout both hemispheres aremapped to contiguous regions. Thus, whentexturearrays (supported by DirectX 10) are used – onetexture per hemisphere – then filtering is automati-cally handled correctly, also for the per-vertex tex-ture coordinate computation. If no texture arraysare used, then similar treatment as described abovefor the quadratic layout is necessary.

dX2

P1

P3

P2 P4

dX1

dY

dX2

P1

P3

P2

P4

dX1

dY

dX2

P1

P2

P3

P4

dX

dY

Figure 3: The quadrilateral region in texture spacecorresponding to a pixel cell in the negative hemi-sphere is mapped to disjoint regions (center). Thisyields to incorrect mip-levels, however, by exploit-ing symmetry we reflect at the XZ-plane and obtainthe correct area estimate for mip map level determi-nation (right).

The second aspect for a filtered texture look-upis that due to the unfolding a wrap-around access tothe texture does not yield correctly bi-linearly inter-polated color values (this applies to parabolic, andto some extend to cube maps as well). This can bebest solved by introducing a ”safety-border”, thatis by duplicating pixels as shown in Figure 4 suchthat samples for bi-linear interpolation and mip-mapping are available.

Please note, that the maximum correctly rep-resented mip-level depends on the width of thesafety-border. We also used octahedron maps withsummed area tables for rendering glossy reflec-

8 7 3 4

6 2 1

5

2

4 8 5 3 7 6

5

1 4

8

7 6 2 1 5 8

7

3

6

b

b

s

s

Figure 4: The OEM texture of dimensionss × s isextended with a texture border of widthb

tions [6]. In this case we used a safety-borderwidth determined by the maximum glossiness ofthe BRDF (Figure 7 shows an example). Pleasenote, that for accurate BRDF modeling, multipleSAT queries are required which holds for all spheri-cal parameterizations and (pre)filtered environmentmappings.

5 Results

5.1 Sampling

In order to evaluate the sampling quality of the oc-tahedron map, we compute the solid angle coveredby each pixel (relative to the solid angle of a sphereover the total number of pixels). The comparisonof the octahedron parameterization to a cube mapis shown in Figure 5. The highest sampling rateis close to the octahedron vertices, but stays withinan acceptable range across the entire surface. Asexpected, the planar projection yields a more bal-anced sampling than the perspective projection; theoverall quality is comparable to a cube map.

5.2 Direct Rendering

We further measured the rendering performancefor an adequately complex scene (Figure 8) creat-ing three environment maps of approximately equalpixel count. We directly render a512 × 512quadratic layout(QL) OEM, a rectangular layout(RL) OEM of two 362 × 362 textures and a cubemap of six209 × 209 textures. The timings arelisted in Table 1. We have implemented both, theplanar and perspective projection with explicit clip-ping in the geometry shader stage as described inSection 4.1. We denote this approach, which gener-ates up to81 vertices,strict split. As mentioned inSection 3.2 the clipping for perspective OEMs can

Page 5: Octahedron Environment Maps - Semantic Scholar...directional shadow mapping for example. This paper is structured as follows: First we give a short overview on environment mapping

Planar Projec�on Perspec�ve Projec�on Cube Map Surface Side

ΩAvg 2ΩAvg 4ΩAvg ½ΩAvg ¼ΩAvg

Figure 5: Dark blue and purple regions indicate ar-eas of undersampling while regions of green to yel-low indicate areas of directional oversampling.

also be done in image space by discarding pixelsthat do not fall into the triangular viewport. We callthis methodclip mask.

For the rectangular layout we present results forthe planar projection and only examine two less ac-curate clipping techniques: The clipping in the ge-ometry shader whose performance heavily dependson the amount of vertices output to the succeedingpipeline stages proved to be the bottleneck in ourimplementation. Exploiting the fact that both hemi-spheres are mapped to contiguous regions we onlysplit triangles mapped to both textures due to in-tersecting the XZ-plane. We denote this approach,which outputs two triangle strips of at most 7 ver-tices,XZ-split (Figure 6,XZ-split).

The second approach, callededge strip, proceedswith the vertices created by the XZ-split in bothhalf-spaces (positive and negative y-axis) indepen-dently. Those vertices form convex polygons whoseedges are split by the remaining split planes (Fig-ure 6,edge-split). Afterwards two triangle strips aredirectly created from the obtained points (Figure 6,triangle strip). Please note, that while this naı̈vestripping preserves the correctness of the projec-tion on both polygon boundaries, it does not guar-antee correct interpolation, e.g. of texture coordi-nates, within the triangle strips. Of course this isnot correct, but rather tolerable than a wrong primi-tive shape. This approach outputs a maximum of 15vertices in total.

5.3 Applications and Advantages

Despite the difficulties introduced with the directrendering of OEMs, they provide two unique fea-tures. First, OEMs have the ability to generatesummed area tables (SATs) over the the entirespherical domain. When creating SATs on GPUs,

triangle to be split XZ-split triangle strip

XZ-Plane

YX

/YZ-P

lan

e

edge-split

Figure 6: The triangle is split at the XZ-plane. Theconvex polygons obtained in the positive (red ver-tices) and negative (orange vertices) half-space areeither directly triangulated or after the boundarieshave been split by all remaining split planes.

e.g. with the method by Scheuermann et al. [6],the input and output parameterization can be cho-sen independently. This is because multiple ren-der passes are required for the generation and thefirst one can include a reparameterization, i.e. alsoeasily renderable cube or paraboloid maps can beused as input. Furthermore, a lookup to an OEMsis an efficient means to make directional data avail-able to all shader stages. For vertex or geometryshaders there is no support for cube maps and theOEM lookup presented in Section 4.2 is more effi-cient than any lookup to cube or paraboloid mapscomputed by hand.

The octahedron parameterization also providescompact storage when multiple (hemi-)sphericaldomains are to be stored, e.g. (hemi-)sphericalshadow maps for instant radiosity methods [7] orfor sparse-sampling of scene radiance [4]. Insteadof parabolic parameterizations which waste up to20 percent of texture space, OEMs can be packedwithout wasting texture space into texture atlases.

As OEMs, latitude-longitude environment mapsallow to parameterize the spherical domain to a rect-angular texture, and consequently, they would alsoallow to compute SATs, provide compact storage,and lookup in vertex and geometry shaders. How-ever, the sampling is worse and exhibits two singu-larities in polar regions, the lookup requires trigono-metric, and thus expensive, operations and render-ing to latitude-longitude maps requires clipping andsplitting as well.

6 Conclusions

We examined octahedron environment maps as analternative for environment map rendering whichrepresent the entire spherical domain of directionsin a single quadratic or rectangular texture whileproviding efficient texture look-ups. Although the

Page 6: Octahedron Environment Maps - Semantic Scholar...directional shadow mapping for example. This paper is structured as follows: First we give a short overview on environment mapping

EnvMap Clipping FPS[s]Planar QL strict split 16Planar RL XZ-split 34Planar RL edge strip 3Perspective QL strict split 16Perspective QL clip mask 95Cube Map 250

Table 1: Rendering performance of our test scenefor a screen resolution of1920× 1200. All timingswere taken on an Intel Q6600 Core2Duo processorwith 2.4GHz, a GeForce 8800GTX running Vistax64 with 4GB of main memory.

Figure 7: Screenshot of a rendering with SATs cre-ated from octahedron environment maps to adjustsurface glossiness at real-time. The creation ofthe 512 × 512 pixel SAT takes about3.3ms on aNVIDIA 8800GTX.

planar projection and unfolding transformations arerather simple and provide good sampling (compa-rable to the cube map), the direct rendering is notyet suitable for interactive applications due to thegeometry shader performance.

Nonetheless OEMs offer benefits not knownfrom other techniques, namely the ability to createspherical summed area tables, efficient look-ups inall shader stages on GPUs, and tight-packing intotexture atlases.

References[1] James F. Blinn and Martin E. Newell. Texture

and reflection in computer generated images.Communications of the ACM, 19(10):542–547, 1976.

[2] Jean-Dominique Gascuel, NicolasHolzschuch, Gabriel Fournier and BernardPeroche. Fast Non-Linear Projections usingGraphics Hardware.ACM Symposium onInteractive 3D Graphics and Games, 2008

[3] Ned Greene. Environment Mapping andOther Applications of World Projections.

Figure 8: Our test scene of approximately105k tri-angles for dynamic environment map generation.

IEEE Computer Graphics and Applications,6(11):21–29, 1986.

[4] Gene Greger, Peter Shirley, Philip M. Hub-bard and Donald P. Greenberg. The Ir-radiance Volume. IEEE Comput. Graph.Appl.,18(2):32–43, 1998.

[5] Wolfgang Heidrich. View-Independent Envi-ronment Maps.Proceedings of Eurograph-ics/SIGGRAPH Workshop on Graphics Hard-ware ’98, 1998.

[6] Justin Hensley, Thorsten Scheuermann, G.Coombe, M. Singh, and Anselmo Lastra. FastSummed-Area Table Generation and its Ap-plications.Eurographics ’05, 2005

[7] Samuli Laine, Hannu Saransaari, Janne Kon-tkanen, Jaakko Lehtinen and Timo Aila. Incre-mental Instant Radiosity for Real-Time Indi-rect Illumination.Proceedings of Eurograph-ics Symposium on Rendering 2007, 2007

[8] Microsoft Corporation. DirectX Software De-velopment Kit 10.

[9] Gene S. Miller and C. Robert Hoffman. Il-lumination and Reflection Maps: SimulatedObjects in Simulated and Real Environments.SIGGRAPH ’84 Advanced Computer Graph-ics Animation course notes, 1984.

[10] Emil Praun and Hugues Hoppe. Sphericalparametrization and remeshing.ACM Trans.Graph.,22(3):340–349, 2003.

[11] Nicolai Steiner. Pyramidal EnvironmentMaps. Diploma Thesis, University ofStuttgart, 2008.

[12] Lance Williams. Pyramidal Parametrics.SIG-GRAPH Comput. Graph., 17(3):1–11, 1983.