Thread: [Maya2osg-users] Winding again!
Status: Alpha
Brought to you by:
jtaibo
From: Jean-Sébastien G. <jea...@cm...> - 2011-10-18 16:26:35
|
Hi guys, I think I found the case where winding will affect surfaces. An object scaled by -1 will have its normals inverted and winding will be inverted too. Maya sets the "opposite" mode on this. It makes it look OK in Maya. If, in the plugin, I set "flip normals if surface mode is opposite", then the plugin will invert the normals (* -1) but the winding will still be wrong, so they will be culled by CULL_FACE even though lighting is correct. If I reverse the normals in Maya, my guess is that Maya also reverses winding, because then all is OK. So I think the plugin should warn when the surface mode is set to opposite AND single sided, as that will not work unless triangle winding is reversed (which is maybe too complex for an export plugin to do). At least with a warning artists can see there is a problem and fix it on the affected surfaces. If the data is wrong, fix the data! :-) Thanks, J-S -- ______________________________________________________ Jean-Sébastien Guay jea...@cm... http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ |
From: Javier T. <jav...@gm...> - 2011-10-18 19:36:42
|
On Tue, Oct 18, 2011 at 6:26 PM, Jean-Sébastien Guay < jea...@cm...> wrote: > Hi guys, > > I think I found the case where winding will affect surfaces. > > An object scaled by -1 will have its normals inverted and winding will > be inverted too. Maya sets the "opposite" mode on this. It makes it look > OK in Maya. If, in the plugin, I set "flip normals if surface mode is > opposite", then the plugin will invert the normals (* -1) but the > winding will still be wrong, so they will be culled by CULL_FACE even > though lighting is correct. > I don't remember why is this "flip normals if surface mode is opposite" option required. Probably Peter explained it to me some time ago, but I don't remember. It was supposed to work automatically in FFP as well as in GLSL mode. Peter can you throw some light here? -- Javier Taibo |
From: PP CG <pp...@cg...> - 2011-10-19 07:42:02
|
Hi guys, > I don't remember why is this "flip normals if surface mode is > opposite" option required. Probably Peter explained it to me some time > ago, but I don't remember. It was supposed to work automatically in > FFP as well as in GLSL mode. > > Peter can you throw some light here? When I added this option I thought one could save a StateSet change when some surfaces have backface culling and some frontface culling. But AFAIK we figured that it was not working correctly, and removed this option from the UI. @Javier, I think you needed it only for one special case ( Shders ? ). @J-S, you mentioned that you are using some older version of Maya2osg, do you still have the flag in the UI ? It should not be there. Cheers, PP |
From: PP CG <pp...@cg...> - 2011-10-19 07:43:44
|
Hi J-S, > Hi guys, > > I think I found the case where winding will affect surfaces. > > An object scaled by -1 will have its normals inverted and winding will > be inverted too. Maya sets the "opposite" mode on this. It makes it look > OK in Maya. If, in the plugin, I set "flip normals if surface mode is > opposite", then the plugin will invert the normals (* -1) but the > winding will still be wrong, so they will be culled by CULL_FACE even > though lighting is correct. > > If I reverse the normals in Maya, my guess is that Maya also reverses > winding, because then all is OK. > > So I think the plugin should warn when the surface mode is set to > opposite AND single sided, as that will not work unless triangle winding > is reversed (which is maybe too complex for an export plugin to do). At > least with a warning artists can see there is a problem and fix it on > the affected surfaces. If the data is wrong, fix the data! :-) Wouldn't just reversing the Vertex or Element Arrays do trick ? Cheers, PP |
From: Jean-Sébastien G. <jea...@cm...> - 2011-10-19 12:49:47
|
Hi Peter, Replying to your two messages: > @J-S, you mentioned that you are using some older version of Maya2osg, > do you still have the flag in the UI ? It should not be there. I will be updating to the trunk of the plugin today I guess. However I am afraid that it won't contain the changes I sent since the last few days. Have you committed your latest changes Peter? > Wouldn't just reversing the Vertex or Element Arrays do trick ? I think so. But I think maybe it's not the plugin's job to do this. Maybe it could print a warning if the surface mode "opposite" is checked in Maya, and then the artist can fix it. I think from a maintainability point of view, it's better if the plugin helps the artist make his model correct so then it doesn't need to contain too many case-by-case fixes for bad models. Less code = better IMHO. J-S -- ______________________________________________________ Jean-Sébastien Guay jea...@cm... http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ |
From: PP CG <pp...@cg...> - 2011-10-19 17:27:03
|
Hi J-S, > I will be updating to the trunk of the plugin today I guess. However I > am afraid that it won't contain the changes I sent since the last few > days. Have you committed your latest changes Peter? Yes, in my local they are, but not the unit patch, as for this would take again some time for debugging animation stuff, and I am not sure if I'll have the time for this. Currently I am working on all the stuff, and trying to debug some error. As said, most probably I'll need till the end of the week. I suggest you use the current trunk of the repo, the patches that you sent were just few, so should be added very fast. Cheers, PP |
From: Javier T. <jav...@gm...> - 2011-10-19 19:26:28
|
On Wed, Oct 19, 2011 at 9:41 AM, PP CG <pp...@cg...> wrote: > Hi guys, > > > I don't remember why is this "flip normals if surface mode is > > opposite" option required. Probably Peter explained it to me some time > > ago, but I don't remember. It was supposed to work automatically in > > FFP as well as in GLSL mode. > > > > Peter can you throw some light here? > > When I added this option I thought one could save a StateSet change when > some surfaces have backface culling and some frontface culling. But > AFAIK we figured that it was not working correctly, and removed this > option from the UI. > @Javier, I think you needed it only for one special case ( Shders ? ). > I think I don't need it. It wasnt originally in the export options. The opposite flag was checked in FFP as well as in GLSL. There were some bugs about this some time ago, but I thought I solved them. I'll take a look at it as soon as I can, to check if it is working OK. Regards, -- Javier Taibo |
From: PP CG <pp...@cg...> - 2011-10-22 18:44:05
|
Hi, found the place ( code ) of confusion, Line 281 in Mesh.cpp // Revert normals if opposite (needed for correct lihgting when using FFP) // If we are using GLSL instead of FFP, we do not reverse the normals because // it is already done in the shader bool reverse_normals = !Config::instance() -> getArgBool( "-useGLSL" ) && !doubleSided(mDagPath.node()) && opposite(mDagPath.node()); float normalDirection = ( reverse_normals ? -1.0f : 1.0f ) ; What to do about it ? I think we should keep the setting, but need to switch the culling ( backface, frontface ) as well, and that shoud fix J-S issue, right ? Cheers, PP > > On Wed, Oct 19, 2011 at 9:41 AM, PP CG <pp...@cg... > <mailto:pp...@cg...>> wrote: > > Hi guys, > > > I don't remember why is this "flip normals if surface mode is > > opposite" option required. Probably Peter explained it to me > some time > > ago, but I don't remember. It was supposed to work automatically in > > FFP as well as in GLSL mode. > > > > Peter can you throw some light here? > > When I added this option I thought one could save a StateSet > change when > some surfaces have backface culling and some frontface culling. But > AFAIK we figured that it was not working correctly, and removed this > option from the UI. > @Javier, I think you needed it only for one special case ( Shders ? ). > > > I think I don't need it. It wasnt originally in the export options. > The opposite flag was checked in FFP as well as in GLSL. There were > some bugs about this some time ago, but I thought I solved them. I'll > take a look at it as soon as I can, to check if it is working OK. > > > Regards, > > -- > Javier Taibo > > > > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Ciosco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > > > _______________________________________________ > Maya2osg-users mailing list > May...@li... > https://lists.sourceforge.net/lists/listinfo/maya2osg-users |
From: Javier T. <jav...@gm...> - 2011-10-22 21:27:59
|
Hi all, At least I have some time again to deal with Maya2OSG... :) On Sat, Oct 22, 2011 at 8:43 PM, PP CG <pp...@cg...> wrote: > Hi, found the place ( code ) of confusion, Line 281 in Mesh.cpp > > // Revert normals if opposite (needed for correct lihgting when using > FFP) > // If we are using GLSL instead of FFP, we do not reverse the normals > because > // it is already done in the shader > bool reverse_normals = !Config::instance() -> getArgBool( "-useGLSL" ) > && !doubleSided(mDagPath.node()) && opposite(mDagPath.node()); > float normalDirection = ( reverse_normals ? -1.0f : 1.0f ) ; > > What to do about it ? I think we should keep the setting, but need to > switch the culling ( backface, frontface ) as well, and that shoud fix J-S > issue, right ? > This is how I left this code, and AFAIK it should be working OK. I don't really know the meaning of the "flip normals if surface mode is opposite" option, that I can see in current trunk is not present anymore. As I said, I think it is working OK right now. The test model I use is the one in "tests/project/scenes/test_geometry.ma". It has all the combinations of single/double/opossite and smooth and hard edges and so on... I tested it with FFP and GLSL shaders and the look is just as seen in the Maya viewport. @J-S: Can you test if the problem you detected still exists and in such case could you add an example of your offending geometry to the " test_geometry.ma" test model so we can use it for fixing the problem and keep it for future tests? Regards, -- Javier Taibo |