-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normals flipped on transforms with negative scale #31
Comments
Hey @birdimus -- you're talking about face normals being flipped as a consequence of the negative scale reversing the winding order of the triangles, right? If so believe you're right in that this is something the tool should handle. I'll investigate further. |
Yes, exactly. In the case I'm looking at, the transform scale is (-1, 1, 1) |
@birdimus I've chatted with some folks and pondered a bit. It's not really the role of a converter to fix this. The glTF spec says: Implementation Note: If the determinant of the transform is a negative value, the winding order of the mesh triangle faces should be reversed. This supports negative scales for mirroring geometry. but this is really an instruction for the loader/client on how to interpret glTF, not how to create it. Furthermore, three.js explicitly warns against using negative scale in this situation; if you do, do it internally in the authoring program and then transform it before export. That said, it's clear from researching the issue and reading forums and the like that this is a common issue that people face, and I'd be up for adding a command line flag that tries as hard as it can to apply magic and do the right thing. This is far from the top of the TODO-list, though, so in the meantime is there anything you can do at the Blender/Maya/Modo/whatnot level? |
Yeah, for an individual file, I can open it in maya and freeze the transform. A lot of modelers will flip geo by scaling one axis to -1. It's not urgent, but it did catch my attention. Thanks for thinking about it. |
Hmm. I'll think about baking the scaling. Non-uniform scaling is tricky. The only practical way to do it I can think of would be to entirely collapse the entire tree beneath any node that has negative scaling and turn it all into a static mesh. Someone more up on their transformational algebra might be able to come up with a more elegant solution. In any case, a full bake is probably fine a lot of the time -- but obviously it won't work well in conjunction with rigged animation or anything along those lines. Maybe the command line option could literally be --bake-all-geometries, and that'd just also helpfully get rid of negative transforms on the way... |
I'm closing this because it's too far down on my TODO list, which in turn is because:
If three.js has issues rendering valid glTF, that's going to have to be a three.js fix. |
Surfaces with negative scale end up with backwards normals after conversion.
The text was updated successfully, but these errors were encountered: