CGT511-08-3D Objects - 3D object representation 3D object...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3D object representation 3D object representation CGT 511 3D objects objects Volume representation Boundary representation Procedural Voxels Wire frame Fractals Oct tree Surfaces Particle systems Bedřich Beneš, Ph.D. Purdue University Department of Computer Graphics Technology CSG Polygonal Grammars Free form Bézier surfaces NURBS Implicit surfaces © Bedrich Benes 3D object rendering Representation and Rendering • Can we display object represented as points images lines surfaces volume • • • • © http://http.developer.nvidia.co m/GPUGems/elementLinks/fig 39-05.jpg © Bedrich Benes © Bedrich Benes voxels using point representation? points using volumetric techniques? B-rep as lines? as lines? etc? Volume representation Volume representation Two main categories: • voxels enumeration of the 3D space using coordinates 3D Advantages: • An easy collision test • CSG tree representation representation © Bedrich Benes Disadvantages: • Displaying • Memory requirement © Bedrich Benes Voxels Voxels • Voxel is an acronym for volume element an object has its resolution given by an ordered triple an ordered triple e.g., 50x20x20 voxels 50x20x20 voxels • typical data structure is a 3D array data[n][m][l] data[n][m][l] • The voxel value depends on the application: density, temperature, pollution intensity temperature pollution intensity • Application areas medicine, meteorology, astronomy geology, etc. medicine, meteorology, astronomy , geology, etc. Example: • How much memory is needed for object in the resolution 200x200x200 voxels? 200 • unsigned char is represented in 1 byte space = 1 x 200 x 200 x 200 = 7.6 MB 200 200 200 MB © Bedrich Benes © Bedrich Benes Voxels Voxels There are three problems with voxels: Example: Wooden log scanned in 512x512x1024 loaded into the GPU and used to texture polygonal quads 1) data storage 2) data acquisition 3) data visualization © Bedrich Benes - data is too huge - we must measure data inside an object - how can we display the data inside? © Bedrich Benes Voxels Voxels - Displaying Example: Direct Volume Rendering (DVR) • An object is displayed without a conversion • Can focus on Weather data in data in resolution 512x512x512 displayed using us texture slicing • the surface, or • the inner structure • Common way of displaying is using raycasting way of displaying is using raycasting © Bedrich Benes © Bedrich Benes Voxels - Displaying Voxels - Displaying • Raycasting • Raycasting A ray is sent from the viewpoint (camera) It It penetrates the volume and traverses through it th th it • What value is used for displaying? value is used for displaying? © Bedrich Benes © Bedrich Benes Voxels - Displaying Voxels - Displaying First hit (corresponds to the surface) (C) Petr Felkel Distance to the first hit © Bedrich Benes (C) Petr Felkel © Bedrich Benes (C) Petr Felkel Voxels - Displaying Voxels - Displaying Integrated value of the volume on the ray (sum) Maximum along the ray © Bedrich Benes (C) Petr Felkel © Bedrich Benes (C) Petr Felkel Voxels - Displaying Voxels - Displaying Normal vector Texture slicing • The most commonly used volumetric rendering • Fast and easy to implement on the GPU • Idea: • • • • © Bedrich Benes (C) Petr Felkel © Bedrich Benes Take the volume Cut in by n slices in the direction perpendicular to camera Use the volume to texture the polygons Display them using α-blending Voxels - Displaying Voxels - Displaying © http://http.developer.nvidia.com/GPUGems/elementLinks/fig39-03.jpg http://http.developer.nvidia.com/GPUGems/elementLinks/fig39 © Bedrich Benes © Bedrich Benes Increasing # of slices Voxels - conversion The Marching Cubes Algorithm • Voxels can be converted to B-rep • We need to find the surface (iso-surface) • The standard way is the marching cubes algorithm • Fast and simple algorithm • The B-rep can be easily displayed on the GPU • Transforms voxels into triangles Lorensen & Cline 1987 • All of the possible cases of triangulation are in a table • Make cube from four voxels from fo • Classify the cases and decide which one is it which one is it • Then we interpolate, to get exact coordinate get exact coordinate © Bedrich Benes 0 © Bedrich Benes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 (C) Petr Felkel The Marching Cubes Algorithm Voxels to B-rep 1. 2. 3. 4. • There are variants of the MC (marching tetrahedra, etc.) Make cubes formed by centers of four voxels Determine vertices (inside, outside the volume) Select the corresponding config. from the table Interpolate values on the edges to get exact positions of the vertices 5. Calculate normals © Bedrich Benes (C) Petr Felkel 3D object representation Volume representation Boundary representation Procedural Voxels Wire frame Fractals Oct tree Surfaces Particle systems Polygonal © Bedrich Benes CSG 3D object representation CSG • So called Marching squares are used to find isolines in ima isolines in images Grammars Constructive Solid Geometry (CSG) describes object CSG Tree • Leaves ~ primitive objects (primitives) • Internal nodes ~ the set operations ∪ • Root ~ the object itself Free form - Bézier surfaces NURBS Implicit surfaces © Bedrich Benes © Bedrich Benes CSG CSG The set of operations is: • union • subtraction • translation, rotation, scale, shear The primitives typically are: • box, sphere, cone, cylinder, toroid • free form surface • half space (ax+by+cz+d > 0) Advantages: • complete information about the construction of the object bj • we have as much undos as we did steps • useful for man-made objects cars, prefabricates, architecture, civil engineering, etc. © Bedrich Benes + - scale move scale rotate move © Bedrich Benes CSG CSG Advantages (contd.): • is exact -we can measure many quantities (weight, surface area, etc.) • easy transformations (one matrix in every node) • It saves space! (every primitive is in normalized form and we are keeping link and transforms) we are keeping link and transforms) Disadvantages: • cannot be easily displayed we usually have two representations, CSG and B-rep, CSG • conversion to B-rep is difficult • another displaying by ray-casting is slow • we can get topological nonsense as a result of some operations, e.g., dangling edges free surfaces surfaces © Bedrich Benes © Bedrich Benes CSG’s displaying • • • • • 3D object representation CSG’s are precise but usually difficult to display A CAD system normally holds two representations The CSG and a B-rep The B-rep is displayed only It must be regenerated when the CSG has changed 3D object representation Volume representation Boundary representation Procedural Voxels Wire frame Fractals Oct tree Surfaces Particle systems CSG Polygonal Grammars Free form Bézier surfaces NURBS Implicit surfaces © Bedrich Benes © Bedrich Benes Wireframe Model Wireframe Model Advantages: • rendering is very fast • it is not space consuming Disadvantages: • ambiguous • no information about surfaces • cannot be easily illuminated • cannot be correctly edited • Rarely used to represent data • Typically used to display other representation © Bedrich Benes ? © Bedrich Benes 3D object representation Polygonal Representation 3D object representation Volume representation Boundary representation Procedural Voxels Wire frame Fractals Oct tree Surfaces Particle systems CSG Polygonal Grammars Free form Bézier surfaces NURBS Implicit surfaces © Bedrich Benes Polygonal Representation Triangles are preferred, because they are simplexes (always flat & convex) (a quadrilateral may be concave or non-planar) quadrilateral may be concave or non The common representation is a mesh of triangles • usually product of conversion from different representation diff (e.g., CSG, NURBS) • is a process of pro of converting a complex object into simpler primitives such as triangles or quadrilaterals simpler primitives such as triangles or quadrilaterals • Polygonal meshes are large so techniques for their simplification are necessary techniques for their necessary • Can be lossless or lossy © Bedrich Benes 3D object representation 3D object representation Volume representation Boundary representation Procedural Voxels Wire frame Fractals Oct tree Surfaces Particle systems CSG Polygonal Free form Images of triangulated objects usually have distinct signature usually have a distinct signature Bézier surfaces NURBS Implicit surfaces © Bedrich Benes © Bedrich Benes Grammars Implicit Surfaces Implicit Surfaces Idea Blinn 1992: “How does an isosurface of an electric potential look?” Terminology: Blobby objects, blobs, soft objects, Meta-balls, etc. This is known in mathematics for hundred years as Example: Let’s use it as a modeling tool! Put some elements in 3D space the isosurface is the model. isosurface is the model © Bedrich Benes Implicit surfaces surfaces Example: x2 + y2 - r2 = 0 - circle - sphere x2 + y2 + z2 - r2 = 0 it is set of points that has distance r from the origin © Bedrich Benes Implicit Surfaces Implicit Surfaces Implicit function is given by the equation Modeling: 1. put elements into 3D space and set their properties they form so called skeleton 2. Calculate the distance field 3. Display it F(P)=0 is a set of points P having the same potential (equipotential, isosurface) this can be reformatted as G(P)+D=0, where D is the distance of the point P from the surface with zero potential ith D is the offset or the distance © Bedrich Benes © Bedrich Benes n F ( p ) = ∑ ci Fi (ri ) Implicit Surfaces Implicit Surfaces Modeling elements can be just points and lines Having n elements of the skeleton Equation of the isosurface: of the isosurface: Modeling (contd.): example of the influence of the value c: Three points in the space and the value of c is increased the from left to the right n F ( p ) = ∑ ci Fi (ri ) i =1 where: i =1 n is the # of the elements ci is factor of influence (power, voltage) of the (p element i Fi is so called blending function and r is distance of the element and point P © Bedrich Benes © Bedrich Benes n n Implicit Surfaces F ( p ) = ∑ ci Fi (ri ) i =1 • ri is the distance • distance of two points is easy: r ( A, B ) = (a x − bx ) 2 + (a y − by ) 2 + (a z − bz ) 2 Implicit Surfaces F ( p ) = ∑ ci Fi (ri ) i =1 • Distance point to line segment has two sub cases: X2 a) Inside the belt |Q,X2|; u>1 b) Outside Q ad a) use equation for X distance point-line abs(v) ad b) distance to the closer endpoint |P,X1|; u<0 P © Bedrich Benes © Bedrich Benes X1 n Implicit Surfaces F ( p ) = ∑ ci Fi (ri ) Implicit Surfaces i =1 • F is the blending function it says how the influence of an object decreases with the distance • in the original version (Blinn) it is exponential (Bli i.e., an object influences the entire space • this is clumsy; one point influences everything is one point infl Better function: 4 r 6 17 r 4 22 r 2 F (r ) = − n 9 R6 + 9 R4 − 9 R2 r is the distance R is the maximal distance of the influence of the element i.e., if r>R the F(r)=0 © Bedrich Benes F ( p ) = ∑ ci Fi (ri ) i =1 • the blending function: • is so called sigmoidal or S-shaped function • is symmetrical! +1 © Bedrich Benes Implicit Surfaces Implicit Surfaces Displaying Tessellation (Marching Cubes) a) divide the space into voxels b) Calculate value in each point (slow) c) Run MC Ray tracing nice but slow as it involves numerical methods • Implicit surface definition • Modeling using some elementary objects – skeleton • Equation of the isosurface and its elements: © Bedrich Benes • • blending function distance evaluation • Displaying Readings • Homepage of Brian Wyvill www.cpsc.ucalgary.ca/~blob/papers.html © Bedrich Benes 3D object representation Free Form Surfaces 3D object representation Volume representation Boundary representation Procedural Voxels Wire frame Fractals Oct tree Surfaces Particle systems CSG Polygonal Free form Bézier surfaces NURBS Grammars • What is a surface? Mathematical definition is complex (as with curves) Physical definition says that surface is a trajectory of definition says that surface is trajectory of a moving curve ...this definition is usually good enough in CG de usua good CG • we use the parametric representation of a surface i.e., the trajectory is given as a function of some parameter • surface is represented a set of points in space Implicit surfaces © Bedrich Benes © Bedrich Benes Free Form Surfaces Free Form Surfaces • x=x(u,v) y=y(u,v) z=z(u,v) Bivariate Function Bivariate Function Important parts of a surface • parameters u and v go from 0 to 1 (0≤ u, v ≤1) the corresponding surface is called a patch • corners Q(0,0), Q(0,1), Q(1,0), Q(1,1) • curves Q(1,v), Q(0,v), Q(u,0), Q(u,1) are called the border • partial derivatives at given point Q(u,v) Q( define tangent vectors in directions u and v Q(u,v)=Q[x(u,v), y(u,v),z(u,v)] • Can be interpreted as a moving curve be interpreted as moving curve © Bedrich Benes © Bedrich Benes ∂Q(u,v)/∂u = Q(∂ x(u,v)/∂u, ∂ y(u,v)/∂u, ∂ z(u,v)/∂u) ∂Q(u,v)/∂v = Q(∂ x(u,v)/∂v, ∂ y(u,v)/∂v, ∂ z(u,v)/∂v) Free Form Surfaces Free Form Surfaces A shape cannot usually be expressed as one surface so it is obtained by connecting patches The patches are connected in either the u or the v direction © Bedrich Benes © Bedrich Benes Free Form Surfaces Free Form Surfaces If the boundary of one patch is equal to the border of the second patch in given direction i.e., if all of the points are equal if all the points are equal i.e., if the curves on the boundary are equal then the patches are continuously connected C0 patc co • if the boundary of one patch is equal to the border of the second patch in given direction and the tangents along this boundary are equal the tangents along this boundary are equal then the patches are parametrically connected C1 © Bedrich Benes © Bedrich Benes Free Form Surfaces Two surface patches parametrically continuously connected surface patches parametrically continuously connected © Bedrich Benes Modeling Surfaces • So called bi‐cubic surfaces are used in 99% applications • The shapes are modeled using so called control control points forming control polyhedron © Bedrich Benes Modeling Surfaces • The most important are bi-polynomial surfaces i.e., surfaces based on polynomials in both directions directions u and v • p(t) = a0 + a1 t + a2 t2 + … + an tn • properties • can be derived easily • have always derivative always • provide many shapes • Horner’s scheme scheme • they can be easily connected © Bedrich Benes Modeling Surfaces • Surface editing: • control points (left) move the patch (right) • approximates • the points position © Bedrich Benes Bézier bi-cubic surfaces Bézier bi-cubic surfaces • Bézier bi-cubic surfaces are popular in CG • They have many disadvantages • One Bézier bi-cubic patch is given by sixteen (4x4) control points • P00, P01, P02, P03,P10,…,P33 • BI-CUBIC, for cubic curve we need four points • They form so called control polyhedron of the patch • Matrix notion -> the map of the surface • Equation: © Bedrich Benes Q(u,v )= [x(u,v), y(u,v), z(u,v)] = Σi3=0 Σ j3=0 Pij Bi(u) Bj(v) • parameters u,v is 0≤u,v≤1 B0(t) = (1-t)3 (1 B1(t) = 3t (1-t)2 B2(t) = 3t2 (1-t) B3(t) = t3 • Blending functions (Bernstein polynomials) © Bedrich Benes Bézier bi-cubic surfaces Bézier bi-cubic surfaces The double sum will give Q(u,v)= =P00B0(u)B0(v)+P10B1(u)B0(v)+P20B2(u)B0(v)+P30B3(u) B0(v)+ +P01B0(u)B1(v) + … … + P23 B2(u) B3(v) + P33 B3(u) B3(v) Properties: • Bézier patch lies entirely inside the convex polyhedron defined by the control vertices convex hull property • Border of the bi-cubic patch is a Bézier cubic curve of the bi pat is Bé • Any curve in direction of u or v is a Bézier cubic • Bézier patch interpolates the points P00, P01, P10, P11 i.e., Q(0,0)= P00, Q(0,1)= P01, Q(1,0)= P10, Q(1,1)= P11 Q(0 Q(1 Q(1 (16 terms) that is a bit complex… © Bedrich Benes © Bedrich Benes Bézier bi-cubic surfaces Bézier bi-cubic surfaces The partial derivatives are easy to remember ∂Q(0,0)/∂u = 3(P01 - P00) ∂Q(0,0)/∂v = 3(P10 - P00) ∂Q(0,1)/∂u = 3(P03 - P02) ∂Q(1,0)/∂v = 3(P13 - P03) etc. The schema is shown on figure (help: the one to which the vector points must be the first one in the parenthesis) Continuous joining of two Bézier patches (assume the direction of parameter u) • Two adjacent Bézier patches (Q and R) must share the border curve i.e., Q(1,v) = R(0, v) Q(1 R(0 • Its is defined by the last column of the map Q and the first column of R, and the first column of © Bedrich Benes • the last column of the map of the patch Q must be equal to the first column of the patch must be equal to the first column of the patch R • similarly for connection in direction of v © Bedrich Benes Bézier bi-cubic surfaces Bézier bi-cubic surfaces Continuous joining of two Bézier patches Parametric continuous joining of two Bézier patches • Tangent vectors on the common border is equal. • The control points defining the common border are the mid points of the lines given by third column of the first pat and the se of the first patch and the second column of the of the adjacent patch. © Bedrich Benes © Bedrich Benes Bézier bi-cubic surfaces Bézier bi-cubic surfaces Parametric continuous joining of two Bézier patches Displaying Bézier surfaces: • tessellation means calculating points on the surface and interpolating them by triangles or quadrilaterals Three approaches: 1) Uniform tessellation 2) Adaptive - using de Casteljau algorithm 3) Forward differencing © Bedrich Benes Bézier bi-cubic surfaces Advantages: • They are simple • They can be easily rendered • Convex hull properties Disadvantages: • We cannot represent sphere • The parametric continuity condition fixes too many points, we loose modeling abilities • Not invariant to the perspective projection (!) © Bedrich Benes © Bedrich Benes ...
View Full Document

This note was uploaded on 02/19/2012 for the course CGT 101 taught by Professor Mohler,j during the Fall '08 term at Purdue University-West Lafayette.

Ask a homework question - tutors are online