Page MenuHome

Objects with GN modifier become very slow to animate
Closed, DuplicatePublic

Description

System Information
Operating system: Linux-5.11.0-40-generic-x86_64-with-glibc2.31 64 Bits
Graphics card: NVIDIA GeForce RTX 2070 Super/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.82.01

Blender Version
Broken: version: 3.1.0 Alpha, branch: master, commit date: 2021-11-09 12:31, hash: rB41b0820dddf9
Worked: (newest version of Blender that worked as expected)

Short description of error
I noticed that adding a GN modifier (even an empty one that literally does nothing) makes moving or animating an object or the Armature that this object is parented to a lot slower.
Muting the GN modifier doesn't help. Only deleting it completely.

Exact steps for others to reproduce the error

  • Open the attached super simple blend file. It contains two cubes (subdivided quite heavily to better show the effect) parented to a simple Armature each. The only difference is that the left cube also has a GN modifier on it.

  • Grab the right bone and move it. Everything is lightning fast.
  • Grab the left bone and the whole interaction is a lot slower.
  • Mute the GN modifier -> No improvement
  • Delete the GN modifier -> everything is fine

This effect becomes a bigger problem if you e.g. have several objects with a GN modifier parented to the same armature because it adds up. I tried to use a super simple GN modifier to animate a switch between several material slots and now I'm kind of giving up and will have to do it "oldskool" either by building a more complex shader tree or by animating the visibility of objects with different materials on it. I'm sad.

Event Timeline

Thanks for the report. This is actually caused by the fact that currently geometry nodes adds a dependency to the transforms of the object itself. So when the object moves, the modifier stack is reevaluated. We should make the system a bit smarter in the future by checking if the node tree actually depends on the object transforms (this happens when e.g. the Object or Collection Info is used in Relative mode).

This change would solve the performance issue in your particular file (but would break many other files). I'm just providing it here for reference:

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 6ea47881982..ada6ab0e2ee 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -231,7 +231,6 @@ static void add_object_relation(const ModifierUpdateDepsgraphContext *ctx, Objec
 static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
 {
   NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
-  DEG_add_modifier_to_transform_relation(ctx->node, "Nodes Modifier");
   if (nmd->node_group != nullptr) {
     DEG_add_node_tree_relation(ctx->node, nmd->node_group, "Nodes Modifier");

Thanks for the explanation.
Would it be somehow possible (without breaking too many things) to treat objects with completely muted / disabled GN modifiers like objects without any GN modifiers at all? This would already make a simple workaround in my current project a lot easier than it currently is. I could just disable the GN modifiers during the animation phase and switch them back on whenever I render the scene,