haptic rendering of subdivision surfaces - kth · subdivision surfaces is a technique for ......

44
Stefan Bindzau TRITA-NA-E03162 Haptic Rendering of Subdivision Surfaces

Upload: truongtram

Post on 10-Sep-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Stefan Bindzau

TRITA-NA-E03162

Haptic Rendering of Subdivision Surfaces

Page 2: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

NADA

Numerisk analys och datalogi Department of Numerical AnalysisKTH and Computer Science100 44 Stockholm Royal Institute of Technology

SE-100 44 Stockholm, Sweden

Stefan Bindzau

TRITA-NA-E03162

Master’s Thesis in Computer Science (20 credits)at the School of Computer Science and Engineering,

Royal Institute of Technology year 2003Supervisor at Nada was Lars Kjelldahl

Examiner was Lars Kjelldahl

Haptic Rendering of Subdivision Surfaces

Page 3: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Abstract

This report presents a new way of representing subdivision surfaces in a combinedhaptic and graphic environment. Subdivision surfaces is a technique for render-ing smooth surfaces built up by arbitrary formed meshes and is primarily used incomputer modeling and animation. Haptics can be described as rendering forcesdescribing the outline of virtual objects aiming to enhance the realism by addinganother sense to the experience.

The new technique used in this work is exact evaluation, meaning that insteadof subdividing the surface into polygons and haptically rendering them, the exactvalue of the interaction points is used to render forces. To find the interaction pointa numerical minimisation is performed at every step in the haptic loop. This is donein order to provide an exact instead of approximated value and is potentially faster.

A proof of concept was implemented which showed that the idea was realisableand that the update rate was sufficient for at least small surfaces. However, dueto some technical issues further work has to be performed to experience the fullpotential of the approach.

Page 4: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Haptisk rendering av subdivision surfaces

Examensarbete

Sammanfattning

Den här rapporten är ett examensarbete om ett nytt sätt att representera “sub-division surfaces” i en kombinerad haptisk och grafisk miljö. Subdivision surfacesär ett sätt att rendera jämna, rundade ytor som baserar sig på oregelbundna nod-nätverk och används främst inom design och datoranimerad film. Haptik innebärkraftbestämning och -generering för att presentera formen av virtuella objekt ochdärigenom höja realismen i modellen.

Den nya metoden som användes var exakt evaluering vilket innebar att iställetför att dela in ytan i polygoner och använda dem i den haptiska renderingen beräknasett exakt värde för interaktionspunkterna. Dessa punkter används därefter för attrendera krafter. För att bestämma punkterna så precist som möjligt används ennumerisk minimering i varje steg av den haptiska loopen. Detta görs för att få ettgodtyckligt precist värde istället för en grövre approximation och det kan även varasnabbare.

I den försöksimplementation som gjordes som en del av arbetet framkom att detvar möjligt att använda metoden och att uppdateringshastigheten var tillräcklig,åtminstone för mindre ytor. Tyvärr uppkom vissa tekniska problem vilket gör attimplementationen måste vidareutvecklas för att verkligen klargöra vilka fördelar sommetoden kan innebära.

Page 5: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Acknowledgements

This thesis would not have been possible without the help of Reachin TechnologiesAB where the development took place and IPLab, Nada, Royal Institute of Technol-ogy. At Reachin I would especially like to thank my supervisor Daniel Evestedt whohas helped me continuously during the work. Special thanks also to John McLaugh-lin who wrote much of the initial code for parts of the implementation. At IPLab Iwould like to thank my supervisor and examiner Lars Kjelldahl.

Page 6: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Contents

1 Introduction 1

1.1 Overview of the Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 The Problems of Surface Rendering . . . . . . . . . . . . . . . . . . . 11.3 Haptic Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3.1 The Reachin API . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Background - Rendering 4

2.1 Two Dimensional Curves . . . . . . . . . . . . . . . . . . . . . . . . . 42.1.1 Explicit form, Implicit form and Parametric Curves . . . . . . 42.1.2 Spline Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.1.3 Piecewise Polynomial Curves . . . . . . . . . . . . . . . . . . 62.1.4 B-Spline Curves . . . . . . . . . . . . . . . . . . . . . . . . . . 62.1.5 NURBS Curves . . . . . . . . . . . . . . . . . . . . . . . . . . 72.1.6 Subdivision Splines . . . . . . . . . . . . . . . . . . . . . . . . 8

2.2 Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2.1 Polygonal Surfaces . . . . . . . . . . . . . . . . . . . . . . . . 92.2.2 Parametric Surfaces . . . . . . . . . . . . . . . . . . . . . . . 102.2.3 B-Spline Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.4 Extraordinary Vertices . . . . . . . . . . . . . . . . . . . . . . 112.2.5 Subdivision Surfaces . . . . . . . . . . . . . . . . . . . . . . . 11

2.3 Subdivision Mathematics . . . . . . . . . . . . . . . . . . . . . . . . 122.4 Calculating the Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 132.5 Subdivision Categories . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.5.1 Catmull-Clark . . . . . . . . . . . . . . . . . . . . . . . . . . 162.5.2 Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.5.3 Recent Attempts . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.6 Volume Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.7 Uses of Subdivision Surfaces . . . . . . . . . . . . . . . . . . . . . . . 192.8 Exact Evaluation of Subdivision Surfaces . . . . . . . . . . . . . . . . 20

2.8.1 Splitting the surface . . . . . . . . . . . . . . . . . . . . . . . 202.8.2 Implementing Exact Evaluation . . . . . . . . . . . . . . . . . 21

2.9 Rendering Subdivision Surfaces . . . . . . . . . . . . . . . . . . . . . 21

3 Using Exact Evaluation for Haptic Rendering 23

Page 7: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

3.1 A New Approach to Haptic Rendering . . . . . . . . . . . . . . . . . 233.2 The Effects on Graphics Rendering . . . . . . . . . . . . . . . . . . . 243.3 Choosing an Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 243.4 Efficiency and Stability Concerns . . . . . . . . . . . . . . . . . . . . 253.5 Shortcuts Taken . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4 Overview of the Implementation Design 27

4.1 The Regular Patch . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.2 The Extraordinary Patch . . . . . . . . . . . . . . . . . . . . . . . . 274.3 Basics of the Haptic Implementation . . . . . . . . . . . . . . . . . . 284.4 A Subdivision Surface in Reachin API . . . . . . . . . . . . . . . . . 29

4.4.1 Evaluation Around Extraordinary Vertices . . . . . . . . . . . 29

5 Results 31

5.1 Tests Performed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315.1.1 Single Patches . . . . . . . . . . . . . . . . . . . . . . . . . . 315.1.2 A Connected Surface . . . . . . . . . . . . . . . . . . . . . . . 32

5.2 Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

6 Conclusions 34

7 Further Development 35

Page 8: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Chapter 1

Introduction

1.1 Overview of the Thesis

This thesis consists of two parts. The first chapter consists of an introductionto the area and a brief discussion of relevant previous work in the field. Afterthis general introduction the following chapters, starting with chapter 2, treat themathematical foundation of some geometrical curves and surfaces used in graphicsrendering. Readers familiar to the field can proceed immediately to the last sectionof the chapter for a short discussion of Jos Stam’s text on exact evaluation on whichmany of the ideas in this work are based. The second part of the thesis starts with achapter on the basic ideas of the thesis (chapter 3). Following is a high level overviewof the implementation design and the last chapter contains tests performed and afinal analysis.

1.2 The Problems of Surface Rendering

Traditionally surfaces in 3D are modelled using one of two approaches; either thebounding surface is approximated by polygons (usually triangles) or it is describedas a mathematical function, often in the form of NURBS surfaces. The polygonalrepresentation has the disadvantage of being poor at rendering smooth surfaces, orat least demanding a large number of polygons to visualise it1. Contrary, the mathe-matical approach can generate very smooth surfaces (though they are tessellated as alast step before rendering) but has instead problems with sharp edges. Note that forhaptic rendering as well as for ray-tracing this last stage tessellation does not haveto be performed, but instead the pure mathematical model can be used throughoutthe process. Additionally, NURBS surfaces need control nets that are regular whichis not always the most natural form of modelling a surface. As NURBS is a commontool for modelling 3D objects many techniques have been devised to rectify this at

1Visualisation techniques such as Phong or Goraud shading can smooth many rough edges butthey can simultaneously interfere with the haptic model as the shading is not in any way an exactrepresentation of the object

1

Page 9: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

the cost of an increase in complexity. Finally both methods are difficult to handlein the increasingly popular field of 3D animations. The polygonal representation re-quires an underlying structure as manipulating every polygon by hand is not feasiblefor larger projects. The NURBS model supplies such a structure, but the effect ofchanges to the controlling mesh on the target surface are not always intuitive. Sub-division surfaces (fig. 1.1 to 1.4) were invented to lessen the impact of these issues,primarily as a way of rendering surfaces controlled by an irregular control mesh, i.e.a mesh with some vertices with a valence other than NURBS usual 4. Additionallythe technique lends itself well for manipulating models used in 3D animations (Zorinand Schröder, 2000). This has made it increasingly used by modellers and it is nowsupported in graphics design packages such as Maya®2.

Figure 1.1. The surface be-fore subdivision.

Figure 1.2. The surface afterone subdivision step.

Figure 1.3. The surface aftera second subdivision

Figure 1.4. The final re-sult. All pictures are fromhttp://www.subdivision.org.

Haptic subdivision surfaces however, creates a new problem as no practical so-lution for evaluating the surface at a given coordinate was known. This is neededto calculate the interaction point in haptic rendering—unless the surface is approxi-mated by polygons around the device, but then the difficulties of polygonal surfacesare present again (see (Bolz and Schröder, 2002) for examples). The article (Stam,1998b) presents a technique for evaluating subdivision surfaces in a given point,seemingly efficiently enough for using it in haptic rendering. This is an attempt toverify that it can be done in a haptic environment using the Reachin API.

2http://www.alias.com/

2

Page 10: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

1.3 Haptic Rendering

Haptics, also known as force feedback, is a technique to make three-dimensionalcomputer models more life-like by enabling the user to “feel” the objects in thescene. This is done by having a robotic device—the haptic interface—generate theappropriate forces to simulate the bounding surface of the objects. Haptics differsfrom tactile feedback as it does not provide the fingertip sensation—the feel of theobjects is purely sensed through the robot arm by the forces generated when movingthe haptic device representation around the virtual objects. As feel is much moresensitive to change than vision the haptic representation needs an update rate of atleast 1kHz to appear smooth. The graphic rendering on the other hand is sufficientlystable with refresh rates in the range of 30-60 Hz.

1.3.1 The Reachin API

To reduce the scope of the implementation I needed a stable platform which suppliedas much of the basic framework as possible. Due to prior experience the choice fellupon the Reachin API (Reachin, 2003) whose concept of collocation—integratingthe graphic and haptic representation—fitted well in the design.

The Reachin API is an API which combines the graphic and haptic aspectsof the virtual world by combining them for every object in a scene graph. Thegraph is an extended version of the VRML standard (Carey and Bell, 1997) toincorporate the changes necessary to accommodate the haptic rendering. In partthis is done by adding new fields to existing nodes and in part by extending theAPI with completely new nodes written in C++. The haptic interface is usuallya Sensable Phantom3 but a number of other devices are supported. The device isgraphically represented by a 3D model and has a sphere representation in the hapticworld. For a more thorough description of the ideas behind this model see (Zillesand Salisbury, 1995).The haptic and graphic rendering are performed by separatethreads to accommodate the haptic’s need for a far higher refresh rate.

Each node generates its own graphical representation using OpenGL (Woo et al.,1999) and in addition has to handle collisions with the haptic device representation.This is done in several steps. First there is an oriented bounding box check tosee if the node is affected at all. Secondly approximate possible collision pointsare calculated. These are added to a Realtime Geometry which is a light-weightrepresentation of the node used for the fast calculations needed. The RealtimeGeometry is added to the haptic thread and in its loop exact collision points arecalculated and these are converted to exclusion planes where the haptic device willbe restricted in its movements. This last step is done during every run of the hapticloop for every device node in the scene which has a haptic representation.

3http://www.sensable.com/

3

Page 11: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Chapter 2

Background - Rendering

This chapter presents a background of rendering subdivision surfaces starting withthe simple form of functional curves in two dimensions, after which parametric curvesare discussed. Moving on to three dimensions polygonal nets and parametric surfacesare described before subdivision surfaces in their different forms are explained.

2.1 Two Dimensional Curves

Most surfaces with a mathematical description are built up from curves in variousways. To get a B-spline surface (see section 2.2.3), for example, two orthogonalsets of B-spline curves are combined. Consequently rendering surfaces relies heavilyon the theory of curves, where I will begin the explanation. For a more thoroughpresentation there are numerous books on computer graphics and rendering, forexample (Angel, 1997).

2.1.1 Explicit form, Implicit form and Parametric Curves

The simplest form of describing curves is the explicit form y = f(x) where x and yare coordinates in the plane. This representation is obviously severely limited, forexample the inability of y to take more than one value for a given x makes closedcurves impossible.

In contrast there is the implicit form where the curve is defined by the equationf(x, y) = 0, i.e. every point (x, y) which fulfils this equation lies on the surface.The major obstacle to this approach is that there is in general no well defined wayto analytically compute the values of the curve. The form works well for collisiondetection though, and has seen some use in the form of algebraic surfaces where fis a sum of polynomials, more specifically quadratic surfaces where no term has adegree above 2.

The most common representation however, is the parametric form. The idea isthat both x and y are controlled by a common parameter, commonly called t or u,i.e. for two dimensions x = f(u), y = g(u) The u parameter can be thought of asa time value and as the time moves forward the curve is drawn. The parametric

4

Page 12: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

curves can with this description take on any value but to help control and analysisthere are strict limitations placed upon them in real world usage. Most commonlyused are parametric polynomial curves where the f and g functions are given bypolynomials up to a given degree—the degree of the curve.

2.1.2 Spline Curves

In their original form spline curves are defined by a list of control points throughwhich the curve will pass. In its simplest form this yields a polynomial curve whosedegree is determined by the number of control points. Except for trivial cases thenecessary degree is equal to the number of control points minus one. The idea ofspline curves means that local changes of control points by design affects the entirecurve, which reduces the possibilities of any detailed control.

The standard spline described above is an interpolating curve, i.e. it will passthrough each of the defining points. The resulting mathematical system is simplebut hard to control for the designer. The less obvious approach is to let some of thecontrol points to be “nearly” reached and instead control the direction of the curvedirectly. One common implementation of the principle is the Bézier curve (fig. 2.1)where every point defined is weighted by a function giving the following function forthe curve

C(u) =n∑

i=0

Bn,iPi

where Pi are the control points. The weighting functions, B, are the Bézier basisfunctions, defined as

Bn,i(u) =n!

i!(n − i)!ui(1 − u)n−i

This means that the point of the curve at u (0 <= u <= 1) is a combination ofall the defining control points, weighted by the B-functions, none of which are zeroduring the interval. Consequently, although the closest points affect the curve themost, all of them are included to some degree in its entire length. The previouslymentioned problems of local changes having a global effect thus remains for Béziercurves, though to a lesser degree.

p0

p1

2p

p3

Figure 2.1. A simple Bézier curve.

5

Page 13: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

2.1.3 Piecewise Polynomial Curves

To reduce the problem further the curve is split into segments, each being a polyno-mial curve of lower degree. This modification introduces the problem of joining thesegments together smoothly. Another drawback is that a greater number of controlpoints are required to achieve this local control, compared to a single polynomialcurve.

The patches of the Bézier curves patches can be joined together by letting adja-cent patches’ endpoints (which the curve passes through) coincide, and to smoothenthe transition the derivatives in the joint points are modified to point in the samedirection. This can quickly become unmanageable, and additionally the curve willnot even be C1 continuous at the join points without extra work.

2.1.4 B-Spline Curves

B-splines formalises the partitioning of the Bézier curve by modifying the B-functionsby zeroing them except for the area “close to” the points in question. This is doneby a sliding function weighting the points

N0i (u) =

{

1, if ui ≤ u < ui+1

0, otherwise

N ri (u) =

u − ui

ui+r − ui

N r−1i (u) +

ui+r+1 − u

ui+r+1 − ui+r

N r−1i+1 (u).

where r is the degree of the curve. To understand the functions it is easiest to startby building them from degree zero. In this case, the value of N0

i is 1 if u is inthe span governed by the i-th point otherwise it is zero. This means that only thecontrol point governed by this knot will define the curve in this interval. To getthe N-function for higher degrees the functions of one degree lower are combined(multiplied). Note that the higher the degree the smoother the curve will be, butnaturally, at the same time local changes will have an affect over an larger span (fig.2.2).

Ni,0 Ni,1 N i,2

Figure 2.2. The N-functions for degrees zero, one and two.

For a curve of degree r, the control point i will affect the curve in the interval[ui, ui+r+1).

The N-functions have some important properties:

Partition of unity:∑

i Nr(u − i) = 1

6

Page 14: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Positivity: N r ≥ 0

Local Support: N r(u − i) = 0 if u 6∈ [i, i + r + 1]

Continuity: N r(u) is (r − 1) times continuously differentiable

The first two gives the complex hull property for the curve meaning it is containedin the convex hull of the points, and the locality and continuity (depending on degree)are important properties for design uses.

To form the B-spline curve the N-functions are used to weight the control pointsaccording to the following formula:

C(u) =n∑

i=0

N ri (u)Pi

where 0 ≤ u ≤ 1, r is as above the degree of the curve and P is the vector of controlpoints, also known as de Boor points. The resulting curve is consists of pieces ofdegree r or less. n is the number of control points minus 1, as the index starts atzero. Using this value instead of the number of control points simplifies the formulae.From the definition it is also evident that the Bézier curve is a special case of B-spline curves. If the degree r is equal to n a Bézier curve of degree r and there are2(r+1) = 2(n+1) knots where r+1 of them are placed in the same position at eachend, known as “clamped”, the B-spline becomes a Bézier curve. This reduction ofthe B-spline highlights that this more advanced rendering technique comes at a costof higher complexity, i.e. it requires the extra degree parameter and the N-functions.However the separation between the degree of the curve and the number of controlpoints yields an increased flexibility as it replaces longer, unmanageable curves withsmoothly connected curve patches of lower degree.

2.1.5 NURBS Curves

Even though B-splines are a far more flexible tool than Bézier curves there are stillsome forms which cannot be described by them. Most prominently these includethe circle as it requires a rational function, i.e. a quotient between two polynomials,which B-splines obviously do not satisfy. To overcome this regular B-splines areextended to what is called Non-Uniform Rational B-splines, or NURBS, where thenon-uniformity derives from the fact that every control point has an associatedweighting factor wi. The definition of a NURBS curve is thus:

C(u) =1

∑ni=0 N r

i (u)wi

n∑

i=0

N ri (u)wiPi

where, as before, r is the degree of the curve and n is the number of control pointsminus one. The control point vector P consists of homogeneous coordinates to

7

Page 15: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

accommodate for the weighting of the points. The close relationship with B-splinescan be seen if the definition is rewritten as:

C(u) =n∑

i=0

Rri (u)Pi

where Rri (u) is defined as

Rri (u) =

N ri (u)wi

∑nj=0 N r

j (u)wj

The details of NURBS are many and complex and will not be further discussedhere, but further reading can be found in (Piegl and Tiller, 1997) where in particulartheir uses in computer graphics are described.

2.1.6 Subdivision Splines

The concept of subdivision exists for curves but is rarely used. The simplicity ofone dimension however is ideal for an explanation of the technique.

One key property of B-splines is that the function can be refined, i.e. be writtenas a linear combination of modified copies of itself

N r(u) =1

2r

r+1∑

k=0

(

r + 1k

)

N r(2u − k).

The copies are translated by k and dilated by 2u. r in the formula is the degree ofthe B-spline curve which thus remains the same. See (Zorin and Schröder, 2000) fordetails and a proof. This refinability of B-splines is what is behind the principle ofsubdivision. The B-spline function

C(u) =∑

i

N ri (u)Pi

can be rewritten in matrix form after some slight modifications. The control pointvector P is written as

P =

. . .r−2

r−1

r0

r1

r2

. . .

and the vector of basis functions N r(u) as

N r(u) = [. . . N r(u − 2) N r(u − 1) N r(u) N r(u + 1) N r(u + 2) . . .] .

8

Page 16: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

In refined form that becomes

N r(2u) = [. . . N r(2u − 2) N r(2u − 1) N r(2u) N r(2u + 1) N r(2u + 2) . . .]

or, using a refinement matrix S for the transformation

N r(u) = N r(2u)S

where the entries of S are given by the equation above to

s2i+k,j = sk =1

2r

r+1∑

k=0

(

r + 1k

)

.

The curve can then be written as

C(u) = N r(u)P = N r(2u)SP.

This refinement process can be continued in infinity and the control points will movecontinuously closer to the true B-spline curve giving after j steps

C(u) = N r(2ju)SjP

For one new control point the step at j + 1 is:

pj+1i =

r

Sri p

jp

The new control points can be divided into odd and even entries each with theirown equations

pj+12i+1 =

r

s2(i−r)+1pjr, for odd

pj+12i =

r

s2(i−r)pjr, for even

The odd control points are the ones newly inserted by the subdivision step, and theeven ones are the refined version of a control point from the previous control pointlist. In the case of linear splines, where the basis function is a linear “hat” function,the even points are not moved during the refinement, and thus never moved. Everynew point will be placed on the final curve upon insertion. Subdivision algorithmshaving this property are called interpolating. Versions where every point is refinedcontinuously (where pj+1

2i 6= pji , with above definitions) are called approximating.

2.2 Surfaces

2.2.1 Polygonal Surfaces

The Polygonal surface is the simplest surface model, simply consisting of a set ofpolygons making up the final surface. The surface can thus have any form including

9

Page 17: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

disjunct parts, but it does have problems with showing smooth surfaces withoutgenerating prohibitively many polygons. Additionally, the lack of underlying struc-ture increases the complexity of modifying the model while keeping it smooth andcontinuous. From a haptic perspective, too small polygons in areas of high curva-ture can lead to instabilities in the haptic rendering as the proxy can collide withseveral different surfaces. To avoid this, it has to be ensured that the interface pointremains fairly stable for small proxy movements as there might be several possiblecollision planes (fig. 2.3).

Figure 2.3. A curved surface might move the points of interaction over the surface(and the polygon representation of it) if the point selection is unstable.

2.2.2 Parametric Surfaces

Parametric surfaces are an extension of the parametric curves combining two or moresets to span a surface. As a basis any of the above curve types are possible, butmost commonly from NURBS curves. As the techniques are very similar I will onlydescribe B-splines surfaces which, though simple, are very relevant for subdivisionsurfaces. The details on NURBS surfaces can be found in (Piegl and Tiller, 1997).

2.2.3 B-Spline Surfaces

B-spline surfaces are formed by computing a tensor product of two separate B-splinecurves resulting in a function very similar to the curves’

Sr,s(u, v) =m∑

i=0

n∑

j=0

N ri (u)N s

j (v)Pi,j

where r and s are the degrees of the composing univariate B-splines, and N ri (u)

and N sj (v) are their respective sets of basis functions. P is the control points for

both splines arranged in a mesh, the so called de Boor net. The similarities to theunivariate case can be enhanced with some renamings

i = (i, j)u = (u, v)

N r,s(u) = N r(u)N s(v).

10

Page 18: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

The resulting formula is almost identical to the univariate case

Sr,s(u) =∑

i

N r,si (u)Pi

The combined set of N-functions N r,si (u) retains all the previously mentioned prop-

erties of its parts (section. 2.1.4) This implies that the convex hull of the de Boornet is also a convex hull of the final surface and it has also local support and iscontinuously differentiable in both directions.

B-spline surfaces are completely regular in their design, every patch has to havethe same net of control points defining it—16 points in a four-by-four square whereevery point has valence 4. This means that only a few topologies, an infinite plane,an infinite cylinder and a torus are really possible to define. The infinity criteria canbe relaxed by handling edges of the B-spline surface with minimal effort. Still, mostsimple geometrical forms are not possible. As an example a cubic control mesh haseight points of valence 3 (fig. 5.4). Designing the model with 6 unconnected surfacepatches is inefficient and impractical in the general case. Consequently B-splinesurfaces themselves are rarely used in computer graphics, but they serve as a basisfor the more common form of NURBS and subdivision surfaces.

2.2.4 Extraordinary Vertices

What makes B-spline surfaces almost unusable is the existence of extraordinaryvertices in most models. These are vertices with valence different from the regularmesh vertex. For example the B-spline surfaces use a quadrilateral mesh (fig. 2.4),thus any vertex with valence not equal to four will be extraordinary. Technicallythis includes the surface’ edge vertices, but it is a trivial task to extend the B-spline algorithm to accept such vertices. What cannot be easily accommodated areinternal extraordinary vertices (fig. 2.5), which is why subdivision surfaces whereconstructed. These can render a surface on an arbitrary mesh.

Figure 2.4. A regular quadri-lateral surface.

Figure 2.5. A quadrilateralsurface with two extraordinaryvertices.

2.2.5 Subdivision Surfaces

The idea behind subdivision surfaces is almost trivial. Starting with a control netwhich in itself is a coarse approximation of the surface the net is split according to

11

Page 19: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

a given algorithm where new vertices and edges are introduced, weighted by nearbyvertices. The process is repeated and in infinity a smooth surface is reached. Thesealgorithms are designed for surfaces with irregular topology which B-spline surfacescannot handle and NURBS handles poorly. Loosely described the algorithms alltreat these meshes in the same way—extraordinary vertices are separated by the in-troduction of new regular vertices and then treated surrounded by a regular surface.Except for handling irregular meshes subdivision surfaces also lend themselves verywell to uses in design due to their hierarchical structure and have already been usedin computer animated features. Finally, subdivision in itself contains the idea oflevel of detail (LoD) renderings, where the same object can be rendered in differentdetails according to need. In fact, the level of detail of the same model can, withslight extensions of the algorithm used, vary over the surface. For example areaswith high curvature can be subdivided more than flatter areas, and parts of a surfacecloser to the viewpoint can be subdivided more and thus rendered smoother.

2.3 Subdivision Mathematics

Subdividing B-spline surfaces is analogous to subdivision of the B-spline curve. Therefinement of the B-splines is concurrently performed along both axes converging onthe described surface, refining the control points and introducing new points. Tocombine the new set of points when forming a curve the associated N-functions, tooare refined

N r,s(u) =∑

j

cr,sj−iN

r,s(2 − (u− j))

where c is a weighting of the previous N-functions. Substituted into the definitionof the B-spline surface this yields

Sr,s(u) =∑

i

dr,si

j

cr,sj−iN

r,s(2(u − j))

from which follows that the refined knots of the mesh are

dr,s′

j =∑

i

cr,sj−id

r,si

wherecr,sj ≡ cr

i csj .

Thus the weights c are

cr,sj = 2−(r+s)

(

r + 12i

)(

s + 12j

)

.

For example, if r = s = 2 the new knot d′

is constructed by weighting the previousknots as follows (zero weighted knots are omitted)

d′

0,0 =1

16(9d0,0 + 3d1,0 + 3d0,1 + d1,1)

12

Page 20: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

These values (9/16, 3/16, 3/16, 1/16) are the weighting of the points around the facein which the new point is placed (as the weight is always positive). The weightingscheme is called the subdivision mask and can be displayed in a geometrical fashion(fig. 2.6).

3/16

9/16

1/16

3/16

Figure 2.6. The subdivision mask for the N2,2 surface (bi-quadric). On every face

four new nodes are placed. The mask for the other three new vertices are symmetric.

As the mathematical side of subdivision is complex, the algorithms will be pre-sented mainly by their subdivision mask. Not all subdivision schemes are this simpleor even based on quadrilateral meshes. Loop subdivision (Loop, 1987), for example,is based on triangular meshes, which is clearly visible from its subdivision mask (seesection 2.5.2).

Note that the above math is all given under the assumption that the underlyingcontrol mesh is regular, yet the promise of subdivision was that it would be ableto handle arbitrary meshes. The solution lies in the fact that the subdivision maskis very easy to modify to handle meshes with extraordinary vertices breaking upthe regularity. Further more, as the mesh is refined, only regular points will beintroduced and no new extraordinary points have to be handled.

2.4 Calculating the Matrix

To evaluate subdivision surfaces a matrix description is commonly used, here it istaken from the original text on the subject by Catmull and Clark (Catmull andClark, 1978). In matrix form the B-spline patch’s double sum from above can berewritten as

S(u) = UMPMT V T

where M holds the coefficients for the B-spline calculation. For example, for thebi-cubic patch used in Catmull-Clark, the matrix is

M =1

6

−1 3 −1 13 −6 3 0

−3 0 3 01 4 1 0

and P is the matrix of the control points

P =

p1,1 p1,2 p1,3 p1,4

p2,1 p2,2 p2,3 p2,4

p3,1 p3,2 p3,3 p3,4

p4,1 p4,2 p4,3 p4,4

13

Page 21: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

U and V are the basis vectors. In the bi-cubic case these are U = [u3 u2 u 1] andV = [v3 v2 v 1].

To simplify the presentation only a sub-patch will be considered, in this case thearea where 0 < u, v < 1/2, as the remainder follows through symmetry. After thesubstitution u1 = u/2 and v1 = v/2 the sub-patch S(u1, v1) can be written as

S(u1, v1) = USMPMT ST V T

where

S =

1/8 0 0 00 1/4 0 00 0 1/2 00 0 0 1

and the other matrices are as defined above. As the sub-patch is a B-spline patchin itself is satisfies the equation

S(u1, v1) = UMP′

MT V T

where P′

is a vector with the new control points. These two equations for S(u1, v1)are equal for all values of u and v giving

MP ′MT = SMPMT ST

assuming that M is invertible, which it is, the formula for calculating new controlpoints can be written as

P ′ = M−1SMPMT ST M−T = H1PHT1

where H1 = M−1SM is called the splitting matrix. In the bi-cubic case it is

H1 =1

8

4 4 0 01 6 1 00 4 4 00 1 6 1

.

From this matrix the subdivision masks are obvious, e.g. the first point in P′

canbe calculated to

p′

1,1 = 1/64 ∗ (16 ∗ p1,1 + 16 ∗ p1,2 + 16 ∗ p2,1 + 16 ∗ p2,2)

which is the applied face mask as seen in section 2.5.1. Masks for edges and verticescan be similarly calculated.

As mentioned before, until this point only regular quadrilateral patches havebeen treated, yet subdivision aims to handle arbitrary meshes of control points.This requires a slight modification of the subdivision rules. For convenience themodified algorithm is described as a set of rules (fig. 2.7 for an example of theirapplication):

14

Page 22: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

1. New face vertex - the average of the vertices in P defining the face.

2. New edge vertex - the average of the midpoint of the edge in P and the twonew neighbouring face vertices in P

.

3. Refined vertex - the average

Q/n + 2R/2 + p(n − 3)/n

where n is the valence of the vertex, Q is the sum of the adjacent new facevertices in P ′ and R is the midpoints of the edges in P leading out from theold vertex.

3.

2.

2.

2.

2.

1. 2. 1.

2.

2.

2.

3.

3. 3.

3.

3.

3.

Figure 2.7. The subdivision rules applied. The filled in vertices are in P and theshaded ones are the new vertices. The number next to them defines by which rulethey are defined or refined.

2.5 Subdivision Categories

Subdivision algorithms can be categorised on several aspects. The most obvious isthe choice of base mesh, where the most common is the quadrilateral mesh usedfor example by the original Catmull-Clark (Catmull and Clark, 1978) and Do-Sabin(Doo and Sabin, 1978) algorithms. As this type of control mesh is already used byregular B-spline surfaces and NURBS Surfaces—it is simply a result of making atensor product of the curve case—it is quite common. The second most used is thetriangulated mesh used in the Loop algorithm (Loop, 1987) which yields a tri-variateB-spline surface. Recent attempts, such as 4–8 subdivision (Velho and Zorin, 2001),uses a mixture of quads and triangles.

Another distinction is to choose between interpolating and approximating algo-rithms, i.e. if the surface will pass through the given control points or only “aim”for them. The instinctive choice might be to select an interpolating surface as this

15

Page 23: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

gives exact control of where the surface will be, but it has been shown (Zorin andSchröder, 2000) that these give a less smooth surface than approximating versions.That all the algorithms discussed below are approximating is not a conscious se-lection, but only a testament to the fact that interpolating algorithms are rarelyused.

For the smoothness of the surface the degree of the surface is taken into account.The degree limits how differential the surface is, that is how differential the underly-ing curve is in the connection points as the polynomial which makes up the patches isnaturally infinitely differentiable. For example Catmull-Clark yields a surface whichis of degree 3, and in general thus a cubic B-spline surface. Extraordinary verticesare handled separately and are for Catmull-Clark only C1 continuous.

2.5.1 Catmull-Clark

The Catmull-Clark surfaces were the first subdivision based surfaces introduced asearly as 1978 in a paper (Catmull and Clark, 1978) along with Doo-Sabin (Doo andSabin, 1978), and they are still the most commonly used. It took a long time beforeit was widely used, as technology needed time to catch up in computational power,and only in the mid 90s did subdivision surfaces become incorporated in designpackages.

Catmull-Clark subdivision is based on a quadrilateral mesh and around regularvertices (of valence four) it is a regular B-spline surface. The scheme uses cubicsplines on both axis and its subdivision masks are shown in fig. 2.8.

1/2

1/4

1/4

1/4

1/4

1/16

1/16 1/16

1/16

3/8 3/8

1/64

3/32

1/64 1/64

1/64

3/32

3/32

3/32

Figure 2.8. The subdivision masks for a bi-cubic B-spline surface such as Catmull-Clark. From left to right, the face mask (used for weighting vertices placed on a faceof the old control mesh), the edge mask (for vertices placed on edges of the old controlmesh) and the vertex mask (for refining the old vertices) respectively.

The subdivision step introduces three new vertices for every vertex in the pre-vious control mesh at every iteration all of them being regular. Thus the onlyextraordinary vertices in the final mesh are those present in the original one.

A more thorough mathematical description can be found in the above chaptertreating the mathematics behind subdivision surfaces, where Catmull-Clark is usedas an example.

16

Page 24: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

2.5.2 Loop

In 1987 Charles T. Loop formulated a different set of subdivision surfaces, whichdiffered from previous attempts as it was based on a triangulated surface (Loop,1987). The result is a C2 continuous tri-variate B-spline surface. Its subdivisionmask for regular vertices (fig. 2.9) is easily extended for extraordinary vertices.Despite the fact that triangulated surfaces are more frequently used in computergraphics due to their simplicity, it is not clear that this would bring any advantagesto subdivision.

1/8

1/8

3/8 3/8

1/64 1/64

1/641/64

1/64 5/8 1/64

Figure 2.9. The loop subdivision mask, for edges and the vertices.

2.5.3 Recent Attempts

In recent years, as the use and experience of subdivision surfaces has increased, anumber of new schemes have emerged. Both these new schemes aim to reduce thenumber of new polygons created at each step in the subdivision. As the increaseis still exponential additional strategies have been introduced to only subdivide“where necessary”, i.e. where there is high curvature in the surface, needing a morefine grained subdivision.

An example of the new schemes is 4–8 subdivision which takes its name fromthe fact that the subdivision generates new vertices of valence 4 and 8, creating a4.8 tiling (fig. 2.10).

Figure 2.10. A 4.8 tiling.

17

Page 25: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

The rules for the algorithm are described in (Velho and Zorin, 2001), they arevery simple but create a mathematically advanced surface with four-directional andC4 continuous splines. One advantage of the scheme is that new vertices are placedonly by bisectioning edges, thus only a single rule for the subdivision step. Afterthe bisection all the vertices are repositioned by an averaging filter.

The creators of the scheme present how to proceed to implement an adaptivesubdivision technique where the depth of subdivision varies over the surface. Exceptfor deciding where additional subdivision is needed the technique handles gracioustransitions between subdivision of different levels so that the mesh maintains con-formity (fig. 2.11). The reason for why this scheme was not used is the complexityof the resulting surface, as seen by the pictures and the exact evaluation algorithmneeded had not yet been developed for this scheme. Finally, the 4–8 subdivisionhad not yet been implemented to any great extent and therefore it had not got the“experience” which for example Catmull-Clark has.

Figure 2.11. Gradual increase in the subdivision level for 4–8 subdivision.

2.6 Volume Subdivision

As the concept of subdivision can be expanded from curves to surfaces, it can withlittle effort be expanded into volumes. The earliest versions modified Catmull-Clarkto base it on hexahedral meshes, but despite the obvious extension to three di-mensions, the resulting subdivision scheme was fairly hard to analyse in terms ofsmoothness and regularity. To counter this a new volumetric subdivision was intro-duced in (Bajaj et al., 2001) which was also based on quad subdivision extendedto hexahedra. The technique described works equally well for higher dimensions, orlower—the standard surface case. The scheme has the same two stepped approachas 4–8 subdivision previously mentioned (section. 2.5.3), first the network of verticesis subdivided and then every vertex—new and old—are averaged to reach a smoothsubdivision. The resulting geometry is based on a 3D-mesh of cubic splines. Thepaper presents a smoothness analysis both for the surface and the volume case.

A radically different approach is presented in (Chang et al., 2002). The netof vertices is here still made up out of splines, but the basic forms in 3D are notcubes but tetrahedra and octahedra formed in octet–truss (fig. 2.12). The technique

18

Page 26: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

requires some more research to deal with special cases around some extraordinaryvertices, but a variety of test cases are presented in the article.

Figure 2.12. A part of the octet-truss. In between the octahedra tetrahedra arefitted to make a continuous volume.

The volumetric subdivision is primarily used for controlled deformation of ob-jects, but might in the future, with increasing computational power, be used formodelling physical properties of objects. Yet at present this is very much a researcharea.

2.7 Uses of Subdivision Surfaces

Subdivision, while being a fairly old concept in computer terms as it was first pre-sented in 1978, did not really start to take off until the mid 1990s, when computerswere getting powerful enough to calculate the sometimes advanced mathematics.NURBS had then already been used for a number of years in design and modelling,and while being a considerable improvement over previous methods for handlingsmooth objects, it was still quite cumbersome for some tasks. Since subdivision wasintroduced it has started to complement NURBS in modelling packages for 3D-designand in the last years even animation (Zorin and Schröder, 2000) (fig. 2.13), wherethe hierarchical structure is readily taken advantage of for controlling movements ofcomplex models.

Figure 2.13. The short film “Geri’s game” by Pixar Animation Studios demonstratedthe use of subdivision surfaces there being primarily used for animating cloth andtextiles.

Naturally, subdivision surfaces is no panacea for every problem facing designersor animators, but still offers a valuable tool.

19

Page 27: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Another area where subdivision has been used is in fitting a surface to a numberof points. This is commonly a first step in modelling where a physical model has beenproduced and is scanned for a virtual representation. This is an old concept, butthere is still no general fully automated way of reconstructing the object surface fromthe measured points—human intervention is needed to smooth parts and removeartifacts from the surface. Naturally, as much automation as possible is desiredand subdivision’s hierarchical and mathematical structure seems to be one goodapproach of increasing this (Friedel et al., 2003).

2.8 Exact Evaluation of Subdivision Surfaces

One major obstacle to implementing subdivision surfaces was that there was, for along time, no way of calculating points on the surface to a sufficiently precise valuewithout performing the subdivision, which is not practical for real-time rendering. Away to perform this calculation efficiently for Catmull-Clark Surfaces was presentedby Jos Stam in 1998 (Stam, 1998b). The basic theory is so general it relatively easilycan be applied to most other subdivision algorithms, such as the Loop scheme whichwas later presented, again by Jos Stam (Stam, 1998a). He also used these ideas inhis implementation of subdivision surfaces in the design package Maya®. So whilethere has been some discussion of the numerical stability of the algorithm (Zorinand Kristjansson, 2002) there is evidence that the basic theory works in practicalapplications. Here follows a short description of how to perform the evaluation ofthe Catmull-Clark surface, the details are found in Stam’s original article (Stam,1998b).

2.8.1 Splitting the surface

The basic idea of exact evaluation is to iteratively split the patch with the extraor-dinary vertex into smaller pieces (fig. 2.14). As a first step the patch is transformedto the unit square. Each split will generate three areas which can be calculated asa regular B-spline with a new set of control points and a fourth quadrant, next tothe extraordinary vertex, can then be repeatedly subdivided, i.e. new control pointsare produced, until the searched point is found in one of the quadrants.

The final value is a weighted summation of the B-spline values from the necessarysubdivided quadrants. To calculate the quadrant value a matrix multiplication isperformed in each step, using the same subdivision matrix, which is a key insight tothe evaluation. The matrix, A, can be decomposed into a matrix of its eigenvectorsV and a diagonal matrix with eigenvalues Λ:

A = V ΛV −1

To compute the B-spline values the new coordinate values are needed. Due to toa somewhat peculiar coordinate ordering of the coordinates the equation can bewritten as (compare with section 2.4)

Cn = ACn−1

20

Page 28: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Figure 2.14. Repeated partitioning of a patch next to an extraordinary vertex.

which with the help of the decomposition of A can be transformed into

Cn = ACn−1 = AAn−1C0AV Λn−1V −1C0

where Cn are the new coordinates after n subdivisions. The bar above C signifiesthat the coordinate vector contains extra coordinates needed for evaluation. LikewiseA is the extended version of the subdivision matrix A to calculate these extra points.

2.8.2 Implementing Exact Evaluation

To implement exact evaluation, the most demanding calculations can be performedonce and stored to file. These include the eigenvalues needed for Λ and the eigen-vectors and their inverses, and the splines for calculating the quadrants. Due to theeigenvalue properties, only a limited number of splines are combined to get the val-ues where the exact number of splines depends on the valence of the extraordinaryvertex. Eigenvalues, eigenvectors and splines need all be pre-calculated for everyvalence present in the model, but luckily most realistic models have limited valenceof their vertices and if a high enough valence is chosen, this will in practice never bea problem. Using this eigenstructure for the coordinate evaluation is considerablyfaster than a calculation of An the standard way.

2.9 Rendering Subdivision Surfaces

There have been early attempts of rendering subdivision in a haptic environment,as presented for example in (Raymaekers et al., 2001). Here the surfaces are splitbeforehand according to the subdivision rules and the resulting polygons are thenhaptically rendered individually. In this case the polygons where triangles as Loopsubdivision was used (see chapter 2.5.2). To speed up the evaluation process the im-plementation took advantage of the hierarchical nature of the subdivision to reducethe time needed for finding polygons being haptically interacted with. The disad-vantage of this approach is that the rendered surface is still only an approximationof the resulting surface and with all the possibilities there are for lack of smoothness

21

Page 29: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

at the edges between polygons. In the paper a speed comparison is made to a naïverendering approach where every generated polygon is checked for collision, but noanalysis is made to how the haptic surface depends on the subdivision levels and ifthe lack of resolution is evident. Still it proves that subdivision can be used in hapticrendering with possible advantages compared to standard rendering of polygon nets.The question was, could it be improved further?

22

Page 30: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Chapter 3

Using Exact Evaluation for Haptic

Rendering

This chapter describes how the exact evaluation algorithm was adapted to performrendering of subdivision surfaces both as a graphical and a haptic surface. It isconcluded by a brief discussion on efficiency and what was not included in theimplementation.

3.1 A New Approach to Haptic Rendering

Instead of performing the subdivision as was done in the previous implementation ofhaptic subdivision surfaces the idea is to use Jos Stam’s method of calculating thesurface exactly. The basic aim is to find the closest point (or points) on the surface tothe haptic representation (the proxy) and check these for collision with it. By usingexact evaluation the point of contact can be calculated to an arbitrary resolution,except for limits of the underlying hardware in use. The limits on the exactness willbe the same for the entire surface, not, as is the case if the surface is subdividedin advance, dependent on how many subdivision steps have been performed. Inshort, this new idea will in theory yield the exact haptic target surface, not anapproximation. There will also be less of the sometimes troublesome edges betweenpolygons. Some edge problems will remain as there will still be edges between thepatches.

To find the closest point on the surface a number of evaluations of points haveto be made as a part of a minimisation. A few candidates have to be evaluated andmight in some cases be kept throughout the process into the force rendering stageas the haptic instrument might be touching the same surface in a number of placesat the same time.

A possible drawback is that the calculations will not be able to keep up withthe high rate needed for smooth haptic rendering. This is one area where tests willhave to be made to see exactly what the demands are on the computer hardware

23

Page 31: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

for this solution to subdivision surfaces. However, as computers get more powerfulany problems with the current hardware could be alleviated by new equipment.

3.2 The Effects on Graphics Rendering

While the haptic surface can be evaluated exactly the graphical representation stillneeds to be approximated. This rises the concern that the graphic and hapticrepresentation will no longer be compatible. However, if the graphic resolution ishigh enough, no visible discrepancies should be evident in the view.

To simplify the implementation the decision was made that, instead of perform-ing a true subdivision of the surface, every patch is sampled at set distances andevaluated exactly using the same method as for haptics. The result is a fine grainedmesh of quads, which closely resembles the target surface if the distances chosenare small enough. Obviously, nothing in the design prevents the use of a partiallysubdivided surface as used in previous implementation, but it will still not matchthe haptic presentation exactly. The limitation is only of theoretical significanceas models will be quite simple to subdivide to a sufficient level, ensuring that nonoticeable difference between haptic and graphic representation will be present.

The idea has another possible drawback—the haptic model lacks the Level ofDetail (LoD) property of subdivision surfaces. If less resolution is needed on asurface, e.g. if it is has a small representation on screen, less subdivisions can beperformed to reduce the number of polygons in the scene. As exact evaluationcompletely skips the subdivision step this will not be an option. Possibly a methodcould be developed to replace the object by a simple polygonal model, but thiswould introduce a parallel rendering technique with all the extra work it implies.Luckily the most common reason to use a lower level of detail, that the object isfar away on the screen, is rarely an issue as most haptic applications work in just asmall volume—the haptic rendering of objects which are not reachable is naturallyof little importance.

3.3 Choosing an Algorithm

One of the main tasks was for me to select which subdivision strategy to use for theimplementation. As seen above there are quite a few different algorithms availableat present. My intention to build on Jos Stam’s work limited me to Catmull-Clark(Catmull and Clark, 1978) or Loop (Loop, 1987) as these were already describedby him in detail. As he himself explains in (Stam, 1998a) the theory should bepossible to adapt to most subdivision algorithms, but due to time constraints I feltthat performing such an adaption was outside the scope of the thesis.

Of the two remaining, Loop has the advantage of using the in the graphicscommunity common triangle mesh for its control vertices. Additionally, there is adeeper analysis of the exact evaluation in (Zorin and Kristjansson, 2002). However,Catmull-Clark is the more common method by far and as the control mesh in regular

24

Page 32: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

area is a well known B-spline surface it can use similar evaluation techniques toNURBS surfaces’. As my work was done in conjunction with Reachin’s developmentof a NURBS toolkit the possibilities of code reuse tipped the scales in advantage ofCatmull-Clark surfaces. The further analysis of Loop surfaces would probably notbe of much use in this rough prototype of subdivision surface rendering.

3.4 Efficiency and Stability Concerns

Disregarding the advantage of having the rendered surface in an exact haptic pre-sentation, there exists the possibility that the rendering method is more efficientthan doing a subdivision of the surface. Equally possible is that it is slower thanthe traditional method, even un-workably so. The most demanding calculation isperformed once and saved to file and some extra work is needed in the startup faceto transform the surface to a rendering efficient representation, but these do notaffect the real-time performance. The big issue is the minimisation needed for find-ing the exact collision point in the haptic loop. This is significant work and needsto be performed frequently. In addition more than one possible point of collisionmight need to be checked at every stage. The iterative design of the minimisationwhere the number of loops can vary and the loosely controlled number of candidatesmakes it very hard to theoretically evaluate the performance of the idea and testingis preferred.

Another reason for caution is that numerical minimisation algorithms need finetuning or instabilities might ensue. This was experienced by the Reachin team whenNURBS were implemented in a similar fashion. In this case, too, tests are required.

3.5 Shortcuts Taken

To limit the scope of this thesis a number of shortcuts were taken.

No subdivision - this might come as some surprise, but as subdivision has beendone before, even in a haptic environment, the decision was made that as inputonly already sufficiently subdivided surface was going to be accepted, i.e. nomore than one extraordinary vertex (section 2.2.4) per patch.

Patch based - the implementation will take surfaces, described as a set of quads,but internally the representation will be patches. This has no visible effecton the graphical rendering, but in the haptic rendering the “cracks” betweenpatches will be very obvious.

Only full patches - the only rendered patches are the “complete” patches, whichhave all their neighbours defined, i.e. no edges are rendered. How to solve thishas not yet been presented by Jos Stam, even though he has implemented thisin Maya®. There should however not be any major obstacles to adding thatpart of the implementation to the haptic environment, only technicalities.

25

Page 33: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Naturally, many other shortcuts are taken in the implementation until a stableversion is found as the goal is not to make a production quality implementation butonly a proof of concept.

26

Page 34: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Chapter 4

Overview of the Implementation Design

To use the subdivision surface I had to construct a node which can display itselfas well as generate a haptic representation. To simplify I chose to first divide thesurface into a set of patches, either regular or extraordinary, i.e. patches with onecorner with a valence number different from 4. The regular patch was implementedfirst and is simply a B-spline patch.

4.1 The Regular Patch

To generate the regular (B-spline) patch I needed the ability to calculate the splinecoefficients for a given surface coordinate (u,v). This was achieved by insertingthe B-spline matrix into the mathematics program Maple and letting it generateC code. The graphic presentation was then generated by sampling the surface atregular intervals to build a net of quads which can be rendered. This coarse meshis also used in the collision detection to find likely interaction points. More on thehaptic part follows below.

4.2 The Extraordinary Patch

The extraordinary patch needs considerably more work than the regular one. Thefirst task is to calculate the eigenvalue structures as described in (Stam, 1998b).This is done for vertices up to a fixed valence. The data was saved to file and loadedat initialisation time by the patch. The control points are then transformed withthe use of the inverted eigenvectors to the eigenspace, a calculation which is redoneonly if and when the points have changed. The final calculation of the values weredone according to Stam’s algorithm.

As mentioned above regarding the regular patch, a coarse mesh was calculatedboth to generate the quads needed for the graphical representation and to find ap-proximation of the possible point of collision. Note that the mesh does not represent

27

Page 35: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

a true subdivision of the patch as the algorithm is not followed. Hopefully the par-titioning is finely enough grained that the graphical representation does not conflictwith the experienced haptic representation.

4.3 Basics of the Haptic Implementation

When the patches—regular as well as extraordinary—have found a possible pointof collision by using the coarse mesh the real-time version of the patches has todetermine the exact point on the patch where contact occurs and the normal vectorof the surface at that point. Note that the aim is only to find the most likely pointon the surface to collide, i.e. closest to the virtual haptic device. The details of thecollision and force generation is handled by the Reachin API core functionality andare beyond the scope of this work.

To find the point of collision in the haptic loop, first a sampling is done inthe graphic (scene-graph) loop to get an approximate point. This is done by firstfinding the closest mesh point and then refining it using the minimisation algorithmDavidon-Fletcher-Powell (DFP) found in Numerical Recipes in C (Press et al., 1997)(pp. 425-430). The function to minimise—the calculation of the distance betweenproxy and surface—depends on if it is a regular or an extraordinary patch. Regularpatches are simple B-splines while the extraordinary ones need the exact evaluationalgorithm discussed above. A new minimisation is performed every run of the hapticloop to refine the point according to changes in the proxy position. When the pointhas been determined a normal vector is calculated at that point as it is neededfor the force rendering. The normal vector is calculated by simply evaluating twopoints in vicinity and by using the cross product of the vectors between them andthe original point. The resulting combination of a point and a normal vector are sentto the haptic manager of the Reachin API as an exclusion plane for final collisionprocessing and force rendering.

Figure 4.1. At every interaction point a exclusion plane (defined as a point and avector) is calculated and used in the force rendering.

28

Page 36: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

4.4 A Subdivision Surface in Reachin API

To implement subdivision surfaces in the Reachin API, it was decided that it shouldbe implemented in C++ as a VRML node of the geometry type. The node is respon-sible for rendering the model according to its defined appearance. For an exhaustivereference on VRML see (Carey and Bell, 1997). Additionally, in the Reachin API,it is also responsible for rendering the haptic representation in accordance with thecurrently defined surface settings—see (Reachin, 2003) for details.

To simplify the work, no “official” data format for the definition of the surfaceswas chosen, but only a list of the polygons defining the mesh. These are parsedand reworked at startup into a more manageable format—but less easy to define byhand for the user.

Internally the surface is a collection of patches, which hardly is the optimalsolution, but simpler to implement. The patches come in two categories—regularwith valence four on each vertex and extraordinary with exactly one vertex withvalence three or higher than four. Patches with more than one extraordinary vertexare currently not supported as these need to be subdivided before use, and this stepwas avoided to limit the scope of the work.

The patch based representation works without any issues in the graphic envi-ronment, but for the haptic rendering there are some problems. Every patch isseparately sampled for possible collision points and currently no patches are ex-cluded even if they are far from the proxy. This is highly inefficient, but can bequite easily corrected with the use of bounding box checks. A more significant issueis that if the edge between two patches is touched, both patches believe that thereis a sharp edge there and try to push the haptic instrument to the side in oppositedirections (fig 4.2).

Figure 4.2. Between two patches the haptic proxy can be subjected to sidewayspointing forces which should not be present as the true surface is continuous.

This leads to major instabilities in the force rendering. The solution is a rework-ing of the minimisation function where it has to be considered that the minimumcan be moved back and forth across edges on adjacent patches. This is by no meansimpossible but not as simple as the above task.

4.4.1 Evaluation Around Extraordinary Vertices

The regular patches only use the standard B-spline evaluation but the extraordinaryvertices use the exact evaluation method described by Jos Stam in (Stam, 1998b).

29

Page 37: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

The first step is to calculate the needed eigenvalues and the eigenvectors alongwith their inverses as described in the section about the evaluation method (2.8).This is done by a Python1 script and stored to file. The values for vertices up tovalence 50 can also be downloaded from Jos Stam’s home-page2, but I preferred todo the calculation myself in case I would have had time left to implement additionalfeatures such as creases. Writing it myself also gave me insight into the details ofthe structure of the solution.

The values are read from the file at program start up for initialisation and areused to initialise the coarse mesh used on every patch both for graphics renderingand finding an approximate start point for the haptic interaction. The bulk of theusage is in the haptic loop where interaction points on the surface constantly needto be calculated.

1http://www.python.org2http://www.dgp.toronto.edu/people/stam/reality/Research/SubdivEval/index.html

30

Page 38: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Chapter 5

Results

This chapter presents the results of the thesis along with a discussion. Instabilitiesin the haptic performance severely reduced the number of tests which could beperformed and voided the point of aiming for a number of possible and obviousoptimisations. There are still some positive results of the work.

5.1 Tests Performed

The implementation where tested on both single patches and on surfaces consistingof several connected ones, all based on the same C++ code but with differing VRMLdefinitions.

5.1.1 Single Patches

The single patch was used as a first step in the implementation and to check thatthe graphic and haptic parts work at all. While the graphic rendering worked asexpected, the haptic rendering displayed severe instabilities, such as a general jitterin the force rendering and occasionally crashes. The latter was most likely due torendering of too high forces. This was only present for the extraordinary patches(fig. 5.2), the regular B-spline patches (fig. 5.1) were as smooth as wanted. Suchunstable behaviour can be experienced when the haptic rate dips too far below thetarget rate of 1kHz due to demanding calculations in the haptic loop. However, whenthe rate was checked no significant rate loss was discovered. Further testing on thepatch never revealed the exact problem, but it seemed more pronounced closer to theextraordinary vertex. Additionally the shakiness was reduced but still present whencompletely flat patches were tried. The problems seemed to stem from inaccuraciesin the minimisation function as the interaction point jumped constantly on thesurface without any corresponding movement of the proxy. This meant that theproxy was pushed in slightly different directions which were felt as “jumps”. The sameproblems were experienced during the implementation of NURBS at Reachin. Theminimisation there needed some fine-tuning of cutoff values for it to work correctly.Another possibility is that the “numerical instabilities” mentioned in (Zorin and

31

Page 39: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Kristjansson, 2002) surfaced here, it might be the case that the demands of theminimisation trigger this instability.

As a side note, concerns that there would be visible discrepancies between thehaptic and graphic representations where laid to rest–at least when the mesh pointswhere as tightly placed as used here (a 10-by-10 mesh for each patch).

Figure 5.1. A regular patch Figure 5.2. A extraordinary(B-spline) patch

5.1.2 A Connected Surface

As previously mentioned the internal representation in the form of patches meantthat there would be instabilities on the edges between patches, and when tested (fig.5.3 and fig. 5.4) these were quickly discovered. The jerkiness of the patches alsoremained, as expected, with the regular patches still working fine even haptically.The inefficient collision detection started to become noticeable on objects with agreater number of patches resulting in a lower rate for the haptic loop. Thereseemed to be little point in pursuing more complex structures to check the patchgeneration used in the implementation these objects were deemed to be complexenough.

Figure 5.3. Two adjacentextraordinary patches forminga corner joined to a regularpatch.

Figure 5.4. A cube made upof regular and extraordinarypatches (in the corners). Thecontrol mesh has been movedout for visibility.

32

Page 40: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

5.2 Measurements

Sadly the instability of the haptic rendering voided any attempts to measure thehaptic performance. However, rudimentary testing showed that one patch did allowfor the haptic rate to be kept at an acceptable level. When more patches were addedthe naïve approach of checking for collision points on every patch individually hurtthe performance tremendously.

33

Page 41: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Chapter 6

Conclusions

Despite major issues with the haptic stability of the implementation, the thesis showsthat, and how, exact evaluation can be used to implement subdivision surfaces in acombined graphic/haptic environment. The unstable haptic performance however, isworrying, especially in the light of the “numerical instabilities” mentioned in (Zorinand Kristjansson, 2002) concerning. Experience from related projects, however,point to issues with the implementation.

There are some trade–offs such as matching the graphical and haptic represen-tations but no obvious differences were noticed. The advantage over the previousimplementations (Raymaekers et al., 2001) is that the problem of subdividing thesurface to a sufficient level for the haptic rendering is avoided. How the two ideascompare in execution speed is still unknown and will remain so for a while as theframework of the implementations are not the same and incurs different and un-known penalties to the execution speed.

34

Page 42: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Chapter 7

Further Development

For future work in this area the obvious next step is to correct the instabilities foundand implement the details skipped in this first implementation. Secondly it wouldbe interesting to study and compare this and the previous approach both in speedand how they handle more complex models. Preferably these tests should be doneunder the same framework, either Reachin API (Reachin, 2003) or the GHOST SDKby Sensable Technologies, the makers of the Phantom haptic device.

When these corrections and tests have been performed, what remains? Theanswer is of course to use subdivision surfaces, mainly as a tool for design andmodelling. There are already toolkits for haptic modelling such as FreeForm®from Sensable Technologies1, and experience from non-haptic environments such asMaya® shows that subdivision surfaces do have a part to play, and there is no reasonthis would not be the case when haptic rendering is added. Additionally, almost anyapplication has at least one but more commonly a number of imported objects—imported from the afore–mentioned design programs. If subdivision surfaces canbe handled in these, naturally it would be an advantage if they could be easilymoved to the haptic environment. Such a development would demand that theimplementation can handle these formats, at the very least after a transformation,and this could be another development path.

Further in the future new algorithms for subdivision could be tried as theybecome more common, if they survive initial testing in the non-haptic community—unless of course advantages specifically for haptic rendering are discovered in any ofthem.

Volumetric subdivision is one area which might be especially suited for hapticsubdivision when combined with physics modelling. The force rendering in mostapplications is based on surface forces, but naturally, most objects, in particular soft,deformable ones, have a force model strongly dependant on the entire (deformed)volume and its mass distribution. The problem is that such an implementationplaces huge demands on computing power and is generally not feasible on todayshardware except for small scale, limited problems.

1http://www.sensable.com/

35

Page 43: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Bibliography

Angel, E. (1997). Interactive Computer Graphics. Addison-Wesley.

Bajaj, C., Schaefer, S., Warren, J., and Xu, G. (2001). A subdivision scheme forhexahedral meshes. http://citeseer.nj.nec.com/bajaj01subdivision.html verifiedNovember 2003.

Bolz, J. and Schröder, P. (2002). Rapid evaluation of catmull-clark subdivisionsurfaces. http://citeseer.nj.nec.com/483572.html verified November 2003.

Carey, R. and Bell, G. (1997). The Annotated VRML 2.0 Reference Manual. AddisonWesley Developers Press.

Catmull, E. and Clark, J. (1978). Recursively generated b-spline surfaces. ComputerAided Desgin, 10(6):350–355.

Chang, Y.-S., McDonnell, K. T., and Qin, H. (2002). A new solid subdivisionscheme based on box splines. In Seventh ACM Symposium on Solid Modelingand Applications, pages 226–233.

Doo, D. and Sabin, M. (1978). Analysis of the behaviour of recursive division surfacesnear extraordinary points. Computer Aided Desgin, 10(6):356–360.

Friedel, I., Mullen, P., and Schröder, P. (2003). Data-dependent fairing of subdivisionsurfaces. http://citeseer.nj.nec.com/556374.html verified November 2003.

Loop, C. T. (1987). Smooth subdivision surfaces based on triangles. M.S. Thesis.

Piegl, L. and Tiller, W. (1997). The NURBS Book. Monographs in Visual Commu-nication. Springer Verlag, second edition.

Press, W. H., Teukolsky, S. A., Vetterling, W. T., and Flannerly, B. P. (1997).Numerical Recipes in C. Cambridge University Press, second edition.

Raymaekers, C., Beets, K., and Reeth, F. V. (2001). Fast haptic rendering ofcomplex objects using subdivision surfaces. Proceedings of the Sixth PHANToMUsers Group Workshop.

Reachin (2003). Reachin programmers guide. avialable from Reachin TechnologiesAB.

36

Page 44: Haptic Rendering of Subdivision Surfaces - KTH · Subdivision surfaces is a technique for ... numerisk minimering i varje steg av den ... haptic rendering as well as for ray-tracing

Stam, J. (1998a). Evaluation of loop subdivision surfaces.http://citeseer.nj.nec.com/stam98evaluation.html verified November 2003.

Stam, J. (1998b). Exact evaluation of Catmull-Clark subdivision surfaces at arbi-trary parameter values. Computer Graphics, 32(Annual Conference Series):395–404. http://citeseer.nj.nec.com/450988.html verified November 2003.

Velho, L. and Zorin, D. (2001). 4–8 subdivision. Computer-Aided Geo-metric Design, 18(5):397–427. Special Issue on Subdivision Techniqueshttp://citeseer.nj.nec.com/velho00subdivision.html verified November 2003.

Woo, M., Neider, J., Davis, T., and Shreiner, D. (1999). OpenGL ProgrammingGuide. Addison Wesley, third edition.

Zilles, C. and Salisbury, J. (1995). A constraintbased god-object method forhaptic display. http://citeseer.nj.nec.com/zilles95constraintbased.html verifiedNovember 2003.

Zorin, D. and Kristjansson, D. (2002). Evaluation of piecewise smooth sub-division surfaces. In Visual Computing (2002) Abstract, pages 299–315.http://link.springer-ny.com/link/service/journals/00371/bibs/2018005/20180299.htm verified November 2003.

Zorin, O. D. and Schröder, P. (2000). Subdivision for modeling and animation.SIGGRAPH 2000 Course Notes.

37