Page MenuHome

Geometry Nodes: Fix "Make Instances Real" operator to work with modifier instances
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Jan 9 2021, 9:03 PM.
Tokens
"Love" token, awarded by gritche."Love" token, awarded by wilBr."Love" token, awarded by dreamak."Orange Medal" token, awarded by kursadk."Love" token, awarded by fkytt."Love" token, awarded by kenziemac130."100" token, awarded by TheRedWaxPolice."Like" token, awarded by APEC."Love" token, awarded by JacquesLucke.

Details

Summary

This patch changes the check at the beginning of the "Make Instances Real"
operator to account for the instances created by nodes modifiers in the
modifier stack.

One thing this doesn't do is create collection instances for the
collection instance type in the "Point Instance* node. Instead it creates
instances of all of the objects in those collections. This is just a bit
unfortunate, but it's the way the "Make Instances Real" work right now.

Diff Detail

Repository
rB Blender

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Jan 9 2021, 9:03 PM
Hans Goudey (HooglyBoogly) created this revision.

Haven't tried it yet, but the code looks surprisingly simple indeed.

source/blender/editors/object/object_add.c
2162

typo

2170

Personally, I find !(object->transflag & OB_DUPLI) && !object_has_geometry_set_instances(object_eval) easier to read.

This seems like it might get a bit dangerous with hundreds of thousands of instances for just being a Ctrl+A away from an unwitting user. I think there should be a popup when applying a modifier with instances with how many objects will be created and allow the user to cancel, apply only geometry, or proceed.

Maybe there could be an option to automatically join the instances into a single mesh?

Apply typo fix and readability improvement from Jacques

For the most common case this seems to work well in my tests.

It does not work correctly when there is more than one Geometry Nodes modifier instancing objects. Currently, it always creates new objects for all instances, not only for the ones added by the applied modifier.

There is also the fact that if this is merged, instances are definitely not an implementation detail (they weren't really before either, because of the "Make Instances Real" operator). In my opinion, that is fine and instances don't have to be an implementation detail. We will have to talk about that topic again soon.

Note: Making object instancing not an implementation detail, does not imply that we can't have other kinds of instancing as implementation detail (e.g. an array modifier node could generate instances to be more efficient, but to the user the output would still look like a single mesh, not like multiple instances).

After some discussion it seems to make sense to turn this into an "off by default" option that you activate in the redo panel. It's possible to scatter many many objects, and like @astrand130 says, that's a bit dangerous.

It does not work correctly when there is more than one Geometry Nodes modifier instancing objects. Currently, it always creates new objects for all instances, not only for the ones added by the applied modifier.

Shoot, that's too bad, because the simplicity of this approach is that it just ties into the existing instancing system. I didn't actually know instancing from multiple nodes modifiers worked.

A couple possible solutions:

  1. That just becomes a drawback of this method. There are already some similar cases for the apply modifier operator, and I expect the situation is fairly rare anyway.
  2. Only fix the "Make Instances Real" operator and don't change the apply modifier operator at all.
  3. Run the selected nodes modifier again, then generate the list of instances just for that modifier and pass it to the "Make Instances Real" code. This would be a bit similar to the way the apply modifier operator already works anyway.

I actually like number 3, I might try that now.

Maybe there could be an option to automatically join the instances into a single mesh?

This is tied to some questions about how we treat instances in the node tree, so I'd like to avoid it for now. For example, if we had a "combine instances" node or a "make instances real" node, the answer to this question would be more obvious.

  • Only include fixes to "Make Instances Real" operator

So, I chose option 2 for now, for a couple reasons:

  1. As a bug fix it can be part of 2.92.
  2. We may want to refactor the way instances work in the nodes modifier at some point. I would prefer to implement better "Apply" behavior after we think about that more.
  3. To make applying on add instances for one of the nodes modifiers would probably require a larger change.
Hans Goudey (HooglyBoogly) retitled this revision from Geometry Nodes: Make instances real when applying the modifier to Geometry Nodes: Fix "Make Instances Real" operator to work with modifier instances.Jan 15 2021, 2:18 AM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Jan 15 2021, 12:07 PM