1 / 32

Strips: Triangle and Quad

Strips: Triangle and Quad. Jyun-Ming Chen Reference: 1 , 2. From Blue Book. GL_TRIANGLE_STRIP For odd n , vertices n , n+1 , and n+2 define triangle n . For even n , vertices n+1 , n , and n+2 define triangle n . GL_QUAD_STRIP

irisa
Télécharger la présentation

Strips: Triangle and Quad

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Strips: Triangle and Quad Jyun-Ming Chen Reference:1, 2

  2. From Blue Book • GL_TRIANGLE_STRIP • For odd n, vertices n, n+1, and n+2 define triangle n. • For even n, vertices n+1, n, and n+2 define triangle n. • GL_QUAD_STRIP • Vertices 2n-1, 2n, 2n+2, and 2n+1 define quadrilateral n.

  3. Using Strips • Reduce number of glVertex calls • Each glVertex call send a data through pipeline: matrix multiplication, … 4D: 6v instead of 12v 3: 8v instead of 12v In general, nD: (n+2) v n: (2n+2) v

  4. b d f e a c GL_TRIANGLE_STRIP For odd n, vertices n, n+1, and n+2 define triangle n. For even n, vertices n+1, n, and n+2 define triangle n. Syntax • Sequence of vertices: follow the arrows separating the triangles abcdef [abc,bcd,cde,def] [abc,cbd,cde,edf] alternate winding; interpret as ….

  5. Swap Swap is a penalty; but breaking into two strips is more costly • Sometimes, additional vertices need to be added (known as swap) A penalty: need one more vertex for the swap d b abcdcef [abc,bcd,cdc,dce,cef] e a c alternate winding [abc,cbd,cdc,cde,cef] f

  6. b d f e a c Key Difference (swap) • Common edges • Head-tail connected: no swap • Strut exists: swap! d b e a c f

  7. The same geometry can be given by a triangle fan: aedcb Fan: a strip with many swaps b bacadae c (bac, aca, cad, ada, dae) d a e

  8. Algorithmically, how does one construct a strip given a set of connected triangles? Exercise • How can this strip be made? d b e a c g j f i h

  9. Other Topics of Triangle Strips • Winding: determined by the first triangle • Related: glFrontFace, glCullFace • Shading: • Smooth: specify normal vector preceding each vertex • Flat: only send (face) normal before the face-defining vertex

  10. b d f e a c Example abcdef (4D, 6v) All triangles are CW-winded e c a abcdef (4D, 6v) All triangles are CCW-winded f d b

  11. b d f e a c Example (Swap) e c a abcxcdef (5D, 8v) All triangles are CCW-winded f d b x aabcdef (4D, 7v) All triangles are CCW-winded

  12. b d f e a c Example (flat shading) Begin v(a) v(b) n(T1), v(c) n(T2), v(d) n(T3), v(e) n(T4), v(f) End T2 T4 T1 T3

  13. Remark: Flat Shading This code can be problematic! • According to spec, the color/normal of flat shaded polygon depends on the last primitive-defining vertex • So the code should work fine if glShadeModel(GL_FLAT) is specified • However, if the shade model is changed to GL_SMOOTH, the normal vectors will be assigned to either (0,0,1) or (-1,0,0) depending on the order of traversal. Be careful!

  14. Stripification New word for “strip generation”

  15. Each triangle associated with an adjacency number (degree in dual graph) Start from the triangle with lowest degree, collect along the path with uncollected & fewer degree triangle Greedy Stripping (SGI) Tend to minimize leaving isolated triangles 1 2 3 2 3 3 2 1 1

  16. Details (OpenMesh) • Assign each face with the following integer property: degree (face valence); collected • For triangular mesh, four possible values for degree: 0 (isolated), 1, 2, 3 • No need to sort; just start from any triangle with degree 1. When exhausted, start with degree 2, then degree 3. • Output degree 0 triangle as GL_TRIANGLES • Collect the triangle.idx into an STL vector • Degree update • When a triangle is collected, decrement the degree of its neighbors

  17. 1 2 1 2 0 1 2 2 3 2 2 2 3 3 2 3 3 3 2 2 2 1 1 1 1 1 1 0 1 0 0 0 0 1 1 1 1 1 0 2 2 3 2 2 2 2 1 2 1 1 1 1 1 0 0 0 Degree Update 1 0 2 1 1 1 0

  18. Supplement • Strip collection is related to finding Hamliton paths in the dual graph • While a single Hamilton path seems impossible, longer strips are preferred (for better rendering speed) Wikipedia: In the mathematical field of graph theory, a Hamiltonian path (or traceable path) is a path in an undirected graph which visits each vertex exactly once.

  19. Stripification (Kommann) • Starting triangle: one with least number of adjacency that are not part of any strip • Idea: process isolated triangles first • Step • Evaluate the weight all neighboring triangles; choose the one with minimum weight to continue the strip

  20. Kommann (cont) • Weight evaluation • Face Connectivity: 0,1,2 (# of triangles not visited) – include poorly connected triangles first • Node connectivity: use connectivity of nodes of the current triangle to decide which side to add: +1 for highest connected node, -1 for all other nodes • Swap required: +1(yes), -1(no)

  21. Weight assignment References: 1, 2

  22. Strip for a Cube

  23. Compare GL_QUADS Vertices 4n-3, 4n-2, 4n-1, and 4n define quadrilateral n. GL_QUAD_STRIP Vertices 2n-1, 2n, 2n+2, and2n+1 define quadrilateral n. Quad strip • Syntax • Winding (consistent) • Shading • smooth shading: averaging vertex colors • Flat shading: the color of the last defining vertex

  24. Example (quadstrip) 0 2 4 1 3 5 Using quadstrip: we give 0,1,2,3,4,5 Quads are formed as (0,1,3,2) and (2,3,5,4) Using quads: we need to give 0,1,3,2, 2,3,5,4

  25. i=1 Assuming all triangles are CCW-oriented Algorithm: Strip construction • Add the vertices of the D1(i=1) to the strip. • From the “stand alone” vertex • Increment i, adding Di • Consider the existence of Di+1: • If no, add the “other v” of Di • If yes, find the common vertex between Di+1 & Di-1 • If the common vertex is the last (tail) vertex in the strip, add the “other v” of Di • If not, add the common vertex to the strip (swap), then add the “other v” of Di • Proceed to step 2, until all triangles have been added Stand-alone

  26. Step 1 • Stand alone vertex • Find the common vertices between D1 & D2 • Take the one that’s left alone

  27. other v other v other v i i i i-1 i-1 i-1 Step 3 Cases i+1 i+1 • No Di+1 • Add “other v” • Di+1 (with swap) • Di+1 (with no swap)

  28. Example Input: triangles to be put in a strip (D1-8) Output: the vertices forming the strip (the 13 vertices) d b 2 1 3 e a c 4 5 g j f 6 8 7 i h If the common vertex between Di+1 & Di-1 is not end of strip, swap is needed

  29. Remark The underlying data structure should be able to answer these queries efficiently • Stand-alone vertex of triangle • “other-v” of a triangle • Common vertex of two triangles • For Kommann stripification • Number of unvisited neighbors of a triangle • Number of triangles connecting to a vertex

  30. [Tagging] A quicker way to find the intersection of two sets xxxx xxxx ^ | 0001 0001 xxxx ToggleTag SetTag xxx1 xxxx & 0001 000x IsTagged xxxx & 1110 ClearTag xxx0

  31. Stripifier by OpenMesh • OpenMesh/Tools/Utils • The strips generated are not as good

  32. Stripifier

More Related