• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualJWalsh

Posted 31 July 2012 - 01:47 PM

Winding Order
Any time you draw a triangle (or quad) there are two surfaces. One on the front of the triangle, and one on the back. When you draw a 3D shape such as a box, half of the surfaces are facing outward in space and are visible, the other half are facing inward, and are in theory, covered by the other side of the box. Unfortunately, unless you give the renderer specific instructions, it doesn't know which triangles are facing inside, and which are facing outside. So left to its own devices, it will try and draw all triangles. This often results in the back side of a 3D primitive drawing over the front side, which is a really disorienting effect, actually.

To solve the problem, the graphics engine can use the winding order of the primitives to determine whether something is front facing or back facing. Here's a little trick, take your pen, put it on paper and draw the three points of a triangle. Now, number them in a circle 0, 1, 2. Notice that if you flip the paper around, the numbers are in reverse order. That is, if you numbered them clockwise before, they are now counter-clockwise, and vice-versa.

This is the system the renderer uses to determine which "faces" should be drawn, and which shouldn't. You can tell the renderer to cull (don't draw) all clockwise surfaces, or you can tell it cull counter-clockwise surfaces. Or, if you disable back-face culling, it will draw all primitives. You're not noticing any adverse effects when disabling back-face culling because you're only drawing single primitives. Before moving on, however, you'll want to re-enable back-face culling and instead change the orientation of the vertices in your quad so they are consistent with the rest of your scene. As OpenGL is a right-handed system, I believe it disables clockwise primitives by default, which is why your red quad wasn't showing.You'll want to make sure whenever you add geometry to the scene, you do so in a counter-clockwise orientation.

World Space vs. Screen Space
Your quad is showing up small because you've got it drawing in the range of -1 to 1 at the origin of your scene. To make it draw over the entire scene, you either need to move it along with your camera and make it bigger, or you need to draw it in screen space using pre-transformed primitives. Given that you're not familiar with winding order, I'm going to guess that pre-transformed primitives is beyond you. So for now, make sure you specify the points of the quad as being just in front of your camera, and large enough that it covers the display area. It's not the correct approach, but it'll work for now.

Cheers and good luck!

### #1JWalsh

Posted 31 July 2012 - 01:45 PM

Winding Order
Any time you draw a triangle (or quad) there are two surfaces. One on the front of the triangle, and one on the back. When you draw a 3D shape such as a box, half of the surfaces are facing outward in space and are visible, the other half are facing inward, and are in theory, covered by the other side of the box. Unfortunately, unless you give the renderer specific instructions, it doesn't know which triangles are facing inside, and which are facing outside. So left to its own devices, it will try and draw all triangles. This often results in the back side of a 3D primitive drawing over the front side, which is a really disorienting effect, actually.

To solve the problem, the graphics engine can use the winding order of the primitives to determine whether something is front facing or back facing. Here's a little trick, take your pen, put it on paper and draw the three points of a triangle. Now, number them in a circle 0, 1, 2. Notice that if you flip the paper around, the numbers are in reverse order. That is, if you numbered them clockwise before, they are now counter-clockwise, and vice-versa.

This is the system the renderer uses to determine which "faces" should be drawn, and which shouldn't. You can tell the renderer to cull (don't draw) all clockwise surfaces, or you can tell it cull counter-clockwise surfaces. Or, if you disable back-face culling, it will draw all primitives. You're not noticing any adverse effects when disabling back-face culling because you're only drawing single primitives. Before moving on, however, you'll want to disable back-face culling and instead change the orientation of the vertices in your quad so they are consistent with the rest of your scene. As OpenGL is a right-handed system, I believe it disables clockwise primitives by default, which is why your red quad wasn't showing.You'll want to make sure whenever you add geometry to the scene, you do so in a counter-clockwise orientation.

World Space vs. Screen Space
Your quad is showing up small because you've got it drawing in the range of -1 to 1 at the origin of your scene. To make it draw over the entire scene, you either need to move it along with your camera and make it bigger, or you need to draw it in screen space using pre-transformed primitives. Given that you're not familiar with winding order, I'm going to guess that pre-transformed primitives is beyond you. So for now, make sure you specify the points of the quad as being just in front of your camera, and large enough that it covers the display area. It's not the correct approach, but it'll work for now.

Cheers and good luck!

PARTNERS