Skip to content
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

Closed
birdimus opened this issue Nov 2, 2017 · 6 comments
Closed

Normals flipped on transforms with negative scale #31

birdimus opened this issue Nov 2, 2017 · 6 comments

Comments

@birdimus
Copy link

birdimus commented Nov 2, 2017

Surfaces with negative scale end up with backwards normals after conversion.

@zellski
Copy link
Contributor

zellski commented Nov 3, 2017

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.

@zellski zellski added the bug label Nov 3, 2017
@birdimus
Copy link
Author

birdimus commented Nov 3, 2017

Yes, exactly. In the case I'm looking at, the transform scale is (-1, 1, 1)

@zellski
Copy link
Contributor

zellski commented Nov 6, 2017

@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?

@zellski zellski added this to the Aspirational milestone Nov 6, 2017
@zellski zellski added enhancement and removed bug labels Nov 6, 2017
@birdimus
Copy link
Author

birdimus commented Nov 7, 2017

Yeah, for an individual file, I can open it in maya and freeze the transform.
For bulk conversion, that becomes untenable.

A lot of modelers will flip geo by scaling one axis to -1.
If Three is known to have issues, could we not 'bake' negative scale at import time - so the export only delivered 'valid' positive scaled transforms?

It's not urgent, but it did catch my attention. Thanks for thinking about it.

@zellski
Copy link
Contributor

zellski commented Nov 7, 2017

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...

@zellski
Copy link
Contributor

zellski commented Aug 22, 2018

I'm closing this because it's too far down on my TODO list, which in turn is because:

  • This kind of scaling is actually perfectly valid in glTF
  • The only solution I came up with was a massive geometry bake
  • It won't work in combination with animations anyway

If three.js has issues rendering valid glTF, that's going to have to be a three.js fix.

@zellski zellski closed this as completed Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants