Re: [Maya2osg-users] Triangle winding question (maya usage)
Status: Alpha
Brought to you by:
jtaibo
From: Javier T. <jav...@gm...> - 2011-10-14 20:32:15
|
On Fri, Oct 14, 2011 at 8:59 PM, Peter Wrobel <pp...@cg...> wrote: > 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. > I assumed that the geometry is in one shell, otherwise, what I say in last message has no sense. > > 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. > We treat normals and backface culling taking into account the "double sided" and "opposite" options in the Maya mesh. And they should behave the same in FFP and GLSL. If they don't it is a bug. Moreover, we have a test model for this backface culling and lighting issues. I'll take a look as soon as I can, but I think last time I checked that it worked OK. > 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. > Cool! If you find this reference, please share it. It's interesting. Regards, -- Javier Taibo |