Re: [Maya2osg-users] Triangle winding question (maya usage)
Status: Alpha
Brought to you by:
jtaibo
From: Peter W. <pp...@cg...> - 2011-10-14 18:59:16
|
Hi J-S > Our modelers often create symmetric pieces by first creating half, then > duplicating that half, scaling it by -1, reversing the normals and then > freezing the transforms. At this point, if the two pieces are supposed to be one piece, the modelers should combine the pieces, and merge the vertices. I think this should fix the winding as well, but need to confirm. > This seems to work fine, at least in Maya, except that I notice now that > triangle winding (vertex order) is still inversed when they do that. > This manifests itself in two ways in our realtime app: Lighting > considers the wrong side of a face (light seems to come from the > opposite side) and backface culling is reversed (faces are culled when > looking from the outside instead of from the inside). If the two pieces are not combined, scaling by minus one and freezing tansform does set the oposite attribute of the shape to true. Maya2osg does consider this attribute, and it might be that this is the reason for the culling. Even in the lightning case this can true, as sometimes we do reverse the normals inside the plugin due to settings and the usage of GLSL shading. The GLSL Shaders do reverse the normals too, if the oposite flag is set, so we can't inverse the normals. @Javier, think we should unify this so that FFP and GLSL allways get the same normals, let's put this on the to do list. > I wonder, is there a way in Maya to reverse the triangle winding? I can > write a script (or search the net for one), but is there something built-in? Here I agree with Javier. This is also the answer to your other mail about the optimization of models. I will take some more timeto reply to that mail later :-) But to be honest I don't think that the winding is your problem here, see above, but of course I will consider it and look into it. > I was thinking of writing a script that would go through all polygons of > a model and compare the "implicit normal" (calculate a normal using the > vertex order in the triangle) to the saved normal (in the normal array) > and if it doesn't point in roughly the same direction, reverse the > vertex order. This assumes that the artist has made his normals all > point in the correct direction, so the normals are used as reference to > correct the triangle winding. I could then put this script on preExport > in the plugin. This sounds really tricky to do with a script, and slow as well. I will take a look into the api, maybe I can find something. But here is one idea that might help. What about an external Triangle Stripifier. Doesn't matter if you use the strips at all, but the Triangles would be alligned with the right winding. From the resulting data it should be easy to built triangle lists with right winding. In some article ( don't know which one, sorry ) I read once that there is an optimazation in osg that reorders the vertices of a triangle list, so that vertices of adjecent triangles are as close as possible in the vertex arrays, to optimize GPU vertex caching. This one should give you as well the right winding. > My question is really, do I have to do this myself or is there something > already there I can use? AFAIK, there's nothing to tweak, fix or optimize triangle winding directly. Cheers, PP |