Jump to content

Consistent counter clockwise winding ??


Drongle McMahon
 Share

You are about to reply to a thread that has been inactive for 4755 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

We have been asked to paye attention to having consistent counter-clockwise winding in our physics meshes, for performace reasons. I got some help, thanks, but am still somewhat confused about exactly what this means and, more important, how to control it. Can anyone offer either a definitive layman's explanation or a means of making sure of this in Collada exports from Blender? Or even both?

:matte-motes-confused:

  • Like 1
Link to comment
Share on other sites

Winding describes the vertex order of a polygon. Polygons with clock-wise winding face towards the viewer and are not back-facing. Polygons with counter-clockwise winding face away from the viewer and are back-facing. All the faces in a mesh must have the same winding order. One face cannot "backface" from the other faces.

IM STILL CONFUSED

Link to comment
Share on other sites

Thanks

I think I am getting there. The Collada file only has vertex normals. Each triangle in the triangle list (I always export triangles only) has three vertices, each of which has indices into a position table and a normal table.  So the Collada doesn't know anything about the face normals we can see in Blender.

Now "solid" Blender faces have all three vertex normals the same as the face normal (so they are shaded flat), and the normal points outward from the visible side of a one-sided face. So for solid faces it would be possible to imply the sidedness of a face from the identical vertex normals.

However, for "smooth" faces, the face normal does not necessarily point to the same side of the face as any or all of the vertex normals. Thus the sidedness of the face cannot generally be implied from the vertex normals. Consequently, the sidedness has to be specified from the counter-clockwise rule. Inspecting the exported Collada for a two-triangle plane with triangles the same way up, and with one of them flipped, confirms that the order of entry of the vertices is always counter-clockwise when you are looking at the visible face (the one the face normal sticks out of in Blender).The exporter must be ensuring that this convention is followed.

From there, I am going to assume that "consistent" means that the visible side of two faces that are connected along an edge must be on the same side when the crease along that edge is flattened. In Blender, this means the face normals must point in the same direction. For nice closed solid meshes, this means they all point inwards or all point outwards.

It is quite easy to overlook this when you are making a custom physics mesh. I have done so, and it has starnge effects on decomposition (see next post). That may be why Falcon saw the need to encourage us to keep to this rule. I wonder whether the performance issues are with or without decomposition, or both?

Edit - whoops. I said always clockwise when I meant counter-clockwise ... corrected now

Link to comment
Share on other sites

I was wondering about this because I had been making physics shapes for corridors. Simplifying, these are equivalent to a tube made by removing two opposite faces of a cube. I looked at all possible combinations of the normals (visible sides) on the four remaining faces; (a) all outward, (b) three outward and one wall inward, © two opposite inward, others outward, (d) three inward and one outward, (e) all inward. Clearly all except (a) and (e) would have inconsistent winding if the explanation of this I offered is correct. I uploaded (or started to) these with default LODs and using the high LOD as the physics mesh.

With no decomposition (don't press Analyze button), these all uploaded and all allowed me to walk through the tube when the physics shape type was set to Prim. I guess the "inconsistent" ones, although they work, are the ones Falcon does not want to see. I don't have any way of measuring their efficiecy though. They all had the same physics cost. Or maybe, since these are triangle-based shapes, it doesn't apply here.

With decomposition, the results were different for each tube. For Surface decomposition, (a) with all faces outward, yielded a solid box which you could not walk through (left picture). When just one face was turned inward (b), the result was two planes and a prism shape that blocked half the corridor (right picture). All the others produced four separate planar hulls (4 points each) which allow you to walk through (middle picture). With solid decomposition, (a) again gave an impenetrable solid box. So, surprisingly, did © with two opposite faces pointing inwards. The other three forms failed to decompose - no error message, just stayed there with the triangle based physics mesh.

So the surface decomposition can make a phsyics shape that works for a corridor from either a mesh with consistent winding or one with inconsistent winding (according to my limited understanding). I tried both © and (e). They both worked as expected and both had the same physics cost. Again, I suppose one of these is preferable to the other unless Falcon's advice applies only to triangle-based shapes, but I can't see any manifestation of the difference.

tubedecomps.png


Link to comment
Share on other sites

  • Lindens

Apologies for the confusion!

Its important for physics, yes, but our algorithms under the hood should be ordering triangles in this manner for rendering anyways. You guys should not have to worry or stress about the winding of your meshes.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4755 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...