View Full Version : Triangle strip and face culling

yossi

09-25-2005, 05:51 AM

Hello,

Just wanted to know,

When drawing a triangles strip, every vertex added to the strip (which defines a new triangle with the previous two vertices) change the triangle orientation.

But when culling is on, all the triangles are rendered correctly, so I guess the driver takes into acount this fact of toggeling the orientation

of the triangles in the strip.

Would like to get more info on that,

Thanks,

Yossi

ZbuffeR

09-25-2005, 02:56 PM

When drawing a triangles strip, every vertex added to the strip ... change the triangle orientation.Wrong. Else it would be a real mess :p

http://www.york.ac.uk/services/cserv/sw/graphics/OPENGL/L2d.html

Hello,

why is he wrong? Consider a two triangle strip:

[0]---[2]

| / |

| / |

[1]---[3]

it is composed of two triangles: the first uses vertices 0, 1, 2 and the second uses vertices 1, 2 and 3. The first triangle is anticlockwise (the edge 0--1 is on the left side of the triangle and moves from top to bottom), whereas the second triangle is clockwise: edge 1--2 is also on the left of its third vertex, yet is moves from bottom to top. Clearly the winding order is alternating between successive triangles.

I belive the ordering is taken from the first pair and is then the clockwise/anticlockwise test is effectively flipped for successive triangles. In this case, the strip would be culled if you had front face with CW ordering.

cheers

John

Overmind

09-26-2005, 02:44 AM

No, it's more like on every even triangle two vertices are swapped.

So the triangles in a strip would correctly be:

0,1,2

2,1,3

2,3,4

4,3,5

4,5,6

6,5,7

...

(instead of simply 0,1,2 1,2,3 2,3,4 ...)

ZbuffeR

09-26-2005, 06:46 AM

john, instead of asserting that, just check the spec.

http://www.opengl.org/documentation/specs/version2.0/glspec20.pdf

pdf page 31 (page labelled 17) : figure 2.4 'Note that...'

> No, it's more like on every even triangle two vertices are swapped.

exactly. so you're swapping the *vertices* to make the *test* consistent. that is no different from swapping the *test* and not the *vertices* to make culling consistent.

Either way, something has to be swapped to make culling consistent. You're advocating that 0, 1, 2 and then 2, 1, 3 is somehow more consistent--more *correct*--than flipping the test.

if you define winding order with respect to the direction of consecutive vertices when viewed from the same side, then alternate vertices have to be flipped, which is in a way redefining your definition of winding order to "winding order is whatever opengl decides it to be, and that's dome function of where this triangle is in in the strip and something else."

its no assertion to acknowledge that sometning HAS to bc changed. i am greatly amused that the idea of changing the vertices is a better "solution" to defining the problem then flipping the test.

> just check the spec.

http://www.opengl.org/documentation/specs/version2.0/glspec20.pdf

pdf page 31 (page labelled 17) : figure 2.4 'Note that...'

that example agrees wtih me, eacatly. the ordering of the STRIP is determioned by the first triangle, certainly, so something has to change for alternating triangles. i never said otherwise.

thus,

0 1

/

2 3is clockwise for all triangles because it is defined by the first (even though the triangle 1, 2, 3 is ccw defined by the order of successive vertices, so SOMETHING has to change--either the test or two vertices), whereas

0 2

/

1 3is CCW for the entire strip, even though 1, 2, 3 is CW. therefore, that figure in the opengl spec doesn't contradict my position.

my position, incidentially, is not to disagree with this statement:

> When drawing a triangles strip, every vertex added to the strip ... change the triangle orientation.

> *Wrong*

every vertex added to the strip DOES change the triangle orientation *IF* you define winding order as the direction of sucessive vertices. so, saying it is wrong IS wrong.

the answer is "yes, that is true: adding successive vertices DOES change the winding order, and if left unchecked, this WOULD create a mess. BUT: opengl defines the winding order on the first triangle (which is true, c.f. fig 2.4) and then either alternates the test on successive vertices, or flips the last two vertices."

my objection was to asserting something was wrong, when clearly this is not the case. adding vertices DOES change the winding order, but opengl itself CHANGES something to make the test right.

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.