Page MenuHome

Provide option to "preserve first edge" in mirror modifier
AbandonedPublic

Authored by David Swift (rococo) on Aug 2 2020, 7:02 PM.

Details

Summary

As described in T77575 and this devtalk post the orientation of "duplifaces" instances is confusing under mirroring.

Briefly, the Y axis is calculated to be perpendicular to the polygon normal and the first edge in the edge loop. Reversing the edge loop order (to flip the normal) results in the Y axis being perpendicular to the last edge.

This patch extends the mirror modifier with an option to "preserve face space", which produces much more consistent results for quads and triangles used for face instancing. Since this changes the tessellation of the polygons, this is provided as an option rather than simply being the default.

Diff Detail

Repository
rB Blender
Branch
arcpatch-D8445 (branched from master)
Build Status
Buildable 11723
Build 11723: arc lint + arc unit

Event Timeline

David Swift (rococo) requested review of this revision.Aug 2 2020, 7:02 PM
David Swift (rococo) created this revision.

Updated using arcanist rather than manually submitting patch

Apologies, still learning how to use arc properly and accidentally pulled in a change to object_dupli.c. Let me see if I can undo that.

Remove accidentally submitted file

If the option leads to a more consistent results, why is not enabled by default and why is this even an option?

If the option leads to a more consistent results, why is not enabled by default and why is this even an option?

It produces more consistent results for instancing; unfortunately it also changes the way quads (and other ngons) get triangulated which would be undesirable in other situations.

If there's a way to control triangulation separately (is it precalculated?) I agree it would be better if this happened invisibly.

Bastien Montagne (mont29) requested changes to this revision.Oct 16 2020, 2:26 PM

General approach seems fine, and think we indeed need to keep this as an option, as depending on usages of mirrored geometry one will want one or the other behavior. Mostly noted style and UI messages points below.

source/blender/blenkernel/intern/mesh_mirror.c
258

Can be const, also better have one variable per line especially when assigning to them, it's clearer.

source/blender/makesrna/intern/rna_modifier.c
2197

'Preserve first edge' is a good technical name, but not a good user one.

'Preserve face space' maybe?

2198

No final point to UI messages (and better avoid multi-sentences ones as much as possible).

"Preserve the face space orientation (important e.g. for instancing), but generate different tessellation" ?

source/blender/modifiers/intern/MOD_mirror.c
207

Better avoid re-defining another label here, unless it is absolutely necessary (rest of this existing code could use some cleanup in that regard btw).

This revision now requires changes to proceed.Oct 16 2020, 2:26 PM
  • Address code review notes
David Swift (rococo) marked 3 inline comments as done.Dec 13 2020, 9:51 PM
David Swift (rococo) added inline comments.
source/blender/modifiers/intern/MOD_mirror.c
207

Was copying the style of the surrounding code but I see how leaving the string NULL uses the property definition. I may submit a refactor of this code in a separate patch.

David Swift (rococo) edited the summary of this revision. (Show Details)Dec 13 2020, 9:53 PM
David Swift (rococo) marked 2 inline comments as done.
  • Change "preserve first edge" identifiers to match "preserve face space"
Bastien Montagne (mont29) requested changes to this revision.Dec 21 2020, 2:17 PM

Looks fine now, mostly needing some updates against latest master.

source/blender/blenkernel/intern/mesh_mirror.c
262–263

We require our comments to be proper sentences, including initial capital and final period.

(I know historic code is often breaking that rule, but new one at least should follow it.)

source/blender/modifiers/intern/MOD_mirror.c
207

Think this patch needs updates now right?

This revision now requires changes to proceed.Dec 21 2020, 2:17 PM

Changed comments to be full sentences

David Swift (rococo) marked an inline comment as done.Dec 21 2020, 7:04 PM

Rebased these changes to master so I believe this should be up to date now.

This revision is now accepted and ready to land.Dec 23 2020, 4:25 PM

This patch has an approved status however it was not committed yet. So I'm assuming the other reviewers are blocking. Updating the reviewers list to reflect this. This way the patch status still show as Need Review.

Also removing modifier since this is not a module that someone can talk on behalf of anyways.

This revision now requires review to proceed.Mar 26 2021, 5:53 PM

Would it be fair to say at this point that Geometry Nodes provide the generalized solution to this kind of problem and the old way of doing instancing will slowly go away? If so this "fix" would therefore be unnecessary.

On the other hand the same problem should be considered if creating a node that converts faces to points/instances. My recommendation would be to use the texture coordinates instead which are more easily visualized and operated upon.

Would it be fair to say at this point that Geometry Nodes provide the generalized solution to this kind of problem and the old way of doing instancing will slowly go away? If so this "fix" would therefore be unnecessary.

On the other hand the same problem should be considered if creating a node that converts faces to points/instances. My recommendation would be to use the texture coordinates instead which are more easily visualized and operated upon.

I disagree on this quite entirely. The beauty of face instancing for me has always been that I don't need to manage modifiers on multiple objects to get the desired results. However the downside has then been that mirroring & using deform modifiers have always been difficult because of the issue described here.

I see no reason not to commit this. At lesat I will continue using face instancing at least until we get to see something like "collection modifiers".

However the downside has then been that mirroring & using deform modifiers have always been difficult because of the issue described here.

I feel like the real solution here is to extend face instancing to make it behave more consistently over mirroring (e.g. by computing transforms based on texture coords like I suggest above).

Benefits:

  • Only adds options where they make sense contextually: in the face instancing options
  • Improves face instancing
    • More easily visualized and edited using existing tools
    • Makes it easier to drive instances procedurally e.g. through generated texture coords
  • Provides a more natural transition to geometry nodes in the future

Downsides:

  • Patch doesn't exist yet! Although I did implement a basic prototype
  • Deciding which way round the coordinate system belongs will probably be a big discussion

However the downside has then been that mirroring & using deform modifiers have always been difficult because of the issue described here.

I feel like the real solution here is to extend face instancing to make it behave more consistently over mirroring (e.g. by computing transforms based on texture coords like I suggest above).

Benefits:

  • Only adds options where they make sense contextually: in the face instancing options
  • Improves face instancing
    • More easily visualized and edited using existing tools
    • Makes it easier to drive instances procedurally e.g. through generated texture coords
  • Provides a more natural transition to geometry nodes in the future

Downsides:

  • Patch doesn't exist yet! Although I did implement a basic prototype
  • Deciding which way round the coordinate system belongs will probably be a big discussion

Alright, I will be waiting impatiently 😁