Fixup normals in add_mesh_solid generated meshes. #105117
No reviewers
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#105117
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "gds/blender-addons:fix-normals-on-solids"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Certain of the presets for add_mesh_solid have faces where their normals are inverted. This commit takes each mesh that's added and invokes
normals_make_consistent
on it to fix the normals.The presets that had bad normals were the Rhombicuboctahedron, Truncated Cuboctahedron, Snub Cube, Rhombicosidodecahedron, and Snub Dodecahedron.
With this change, these solids are fixed as will be any new ones that happen to be added with faces ordered the wrong way.
https://imgur.com/a/YLhkPhT shows the Rhombicuboctahedron with an embedded light emitting cube before the fix, and https://imgur.com/a/S9pU41I shows it after.
Note that this issue was raised on Blender StackExchange as https://blender.stackexchange.com/questions/309376/refraction-bsdf-shader-showing-as-opaque-for-certain-meshes-and-angles, and the responder pointed out the problem with the normals. This fixes that.
I think it would be better to try and find the cause of the problem in the existing code and fix that, than to add a bunch of code to 'fix' things afterwards.
I had a look at this. When vertex truncation is > 1.0, the truncated polyhedron is computed using a mirrored (scaled -1.0) dual of the base polyhedron. Duals themselves are mirrored as well.
I think that’s a good strategy, and computing inverted normals during mesh generation seems much more complex than making them consistent after the fact. However I also think this can be made simpler than the proposed solution, by using bmesh:
Also noticed that the faces are converted to quads, probably because the add-on was written before the introduction of ngons with bmesh, so this conversion should be removed in my opinion.
Flipping polygon normals can be done by reversing the order of the vertices of each face, I've done this for each of the scaled * -1 cases in my fork:
93d3b64772
It seems to work and I would prefer this to recalculating normals afterwards, but I'll check more tomorrow because I'm exhausted right now.
You’re right, it’s not as hard as I thought it would be and your fix is better.
I found another issue, which is that the dual tetrahedron gets flipped when it has a vertex truncation of 2.0. I think it needs to be mirrored as well:
No hurry for me :)
Thanks @Mysteryem and @pioverfour for taking a look!
I didn't know about
bmesh
, and that's definitely a better and cleaner approach than what I was doing with updating and restoring the current selection.I'm less certain about fixing these normals at the source of their problem. The extra issue that @pioverfour found with the dual tetrahedron is a good example of why it may be a whack-a-mole problem to get all these right, vs. the guaranteed fixup at the end.
Also, the problem is also hidden by the fact that many uses (maybe most uses) don't subject these solids to shaders that care about the sign of the normal.
I'm a Blender pull-request n00b, so don't know the expectation from me at this point. I'm happy to update this pull request to the
bmesh
route and feel confident in it. This would be my preferred solution due to the whack-a-mole nature I mention, and the fact that the createSolid method is already super complicated with many if-else branches, and adding to those just makes it more complex.Suggestions?
Great that you learned something ;)
Well, I do think @Mysteryem has a point and their fix is solid. The issue I noticed is not really related to the normals, and should be investigated anyway.
IMO Mysteryem’s solution doesn’t add that much more complexity, and there aren’t really that many combinations to test. This script should be comprehensive enough to check the normals:
Before:
After:
I made a PR for my changes (#105123), it doesn't touch the issue of the dual tetrahedron being flipped, it's only for the normals issue.
Abandoning this PR in favor of !105123. Thanks @Mysteryem!
Pull request closed