A Simple, Fast,Effective Polygon Reduction Algorithm BY Stan Melax

Attribution Non-Commercial (BY-NC)

Als PDF, TXT **herunterladen** oder online auf Scribd lesen

3,2K Aufrufe

A Simple, Fast,Effective Polygon Reduction Algorithm BY Stan Melax

Attribution Non-Commercial (BY-NC)

Als PDF, TXT **herunterladen** oder online auf Scribd lesen

- GM Tech Magazine :: Issue Five
- AMETank Product Brochure
- Advanced Computational Models
- max2010_us13
- Algorithms for Generating Convex Polyhedrons Over Three Dimensional Rectangular Grid
- Casing Report
- Voxler 2 Demo Part 4
- 15437_EXCEL TERM PAPER C1802
- Linear Dt
- VisiInc PLC Announces Open Inventor Integration into Vistime
- 3DS Max Hotkeys
- pcs97
- Advance Meshing Tool
- Lesson 3 4
- FME Vol 32 No1 Manesku
- DF0MCd34
- CSN523_Lec_12.pdf
- Unified Representation
- 317 Boghian Gabriel Marcel
- Geometric Algorithms for Automated Design of Side Actions in Injection Molding of Complex Parts

Sie sind auf Seite 1von 6

I

f you’re a game developer, there’s a good

detail model with many polygons and generate a version

A Simple, Fast, using fewer polygons that looks reasonably similar to the

original. In addition to talking about what polygon reduc-

tion is and why it is useful, this article explains one method

for achieving it. Before going any further, I suggest you

strates the technique that I’ll explain. You can find it on the

Game Developer web site.

Polygon B

Motivation

efore diving into a sexy 3D algorithm, you may be ask-

Reduction ing yourself if you really care. After all, there are com-

mercial plug-ins and tools that reduce polygons for you.

Nonetheless, there may be reasons why you want to imple-

ment your own reduction algorithm.

your specific needs, and you would like to build your own.

• Your current polygon-reduction tool may not produce the

morph information that you require for smooth transi-

by Stan Melax tions between different levels of detail.

• You want to automate your production pipeline so that

the artist has to create only one reasonably detailed model,

and the game engine does the rest.

• You’re creating a VRML browser, and you want to provide

a menu option for reducing those huge VRML files placed

on the Web by supercomputer users who didn’t realize the

frame rate would be slower on a home PC.

• Special effects in your game modify the geometry of

objects, bumping up your polygon count and requiring a

method by which your engine can quickly reduce polygon

counts at run time.

rithms for his Ph.D. in computer science at the University of

Alberta. He is also the Director of Technology at Bioware,

where he had worked on SHATTERED STEEL and is now imple-

menting cool stuff for their next 3D titles. He can be contacted

via e-mail at melax@cs.ualberta.ca.

F I G U R E 2 . Edge collapse.

v v

u

Before After

other (in this case, v). The following steps

implement this operation:

1. Remove any triangles that have both u and

v as vertices (that is, remove triangles on the

edge uv).

F I G U R E 1 . Effect of Boolean operations on polygon count. 2. Update the remaining triangles that use u as 45

a vertex to use v instead.

3. Remove vertex u.

Still not convinced? Figure 1 shows a concrete example of This process is repeated until the desired polygon count is

an instance in which a game engine requires polygon reduc- reached. At each step, one vertex, two faces, and three edges

tion capabilities. are usually removed. Figure 3 shows a simple example.

At Bioware, I implemented real-time Boolean operations

and used them in a game prototype that we developed to

impress our publisher. Players could shoot and blast arbi- Selecting the Next Edge to Collapse

trary chunks out of a solid object wherever they decided to

point the gun. Modifying the game environment where the he trick to producing good low-polygon models is to

bullets impact produces much more stunning results than

the typical “place pipe bomb here” technique, in which the

T select the edge that, when collapsed, will cause the

smallest visual change to the model. Researchers have pro-

game world only changes in a predetermined manner. posed various methods of determining the “minimal cost”

Unfortunately, repeated use of Boolean operations per- edge to collapse at each step. Unfortunately, the best meth-

formed on polygonal objects generates lots of additional tri- ods are very elaborate (as in, difficult to implement) and

angles, as you can see in Figure 1. Many of these additional take too long to compute. Motivated to find a way to reduce

faces are small or splinter triangles that don’t contribute to polygons during run time in a game, I performed many

the visual quality of the game — they just slow it down. The experiments and eventually developed a simple and blazing-

situation demanded run-time polygon reduction, so I began ly fast approach for this selection process that generates rea-

my quest to find an algorithm that would do this efficiently. sonably good low-polygon models.

Collapsing Edges

ather than attacking this problem

R all by myself, I studied polygon

reduction with some other people at the

University of Alberta Graphics Lab. (It

helps to work with a team in order to fig-

ure out how the different algorithms

work and which technology is appropri-

Original Final

ate for which task.) A lot of research has

gone into this subject recently, and most

of the better techniques are variations of E Q U A T I O N 1 . The edge cost formula.

the progressive meshes algorithm by H.

{ {( ) }}

Hoppe (see “For Further Info”). These

techniques reduce a model’s complexity ( )

cost u,v = u − v × max min 1 − f .normal • n.normal ÷ 2

f ∈Tu n∈Tuv

by repeated use of the simple edge col-

lapse operation, shown in Figure 2. where Tu is the set of triangles that contain u and Tuv is the set of triangles that contain

In this operation, two vertices u and v both u and v.

(the edge uv) are selected and one of

P O LY G O N R E D U C T I O N

F I G U R E 4 . Good and bad edge collapses. want to develop a formula that will look

at more than just one keyframe when

computing the cost of a potential edge

A C collapse. If quality is more important to

B you than the reduction algorithm’s exe-

cution time, then you should consider

using Hoppe’s energy function. We’ve

Original added our own extensions to deal with

texture coordinates, vertex normals,

B to A B to C A to C border edges, and surface discontinu-

ities such as texture seams.

A A A

C C

B B C

B

Results

he effectiveness of a polygon

T reduction algorithm is best demon-

strated by showing a model before and

A to B C to A C to B

46 after it has been simplified. Most

A research papers demonstrate their

C AC

A C results using highly tessellated models

B B

B in the neighborhood of 100,000 poly-

gons, reducing them to 10,000 poly-

gons. For 3D games, a more appropri-

ate (and challenging) test of an

Obviously, it makes sense to get rid mining which edge to collapse. Note algorithm is how it demonstrates its

of small details first. Note also that that the cost of collapsing vertex u to v prowess by generating models that use

fewer polygons are needed to represent may be different than the cost of col- only a few hundred polygons.

nearly coplanar surfaces while areas of lapsing v to u. Furthermore, the formula For instance, Figure 5 shows a bunny

high curvature need more polygons. is effective for collapsing edges along a model taken from a VRML file created

Based on these heuristics, we define the ridge. Although the ridge may be a by Viewpoint Datalabs. The initial ver-

cost of collapsing an edge as the length sharp angle, it won’t matter if it’s run- sion (left) of the model contains 453

of the edge multiplied by a curvature ning orthogonal to the edge. Figure 4 vertices and 902 polygons. Reductions

term. The curvature term for collapsing illustrates this concept. Clearly, vertex to 200 (center) and 100 (right) vertices

an edge uv is determined by comparing B, sitting in the middle of a flat region, are shown. Hopefully, you’ll agree that

dot products of face normals in order can be collapsed to A or C. Corner ver- the models look reasonably good given

to find the triangle adjacent to u that tex C should be left alone. It would be the number of polygons used in each

faces furthest away from the other tri- bad to move vertex A, sitting along the image. Figure 6 shows the conse-

angles that are along uv. Equation 1 top ridge, onto interior vertex B. quences of not selecting the right edge

shows the edge cost formula in more However, A could be moved (along the to collapse at each step. In this case,

formal notation. The specific details ridge) onto C without affecting the edges were chosen randomly.

can also be found in the source code overall shape of the model. After completing animal testing, we

(which you can dowlnoad from Game If you’re implementing your own began human clinical trials for the algo-

Developer’s web site). reduction algorithm, you may wish to rithm. Figure 7 shows three versions —

You can see that this algorithm bal- experiment with this equation in order at 4,858; 1,000; and 200 vertices — of a

ances curvature and size when deter- to meet your needs. For example, in the

F I G U R E 5 . Bunny model at (left to right) 453, 200, and 100 vertices. (200 vertex version).

female human model made by Bioware. list of triangles that contain indices into

(From Euler’s formula, we know that the

Implementation Details the vertex list. For example,

polygon counts are roughly double these his algorithm only works with trian-

numbers.) Once again, these images are

shown with flat shading so you can see

T gles. Nothing is lost by this limita-

tion; polygons with more sides are easily

Vector vertices[];

class Triangle {

int v[3]; // indices into vertex list

the difference in the meshes. When triangulated if necessary. In fact, many } triangles[];

smooth shading and textures are applications use triangles exclusively. The Indexed Face Set node data type

applied, the differences are less apparent. Most data structures for storing polyg- used in VRML is another example of

onal objects use a list of vertices and a this type of data structure. When two

ur initial goal was modest: we

O wanted to find a way to get rid of

a few excess polygons caused by too

class Triangle {

public:

Vertex * vertex[3];// the 3 points that make this tri

many Boolean operation effects. Vector normal; // orthogonal unit vector

However, after developing the reduc- Triangle(Vertex *v0,Vertex *v1,Vertex *v2);

tion algorithm and noticing better- ~Triangle();

than-expected results on actual models, void ComputeNormal();

we decided that the technique was void ReplaceVertex(Vertex *vold,Vertex *vnew); 47

good enough to generate the level of int HasVertex(Vertex *v);

detail (LOD) models for the game };

engine. An improved version of this class Vertex {

basic algorithm has since been incorpo- public:

rated into Bioware’s 3D graphics Vector position; // location of this point

engine, Omen. Now, for many game int id; // place of vertex in original list

objects, our artists only have to create List<Vertex *> neighbor; // adjacent vertices

one detailed model. A preprocessing List<Triangle *> face; // adjacent triangles

step does the polygon reduction. Then, float cost; // cached cost of collapsing edge

when the frame rate falls below a prede- Vertex * collapse; // candidate vertex for collapse

fined threshold or an object is to be Vertex(Vector v,int _id);

rendered in the distance, a lower poly- ~Vertex();

gon version is used instead. Being able void RemoveIfNonNeighbor(Vertex *n);

to make these choices at run time };

increases the scalability of a game. The List<Vertex *> vertices;

game adapts itself to the horsepower of List<Triangle *> triangles;

the system on which it’s running.

F I G U R E 7. Female human model showing 100 percent of the original polygons (left), 20 percent of the original polygons (cen-

ter), and 4 percent of the original polygons (right).

P O LY G O N R E D U C T I O N

triangles on an object meet at the be maintained as vertices and triangles tialize the vertex and triangle lists with

same vertex, they’ll have the same are added, deleted, or replaced. The con- the object’s geometry, and then do

index (so they share the same entry in structors, destructors, and member func- something like this:

the vertex list). tions contain code to keep things in while(vertices.num > desired) {

We’ve enhanced this data structure order. We cache face normals because Vertex *mn = MinimumCostEdge();

as required by our polygon reduction they are frequently used by the edge Collapse(mn,mn->collapse);

algorithm. One major improvement is selection formula. In order to save us the }

that we now have access to more infor- effort of recalculating these costs, the The demo, BUNNYLOD.EXE, doesn’t

mation than just which vertices each best edge and its cost is cached for each use this simple loop. Instead it creates

triangle uses — we also know which tri- vertex. The implementation of the an additional data structure for the

angles each vertex bounds. Further- member functions is fairly straightfor- animation.

more, for each vertex, we have direct ward, so I haven’t included it in this arti-

access to its neighboring vertices cle. If you’re interested, simply examine

(which gives us the edges). Listing 1 this algorithm’s source code on the Making Better Use of the Data

shows the enhanced data structure. Game Developer web site. Listing 2 con-

Member functions such as tains the code for determining edge costs ather than throwing away infor-

ReplaceVertex() have been added to per-

form edge collapses during polygon

and doing the edge collapse operation.

Performing polygon reduction is

R mation about triangles and ver-

tices that have been removed, this

reduction. Consistency of this data must easy given these functions. Simply ini- information can be preserved so that a

48

L I S T I N G 2 . Determining the edge costs and performing the edge collapse operation.

// if we collapse edge uv by moving u to v then how c = ComputeEdgeCollapseCost(v,v->neighbor[i]);

// much different will the model change, i.e. the “error”. if(c < v->cost) {

float edgelength = magnitude(v->position - u->position); v->collapse=v-neighbor[i];

float curvature=0; v->cost=c;

}

// find the “sides” triangles that are on the edge uv }

List<Triangle *> sides; }

for(i=0;i<u->face.num;i++) {

if(u->face[i]->HasVertex(v)){ void Collapse(Vertex *u,Vertex *v){

sides.Add(u->face[i]); // Collapse the edge uv by moving vertex u onto v

} if(!v) {

} // u is a vertex all by itself so just delete it

// use the triangle facing most away from the sides delete u;

// to determine our curvature term return;

for(i=0;i<u->face.num;i++) { }

float mincurv=1; int i;

for(int j=0;j < sides.num;j++) { List<Vertex *>tmp;

// use dot product of face normals. // make tmp a list of all the neighbors of u

float dotprod = for(i=0;i<u->neighbor.num;i++) {

u->face[i]->normal ^ sides[j]->normal; tmp.Add(u->neighbor[i]);

mincurv = min(mincurv,(1-dotprod)/2.0f); }

} // delete triangles on edge uv:

curvature = max(curvature,mincurv); for(i=u->face.num-1;i>=0;i—) {

} if(u->face[i]->HasVertex(v)) {

return edgelength * curvature; delete(u->face[i]);

} }

}

void ComputeEdgeCostAtVertex(Vertex *v) { // update remaining triangles to have v instead of u

if(v->neighbor.num==0) { for(i=u->face.num-1;i>=0;i—) {

v->collapse=NULL; u->face[i]->ReplaceVertex(u,v);

v->cost=-0.01f; }

return; delete u;

} // recompute the edge collapse costs in neighborhood

v->cost = 1000000; for(i=0;i<tmp.num;i++) {

v->collapse=NULL; ComputeEdgeCostAtVertex(tmp[i]);

// search all neighboring edges for “least cost” edge }

for(int i=0;i < v->neighbor.num;i++) { }

model at any specified number of ver-

tices can be retrieved on demand with- F I G U R E 8 . Comparison of techniques.

out having to recompute the polygon

reductions. This feature is easily imple-

mented by storing the vertex to which

each vertex is collapsed and sorting the

vertices by the order in which they

were collapsed.

The BUNNYLOD.EXE demo uses this

method. Initially, the bunny is reduced

from 450 to 0 vertices in approximately Original Octagon Regenerated from circle Edge Collapse

one second. Then, as the slider on the equation using 7 edges

left animates the bunny, the model is

rendered in increasing detail using the

specified number of polygons. Another model. An artist, on the other hand, based reduction methods are more gen-

way to think of this animation is as a knows the object that he or she is creat- erally useful, and work with typical

sequence of models for every number ing (be it a rabbit, a chair, and so on) models used these days.

of vertices between 0 and the number and can make careful aesthetic deci- While I hope that this information

in original model. sions as he or she manually reduces the and the accompanying demonstration

The edge collapse sequence could face count. The human visual system is application that I’ve provided are use- 49

also be used for progressive transmis- biased towards certain details, such as ful, this article has not touched on

sion. Just as interlaced .GIF and .JPG the eyes and mouth, and pays less issues such as dealing with texture

pictures come over the Web in increas- attention to other details such as the coordinates, vertex normals, border

ing detail, the vertices of an object can collarbone or kneecaps. On the other edges, nonmanifold topology, texture

be broadcast in the reverse order from hand, our simple algorithm merely seams, and so on. These subjects have

which they were collapsed. The receiv- compares a few dot products and edge been left as an exercise for the reader.

ing computer can display the model lengths, and obviously doesn’t have the Furthermore, many other variations

while it is reconstructed from the intelligence to place automatically and enhancements to this algorithm

incoming data stream. This is a nice varying amounts of importance on dif- are worth exploring. One exciting topic

idea, but it’s probably not relevant for ferent pieces to optimize for human is adaptive simplification, in which dif-

game developers just yet. perception. The advantage to using a ferent parts of the same mesh are ren-

An important component in many polygon reduction algorithm is that it dered at different levels of detail

games is the LOD of models. A handful automates the process. according to run-time parameters. This

of models can be selected from the Another technique for doing LODs is especially useful for open terrain

sequence generated by our algorithm in a game is to represent an object’s environments so that more detail can

to represent the object at various LODs. geometry using parametric surface be used near the current viewpoint. ■

One problem with swapping models is patches, which are tessellated on the

that players often notice when this fly to the desired detail. Shiny’s

F O R F U R T H E R I N F O

occurs (the phenomenon known as MESSIAH engine uses a similar

“popping”). A solution to the popping approach. Certainly, these surface- Polygon reduction has been a hot

effect is to morph smoothly between based methods are preferable (and research topic lately, and most of the

the models. In order to morph between probably optimal too). Figure 8 illus- literature about it can be found in pro-

two models, the vertices of one model trates the advantage using a 2D analo- ceedings from academic computer

must be mapped onto the other. gy. An octagon reduced by one edge is graphics conferences. Some more

Fortunately, this information can be regenerated as a regular heptagon by places you can look:

extracted from the edge collapse the parametric approach. Collapsing an • Cohen, J., M. Olano, and D.

sequence. The BUNNYLOD.EXE demo edge on the octagon produces non-reg- Manocha. “Appearance-Preserving

also shows an example of morphing. ular results. Simplification”, SIGGRAPH ‘98.

Unfortunately, using curved para- • Hoppe, H. “Progressive Meshes,”

metric surfaces isn’t always appropri- SIGGRAPH ‘96, pp. 99-108.

Alternatives to Edge Collapse ate. Some of the challenges include get- • Luebke, D. and C. Erikson. “View-

Techniques ting the object into this sort of Dependent Simplification of Arbitrary

representation and being able to gener- Polygonal Environments”, SIGGRAPH

olygon reduction algorithms ate polygons at render time so that

P aren’t the only way to create a

model with fewer faces. Artists will

adjacent surfaces fit together properly

(without gaps or T-intersections).

‘97, pp. 199-207.

• I have a demo on my university web

site at http://www.cs.ualberta.ca/

always be able to do a better job of rep- Furthermore, jagged objects aren’t ~melax/ polychop

resenting a model using fewer polygons good candidates for use with curved • H. Hoppe, the Guru of polygon

than any reduction algorithm. One rea- surface patches because the number of reduction, maintains a web site at

son is that algorithms have little or no surfaces would be no less than the http://research.microsoft.com/~hoppe/

higher-level understanding of the number of polygons required. Polygon-

- GM Tech Magazine :: Issue FiveHochgeladen vongamemakertech
- AMETank Product BrochureHochgeladen vonSYedZYnAle
- Advanced Computational ModelsHochgeladen vonjiandong3600
- max2010_us13Hochgeladen vonRock End
- Algorithms for Generating Convex Polyhedrons Over Three Dimensional Rectangular GridHochgeladen vonsipij
- Casing ReportHochgeladen vonAqil Anwar
- Voxler 2 Demo Part 4Hochgeladen vonRizalabiyudo
- 15437_EXCEL TERM PAPER C1802Hochgeladen vonAkash Srivastava
- VisiInc PLC Announces Open Inventor Integration into VistimeHochgeladen vonkalai2
- Linear DtHochgeladen vonMarvin Uribe
- 3DS Max HotkeysHochgeladen vonPeteSAMEX
- pcs97Hochgeladen vonMohammed Hashim
- Advance Meshing ToolHochgeladen vonranganathan0818
- Lesson 3 4Hochgeladen vonmamunruet
- FME Vol 32 No1 ManeskuHochgeladen vonNurul Huda
- DF0MCd34Hochgeladen vonMullah Fassudin
- CSN523_Lec_12.pdfHochgeladen vonsaiavinash duddupudi
- Unified RepresentationHochgeladen vonRuxi Neagu
- 317 Boghian Gabriel MarcelHochgeladen vongandalf500
- Geometric Algorithms for Automated Design of Side Actions in Injection Molding of Complex PartsHochgeladen vonDanistergladwin
- StructureHochgeladen vonD.n.Prasad
- Automatic Reconstruction of Parametric Building Models From IndoorHochgeladen vonLuciano Dodl
- Indoor Mapping using The ZEB1.pdfHochgeladen vonBardalian
- AutoCAD Map 3D 2008 TrainingHochgeladen vonHerbert Lopes Filho
- Area FillingHochgeladen vonSwapnil Barapatre
- justas_ingelevicius.pdfHochgeladen vondonmazeti123
- PortfolioHochgeladen vonAnonymous fVnuuSF
- HEXPRESS-User-Guide.pdfHochgeladen vonIndra Evolusi Nandra
- Design and Implementation of Computer Games a CapsHochgeladen vonlalokass
- DESIGN 1Hochgeladen vonDwin Etolabs

- Laudon_MIS13_ch05Hochgeladen vonMary Anne Murillo
- Kishore's Cognos Class Room_ Cognos FM Interview Questions and AnswersHochgeladen vonPraveenKumar
- readme.txtHochgeladen vonRoland Michael Sanjaya
- ERP Intrastat reporting process overview.docxHochgeladen vonAnonymous gd8Q7nLos
- Toolbox PLUS Users Manual 3.11.0Hochgeladen vonpyrodido
- Ductility MachineHochgeladen vonYen Ling Ng
- SQR Manual000Hochgeladen vonskanungo
- Magnetic Flux LeakageHochgeladen vonchristen76
- Global EnglishHochgeladen voncvsumitha
- 1756-um016a-en-p.pdfHochgeladen vonandrea19711971
- installupgrade-sfeHochgeladen vonChris Borzumato
- UT Dallas Syllabus for mis6308.501.11f taught by Srinivasan Raghunathan (sraghu)Hochgeladen vonUT Dallas Provost's Technology Group
- Degrees of FreedomHochgeladen vonveda20
- How to Create a Distorted VHS Effect in PhotoshopHochgeladen vonseedot
- CNC Codes - Full ListHochgeladen vonneurra
- Success Stories Tr All 16 9 EnHochgeladen vonKijo Supic
- Siraj - School of AI - V1.0 08162018Hochgeladen vonMohit k
- abstractHochgeladen vonRavi Kumar
- H-Index and Impact FactorsHochgeladen vonMehdi Chlif
- HDRLS4 - Plugin Guide - 3ds MaxHochgeladen vonAnderson Jesus
- windows8Hochgeladen vonsarwan111291
- java_abstraction_25.pdfHochgeladen vonJyotsana Sharma
- Ansys MeshingHochgeladen vonHari Shankar
- Spa9000 Voice System v6-1 Ag Nc-webHochgeladen vonjcdaza
- Comment recharger Encre Toner Hp 1012Hochgeladen vonJean Christian Rakotoarimalala
- Corel DESIGNER 12 VBA Programming GuideHochgeladen vonЗоран Марковић
- ACI Test Drive Course Description2.0(2)Hochgeladen vonAnthony Lobosco
- Windows Xp Hardware RequirementsHochgeladen vonPrasidh Mayyanad
- Copy of Indzara Project Planner Basic v3 1 SampleHochgeladen vonYudith Rachmadiah
- Comarch Technology Review Magazine 2011/01Hochgeladen vonComarch Telecommunications Business Unit

## Viel mehr als nur Dokumente.

Entdecken, was Scribd alles zu bieten hat, inklusive Bücher und Hörbücher von großen Verlagen.

Jederzeit kündbar.