Geometry Nodes: add simulation support #104924

Closed
Hans Goudey wants to merge 211 commits from geometry-nodes-simulation into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This adds support for building simulations with geometry nodes. A new Simulation Input and Simulation Output node allow maintaining a simulation state across multiple frames. Together these two nodes form a simulation zone which contains all the nodes that update the simulation state from one frame to the next.

A new simulation zone can be added via the menu (Simulation > Simulation Zone) or with the node add search.

The simulation state contains a geometry by default. However, it is possible to add multiple geometry sockets as well as other socket types. Currently, field inputs are evaluated and stored for the preceding geometry socket in the order that the sockets are shown. Simulation state items can be added by linking one of the empty sockets to something else. In the sidebar, there is a new panel that allows adding, removing and reordering these sockets.

The simulation nodes behave as follows:

  • On the first frame, the inputs of the Simulation Input node are evaluated to initialize the simulation state. In later frames these sockets are not evaluated anymore. The Delta Time at the first frame is zero, but the simulation zone is still evaluated.
  • On every next frame, the Simulation Input node outputs the simulation state of the previous frame. Nodes in the simulation zone can edit that data in arbitrary ways, also taking into account the Delta Time. The new simulation state has to be passed to the Simulation Output node where it is cached and forwarded.
  • On a frame that is already cached or baked, the nodes in the simulation zone are not evaluated, because the Simulation Output node can return the previously cached data directly.

It is not allowed to connect sockets from inside the simulation zone to the outside without going through the Simulation Output node. This is a necessary restriction to make caching and sub-frame interpolation work. Links can go into the simulation zone without problems though.

Anonymous attributes are not propagated by the simulation nodes unless they are explicitly stored in the simulation state. This is unfortunate, but currently there is no practical and reliable alternative. The core problem is detecting which anonymous attributes will be required for the simulation and afterwards. While we can detect this for the current evaluation, we can't look into the future in time to see what data will be necessary. We intend to make it easier to explicitly pass data through a simulation in the future, even if the simulation is in a nested node group.

There is a new Simulation Nodes panel in the physics tab in the properties editor. It allows baking all simulation zones on the selected objects. The baking options are intentially kept at a minimum for this MVP. More features for simulation baking as well as baking in general can be expected to be added separately.

All baked data is stored on disk in a folder next to the .blend file. #106937 describes how baking is implemented in more detail. Volumes can not be baked yet and materials are lost during baking for now. Packing the baked data into the .blend file is not yet supported.

The timeline indicates which frames are currently cached, baked or cached but invalidated by user-changes.

Simulation input and output nodes are internally linked together by their bNode.identifier which stays the same even if the node name changes. They are generally added and removed together. However, there are still cases where "dangling" simulation nodes can be created currently. Those generally don't cause harm, but would be nice to avoid this in more cases in the future.

image
image

This adds support for building simulations with geometry nodes. A new `Simulation Input` and `Simulation Output` node allow maintaining a simulation state across multiple frames. Together these two nodes form a `simulation zone` which contains all the nodes that update the simulation state from one frame to the next. A new simulation zone can be added via the menu (`Simulation > Simulation Zone`) or with the node add search. The simulation state contains a geometry by default. However, it is possible to add multiple geometry sockets as well as other socket types. Currently, field inputs are evaluated and stored for the preceding geometry socket in the order that the sockets are shown. Simulation state items can be added by linking one of the empty sockets to something else. In the sidebar, there is a new panel that allows adding, removing and reordering these sockets. The simulation nodes behave as follows: * On the first frame, the inputs of the `Simulation Input` node are evaluated to initialize the simulation state. In later frames these sockets are not evaluated anymore. The `Delta Time` at the first frame is zero, but the simulation zone is still evaluated. * On every next frame, the `Simulation Input` node outputs the simulation state of the previous frame. Nodes in the simulation zone can edit that data in arbitrary ways, also taking into account the `Delta Time`. The new simulation state has to be passed to the `Simulation Output` node where it is cached and forwarded. * On a frame that is already cached or baked, the nodes in the simulation zone are not evaluated, because the `Simulation Output` node can return the previously cached data directly. It is not allowed to connect sockets from inside the simulation zone to the outside without going through the `Simulation Output` node. This is a necessary restriction to make caching and sub-frame interpolation work. Links can go into the simulation zone without problems though. Anonymous attributes are not propagated by the simulation nodes unless they are explicitly stored in the simulation state. This is unfortunate, but currently there is no practical and reliable alternative. The core problem is detecting which anonymous attributes will be required for the simulation and afterwards. While we can detect this for the current evaluation, we can't look into the future in time to see what data will be necessary. We intend to make it easier to explicitly pass data through a simulation in the future, even if the simulation is in a nested node group. There is a new `Simulation Nodes` panel in the physics tab in the properties editor. It allows baking all simulation zones on the selected objects. The baking options are intentially kept at a minimum for this MVP. More features for simulation baking as well as baking in general can be expected to be added separately. All baked data is stored on disk in a folder next to the .blend file. #106937 describes how baking is implemented in more detail. Volumes can not be baked yet and materials are lost during baking for now. Packing the baked data into the .blend file is not yet supported. The timeline indicates which frames are currently cached, baked or cached but invalidated by user-changes. Simulation input and output nodes are internally linked together by their `bNode.identifier` which stays the same even if the node name changes. They are generally added and removed together. However, there are still cases where "dangling" simulation nodes can be created currently. Those generally don't cause harm, but would be nice to avoid this in more cases in the future. ![image](/attachments/161f107e-f607-4fe0-b26f-9faccef6c780) ![image](/attachments/6cb774ac-b3b9-4dae-8d53-27ac2cb12fe6)
754 KiB
331 KiB
Hans Goudey added the
Interest
Geometry Nodes
Module
Nodes & Physics
labels 2023-02-18 17:20:36 +01:00
Hans Goudey added 89 commits 2023-02-18 17:20:49 +01:00
4726803e85 Fixed typo in Simulation Input node
"Delta Time" was set instead of "Elapsed Time" output.
97df619be7 Move "Run" input to simulation output node
It's the output node that decides whether to requiest the values
from the nodes inside the simulation, so it makes more sense
for it to be there. This is part of a general effort to have less
redundancy in the options.
18b2ec1963 Rename "Use Cache" to "Persistent Cache"
This is a temporary option anyway, the caches will be controlled in a
more unified place at the object or scene level. But for now the name
can be a bit better anyway.
7469e19446 Add basic UI support for multiple simulations in a group
Just allows multiple simulation "frames"/regions/contexts to be drawn
in the editor, doesn't include any changes to caching yet.
92a1234830 Add hint to add simulation output node first
Until we can add both nodes at the same time, or we find
an improve simulation to link the two nodes
850aa3d26a Allow multiple caches in the same node group
The caches now hash the identifier of the output node as well.
bb732c240d Half finished refactoring to simulation cache
- Cache is accessed with a string identifier, allowing multiple sockets in the future
- Cache is meant to be stored in a simple array, not sparsely like before
- Persistent cache and temporary "last run" cache are separated more clearly
- Use a "Time Point" class instead of integers, to maybe clarify adding subframe support in the future
- Use a different "sim" namespace (not sure if that will last)
- The value from the last frame is moved, to avoid a copy when no persistent cache is used

I don't think this works now, at least I haven't tested it.
c9958c8e9f Basics of temporary and persistent cache working again
Edge cases not really tested still though
3dcb437d5c Remove elapsed time sockets
Since this is theoretically redundant with simulating a float
with the delta time value, we decided to remove it for now to
make the whole interface simpler.
94e6f87ebc Remove "Persistent Cache" option from the UI
I will keep it internally, but for the simulation MVP we want to focus
on the most basic "last frame's cache" features at first.
49e8218edf Remove Started and Ended booleans
These aren't theoretically necessary, since you can just created them
as regular outputs. Maybe we will eventually add them back for
convenience, but that's not clear.
3fcf50d37a Make the simulation always run, remove run socket
Note: Still unstable. Simulation resets when playback stops bug.

Since the "Run" behavior can basically be implemented with the switch
node already, it's just adding unnecessary complexity to the interface
now, when it's use case isn't clear. We decided to remove it for now,
and only consider it later as a possible convenience feature, rather
than an essential part of the design.

Also, the simulation nodes are now considered "side effect nodes"
for the evaluator, meaning they are *always* evaluated, even if they
aren't needed because of switch nodes, etc. This was the best way
we thought of to make simulations run consistently even through
situations like that.
620b190e52 Fix delta time output
Output time in seconds rather than frame units
1965e31d17 Fix T101130: Scaling of NLA Strip Via S Hotkey Not Working
After switching over to using start_frame / end_frame, scaling an NLA strip didn't scale the strip, it just repeated the action.

Now withing the NLA transform code, we look for TFM_TIME_EXTEND / TFM_TIME_SCALE transform mode, and handle the update to strip scale accordingly
c30718ded9 cmake/win: Allow running blender_test from the VS debugger
This was missing some paths setup in the environment, ctest
normally sets this up before running the tests from the CLI
but that does not help the IDE all that much.
496e344015 Cleanup: Move mesh modifier apply function to editors module
The function was highly related to the apply modifier operator,
and only used once. This was too specific to be in the blenkernel,
especially in a mesh conversion file.
e50d567c97 Cleanup: Various improvements to modifier apply operator
Use C++ casts, decrease variable scope, use references, use const.
6b26b0db21 Fix build issue with NanoVDB and HIP on Linux
This patch was already accepted upstream, so this is temporary until we update
to a new OpenVDB release that includes it.
f9b621a9d9 Nodes: Allow skipping node attachment after dragging
This patch allows skipping the automatic insertion of nodes on top of
links when the transform operator ends. When putting nodes into small
spaces this often gets in the way and wastes time. Now, when holding
`alt`, this is turned off.

The header text is also improved to add this shortcut and to remove
the Dx and Dy values and improve the formatting a bit.

Making this functionality optional might allow us to use it in more
places in the future, like for the nodes added by link-drag-search.

Differential Revision: https://developer.blender.org/D16230
20cab8f8f2 Geometry Nodes: Add error message when applying modifier with no mesh
If the resulting geometry from applying a geometry nodes modifier
contains no mesh, give an error message. This gives people something to
search and makes the behavior more purposeful.

Also remove the `modifyMesh` implementation from the geometry nodes
modifier, since it isn't necessary anymore. And remove the existing
"Modifier returned error, skipping apply" message which was cryptic
and redundant if applying returns an actual error message.

Resolves T103229

Differential Revision: https://developer.blender.org/D16782
24523726d7 Mesh: Store active & default color attributes with strings
Attributes are unifying around a name-based API, and we would like to
be able to move away from CustomData in the future. This patch moves
the identification of active and fallback (render) color attributes
to strings on the mesh from flags on CustomDataLayer. This also
removes some ugliness used to retrieve these attributes and maintain
the active status.

The design is described more here: T98366

The patch keeps forward compatibility working until 4.0 with
the same method as the mesh struct of array refactors (T95965).

The strings are allowed to not correspond to an attribute, to allow
setting the active/default attribute independently of actually filling
its data. When applying a modifier, if the strings don't match an
attribute, they will be removed.

The realize instances / join node and join operator take the names from
the first / active input mesh. While other heuristics may be helpful
(and could be a future improvement), just using the first is simple
and predictable.

Differential Revision: https://developer.blender.org/D15169
ac59dfeffd Fix T103049: Cycles specular light leak regression
The logic here is not ideal but was unintentionally changed in refactoring
for path guiding, now restore it back to 3.3 behavior again.
a3a132ea74 Build: upgrade pre-built libraries for Linux
Replace ../lib/linux_centos7_x86_64 with ../lib/linux_x86_64_glibc_228,
built with Rocky8 Linux, compatible with the VFX platform CY2023,
see: T99618.

- Update build-bot configuration.
- Remove unnecessary check for Blosc, this is part of OpenVDB lib now.
- Remove WITH_CXX11_ABI, always use new C++11 ABI now
- Replace centos7 by glibc_228 everywhere

Note that existing builds with cached paths pointing to
"../lib/linux_centos7_x86_64" will need to be updated.

Includes contributions by Brecht.
34f307547b Fix T103183: UV map name of mesh converted from curve is untranslated
Upon conversion, the newly-created UV map with default name "UVMap"
should be translated.

Reviewed By: mont29

Maniphest Tasks: T103183

Differential Revision: https://developer.blender.org/D16775
af7c34716b Fix active/default color names not being editable
Revert [0] and enable the editable flag as the intent for [1] was that
these values would be editable.

[0]: e58f5422c3
[1]: 6514bb05ea
0403d77a0f Fix T103237: Prevent UV Unwrap from packing hidden UV islands
When migrating to the new packing API, pin_unselected was not
implemented correctly.

Regression from rB143e74c0b8eb, rBe3075f3cf7ce, rB0ce18561bc82.

Differential Revision: https://developer.blender.org/D16788

Reviewed By: Campbell Barton

Duplicated in blender-v3.4-release as rB3dcd9992676a
a12614d166 Fix T102923: replace zero check with epsilons with uv constrain to bounds
Small roundoff errors during UV editing can sometimes occur, most likely
due to so-called "catastrophic cancellation".

Here we set a tolerance around zero when using Constrain-To-Bounds and UV Scaling.

The tolerance is set at one quarter of a texel, on a 65536 x 65536 texture.

TODO: If this fix holds, we should formalize the tolerance into the UV editing
subsystem, perhaps as a helper function, and investigate where else it needs
to be applied.

Differential Revision: https://developer.blender.org/D16702
c9bd78890a Build: remove opus workaround for sndfile
For some reason SNDFILE now builds without this workaround,
which broke building FFMPEG.
bb8cbf0c10 UI: don't change mouse cursor while it's grabbed
The paint cursor was continuously set which meant hiding the cursor
while interacting with buttons would immediately show it again.

This exposed cursor warping.
5d1ed47d6c Fix T103253: Infinite drag of number buttons is broken on WIN32
Recent reverting of changes to cursor grabbing intended to match
Blender 3.3 release. This is the case for 3.4x branch, however there is
an additional change to grabbing on WIN32 by Germano [0] which is a
significant improvement on old grabbing logic for Windows.
So instead of matching 3.3x behavior, restore logic that keeps
the cursor centered while grabbing & hidden.

This re-introduces T102792 issue displaying the paint-brush while
dragging buttons, this will have to be solved separately.

Re-apply [1] & [2], revert [3] & [4].

[4]: a3a9459050
[0]: 9fd6dae793
[1]: 4cac8025f0
[2]: 230744d6fd
[3]: 0240b89599
54942e5ea6 Fix T102792: Sculpt cursor jumps to random place
Restrict the condition under which paint cursors read use the cursor
location from the the operating-system.

This caused a glitch when dragging UI elements in painting context
popup. Since the paint cursor would display using mouse motion
which was clamped to the window center - an internal detail of hidden
cursor grabbing.

Now only read the cursor coordinates when clamped to a region which
is used for the transform cursor to stay visible even when the cursor
wraps around.
32a7384c0b Geometry Nodes: improve dot graph export of lazy function graph
* Dim default input values.
* Print default input values instead of type name.
* Add node/socket names to group input/output nodes.
74171ff3b0 CMake: warn Linux references old linux_centos7_x86_64 paths
When the centos7 library dir is found, warn when the values of cached
variables reference it, listing the variables and their values.
06525747c0 Build: resolve failure to copy indirect dependencies for USD on Linux
Even when building without OpenImageIO and OpenVDB, USD depends on these
libraries.

Ensure these libraries are copied when building with USD.
cfb77c54b0 Fix T103257: Enabling or disabling viewport denoising while using OptiX OSL results in an error
Switching viewport denoising causes kernels to be reloaded with a new
feature mask, which would destroy the existing OptiX pipelines. But OSL
kernels were not reloaded as well, leaving the shading pipeline
uninitialized and therefore causing an error when it is later attempted to
execute it. This fixes that by ensuring OSL kernels are always reloaded
when the normal kernels are too.
6bd6d7aec7 Fix T103258: Deleting a shader with OptiX OSL results in an illegal address error
Materials without connections to the output node would crash with OSL
in OptiX, since the Cycles `OSLCompiler` generates an empty shader
group reference for them, which resulted in the OptiX device
implementation setting an empty SBT entry for the corresponding direct
callables, which then crashed when calling those direct callables was
attempted in `osl_eval_nodes`. This fixes that by setting the SBT entries
for empty shader groups to a dummy direct callable that does nothing.
f92a85d7d2 Nodes: Add Exclusion color mix mode
Expands Color Mix nodes with new Exclusion mode.

Similar to Difference but produces less contrast.

Requested by Pierre Schiller @3D_director and
@OmarSquircleArt on twitter.

Differential Revision: https://developer.blender.org/D16543
807be888a5 Fix: Crash after mesh color attribute name commit
6514bb05ea missed a null check when accessing the active
and default color attribute names, since the CustomData API does not
do that check itself.
8226abc111 Cleanup: Remove duplicate UV islands header
This code was duplicated from `pbvh_uv_islands.hh`,
which was the version that was actually used.
a0ed3601c9 Fix T103187: Opening node search menu is slow because of assets.
Avoid utility function call that would query the file system, this was a
bottleneck. The path joining was also problematic. See patch for more
details.

Differential Revision: https://developer.blender.org/D16768

Reviewed by: Jacques Lucke
988241e23e Geometry Nodes: simplify handling of invalid group interface sockets
Previously, the code tried to keep node groups working even if some of
their input/output sockets had undefined type. This caused some
complexity with no benefit because not all places outside of this file
would handle the case correctly. Now node groups with undefined
interface sockets are disabled and have to be fixed manually before
they work again.

Undefined interface sockets are mostly caused by invalid Python
API usage and incomplete forward compatibility (e.g. when newer
versions introduce new socket types that the older version does
not know).
aeea690e00 Cleanup: Remove unnecessary node link flag
Links that are currently being dragged are now stored outside
of the node tree, so we don't need a flag to distinguish them
from "proper" links.
38567bc023 Cleanup: Slightly refactor cancelling link drag operator
Clarify that the dragged links aren't stored in the tree, use a
separate function for cancelling vs. applying the links to the tree.
508fd044b4 Revert "Fix simulation"
This reverts commit 468f43c7a6.

Revert "Add initial dynamic declarations"

This reverts commit 50a2c77c4e.

Revert "Add initial simulation state items array to output node"

This reverts commit 3f1027567d.
buildbot/vexp-code-experimental-coordinator Build done. Details
6f56fee3bb
Fixes after merge
Hans Goudey added this to the Nodes & Physics project 2023-02-18 17:21:20 +01:00
Hans Goudey added 1 commit 2023-02-28 17:49:16 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
9241ab1d7c
Merge branch 'main' into geometry-nodes-simulation
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR104924) when ready.
Hans Goudey added 2 commits 2023-03-10 20:15:18 +01:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR104924) when ready.
Hans Goudey added 1 commit 2023-03-10 22:17:41 +01:00
f36dd06609 Add initial infrastructure for multiple simulation state items
- Use dynamic declarations to build simulation node sockets
- Fixes in some node code for futher use of dynamic declarations
- Copying, freeing, reading, and writing of simulation state array
- Add simulation state items with link drag operator

The new sockets won't do anything yet, only geometry sockets are
supported, and there is no way to remove sockets yet.
Hans Goudey added 1 commit 2023-03-13 20:31:07 +01:00
Hans Goudey added 1 commit 2023-03-13 22:29:24 +01:00
3bad7a51cb Implement simulation nodes as lazy functions directly
Support for multiple sockets will be slightly more complete now too,
but that part hasn't been tested.
Jacques Lucke added 1 commit 2023-03-16 12:51:41 +01:00
Jacques Lucke added 2 commits 2023-03-20 16:25:32 +01:00
Jacques Lucke added 2 commits 2023-03-20 17:00:11 +01:00
Jacques Lucke added 1 commit 2023-03-21 12:25:34 +01:00
Jacques Lucke added 1 commit 2023-03-21 12:39:07 +01:00
Jacques Lucke added 1 commit 2023-03-21 16:03:50 +01:00
Jacques Lucke added 1 commit 2023-03-21 17:56:56 +01:00
Jacques Lucke added 1 commit 2023-03-22 11:35:32 +01:00
Jacques Lucke added 1 commit 2023-03-28 11:52:53 +02:00
Jacques Lucke added 2 commits 2023-03-28 13:38:18 +02:00
b14668ae03 Simulation Nodes: refactor automatic caching
The most important part of this change is that the simulation
state at a specific point in time is more self contained now.
This way, only the modifier has to deal with finding the old/new
simulation states and not every simulation individually.

Furthermore, this also includes some simple cache invalidation
when the user changes something that might affect the result.
First-time contributor

Hello, is there any way to get an updated patch or branch MacOS Intel compiled build to download?

https://builder.blender.org/download/patch/PR104924/ ?

Thanks!

Hello, is there any way to get an updated patch or branch MacOS Intel compiled build to download? https://builder.blender.org/download/patch/PR104924/ ? Thanks!
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR104924) when ready.
First-time contributor

@blender-bot package

Great thank you @HooglyBoogly !

> @blender-bot package Great thank you @HooglyBoogly !
Lukas Tönne added 1 commit 2023-04-05 14:29:21 +02:00
3d8d142205 Check if output node exists before creating a sim input lazy function.
Avoid creating a lazy function for the `Simulation Input` node if the `output_node_id` is invalid. This can happen when e.g. the output node is deleted without also deleting the input node. The lazy function assumes a valid output ID and will crash if the output node does not exist.

Pull Request: #106585
Lukas Tönne added 1 commit 2023-04-05 16:21:05 +02:00
98bc439e47 Add simulation input and output node as a pair
Simulation input and output nodes are currently added individually, but they always need to exist as pair. This PR modifies the _Add Node_ menu so that a single menu entry adds and input and output node together.

The `NODE_OT_add_node` operator currently adds just a single node type. A new variant of this operator is added which adds a _simulation zone_ with origin + target node instead. This requires some modification of the `NodeAddOperator` base class, moving the `node_type` property into the final implementation. Unlike the `NODE_OT_add_node` operator, the `NODE_OT_add_simulation_zone` adds 2 different node types.

After adding the two nodes, a reference needs to be added to "pair" them: Input node ("origin") stores the UID of the output node ("target") in its `output_node_id` property. So far this was detected automatically when adding an input, but this method is not very robust (e.g. it depends on order of adding nodes and adding multiple pairs can be tricky).

Now the pairing is done explicitly through an API function `node_geo_simulation_input_pair_with_output`. The `NODE_OT_add_simulation_zone` operator performs pairing of the input/output nodes after adding them. The function is accessible through RNA, so an operator may be added if necessary to allow users to fix unpaired nodes.

In addition to pairing the two nodes, the operator also positions them at a comfortable distance, as well as adding a default link between the two Geometry sockets for convenience.

Resolves #105727

Pull Request: #106557
Lukas Tönne added 1 commit 2023-04-05 18:28:57 +02:00
buildbot/vexp-code-experimental-coordinator Build done. Details
c6d8da0e97
Remove simulation inputs when deleting outputs and vice versa
To avoid unpaired simulation inputs or outputs, whenever deleting such
nodes the respective paired node should be deleted as well. A simple
utility function selects paired nodes before the delete operator removes
them.

This does not affect API methods, which still remove only individual
nodes. The feature is primarily a workflow improvement.

Resolves #105728

Pull Request: #106597
Jacques Lucke added 1 commit 2023-04-07 16:53:58 +02:00
Jacques Lucke added 1 commit 2023-04-11 09:19:44 +02:00
Jacques Lucke added 1 commit 2023-04-13 16:45:24 +02:00
Hans Goudey added 5 commits 2023-04-14 04:12:56 +02:00
Hans Goudey added 6 commits 2023-04-14 04:21:41 +02:00
Jacques Lucke added 1 commit 2023-04-17 06:38:29 +02:00
Lukas Tönne added 1 commit 2023-04-17 16:11:19 +02:00
315cc66bd8 Fix #106732: Support for simulation zones in copy operators
Copying a simulation zone should keep the 1:1 pairing intact (see `remap_pairing` functions)
- When copying a simulation input node on its own, unpair it to avoid ambiguity. Only the old simulation input node is paired to the output.
- When copying a simulation output node on its own, no special action is needed - the node gets a new ID and nothing is paired with it.
- When copying both input and output, remap the `output_node_id` property of the simulation input node, so that it is paired with the output copy.

There are a couple of places where copies happen:
* Node tree copy
* Duplicate nodes
* Group Separate (copies nodes from the group tree into another tree)
* Clipboard (both copy to clipboard and paste into node tree)
* Shader node tree branch copy for execution

These copy operators do mostly the same thing, but in slightly different ways, which makes the code incompatible (e.g. using a `Map<const bNode *, bNode *> node_map` vs. `Map<bNode *, bNode *> node_map`). That's why there are 3 `remap_pairing` implementations.

Dynamic node declarations are problematic:
Copying nodes invokes `nodeDeclarationEnsure` to generate declarations for new nodes. It does not, however, change the socket lists. If a dynamic declaration for a node copy alters the sockets (in this case: remove all because the node is unpaired), the subsequent `update_socket_declarations` will crash because it expects sockets to match the declaration.
At the end of operators there is usually a `BKE_ntree_update_main` or similar, which invokes `update_node_declaration_and_sockets`. This method _does_ update the socket lists as well (see #106732), but only if a node is tagged for a respective update.

The solution here is to use `update_node_declaration_and_sockets` for dynamic declarations instead of just `build_node_declaration_dynamic`.

Pull Request: #106812
Jacques Lucke added 1 commit 2023-04-18 11:24:46 +02:00
Dalai Felinto added 1 commit 2023-04-18 12:11:16 +02:00
8981bb4ac6 Geometry Nodes: Simulation Zone drawing updates
* Make the drawing smoother/anti-aliased.
* We use the alpha to blend between the background and the zone color.
* If alpha is 100% we then get to see the dotted background again
* Change zone corner radius to match nodes/layout.

If we want to set the background transparent again we need to do:
```
-    immUniformThemeColorBlend(TH_BACK, TH_NODE_ZONE_SIMULATION, zone_color[3]);
+    immUniformThemeColor(TH_NODE_ZONE_SIMULATION);
```

For the design behind some of those change see #106810
Pull Request: #107043
Dalai Felinto added 1 commit 2023-04-18 12:13:05 +02:00
Hans Goudey added 1 commit 2023-04-18 13:24:32 +02:00
e41cd795a6 Small cleanups to zone drawing
- Avoid unnecessary topology tag
- Copy from offsets in one line
- Comment formatting
- Avoid describing future changes in comment, let the code stand on its own
Jacques Lucke added 1 commit 2023-04-18 14:28:24 +02:00
buildbot/vexp-code-experimental-coordinator Build done. Details
6f26bb6841
add missing immUnbindProgram()
Hans Goudey added 1 commit 2023-04-18 22:56:46 +02:00
Jacques Lucke added 1 commit 2023-04-19 08:57:55 +02:00
Jacques Lucke added 1 commit 2023-04-19 11:25:46 +02:00
Hans Goudey added 1 commit 2023-04-20 04:53:01 +02:00
Hans Goudey added 1 commit 2023-04-20 05:26:07 +02:00
Jacques Lucke added 1 commit 2023-04-20 14:31:42 +02:00
4d34028ce9 use BitArrayVector instead of MultiValueMap for attribute propagation detection
This simplifies the code and also makes it more efficient in many cases
(although not by much in my simple tests).
Jacques Lucke added 1 commit 2023-04-21 09:27:18 +02:00
Hans Goudey added 1 commit 2023-04-21 21:26:58 +02:00
Jacques Lucke added 1 commit 2023-04-22 13:15:46 +02:00
Jacques Lucke added 1 commit 2023-04-22 14:49:06 +02:00
05ddbc20b8 Simulation Nodes: bake simulation states to disk
This adds baking support to simulation nodes.

The following features are supported:
* Bake simulation nodes of selected objects from the new "Baking" panel in the
  object properties.
* Free baked/cached simulation data.
* The bake is stored on disk in a folder next to the .blend file (so it's necessary
  to save before baking works).
* Baked data is detected automatically when reloading the file.
* The data stored on disk is partially deduplicated. Only duplicates that can be
  detected using implicit-sharing are taken into account.
* The baked data can contain meshes, curves, pointclouds and instances.
* The simulation state is written using a combination raw binary files for the
  data arrays and `.json` for meta data. Other formats besides `.json` could be
  used (most code is agnostic to that), but json is the easiest to use right now and
  seems to be good enough the common use cases (note that the size of the `.json`
  files do not depend on how large e.g. the baked mesh is).
* During baking, there is a progress bar and it can be interrupted using escape.

Limitations:
* Volumes are not written to disk yet.
* Currently it always bakes the entire scene frame range.
* Baking subframes is supported internally, but is not exposed in the UI.
* Currently, all attributes are written, but that is likely not necessary in most
  cases (e.g. selection attributes are written as well).

Pull Request: #106937
Jacques Lucke added 1 commit 2023-04-22 16:19:19 +02:00
Jacques Lucke added 1 commit 2023-04-24 12:45:17 +02:00
Jacques Lucke added 1 commit 2023-04-24 12:53:58 +02:00
Lukas Tönne added 1 commit 2023-04-24 14:26:34 +02:00
8446b2cad1 Simulation nodes: UI for simulation state items in sidebar
Selecting the input or output simulation node now shows a new panel in the node sidebar with a list of simulation state items. Items can be added, removed, or moved up and down the list. This updates the sockets on both simulation input and output nodes. This is similar to node group interfaces, except that simulation state items only have one list which generates both input and output sockets.

Resolves #105723

Pull Request: #106919
Lukas Tönne added 1 commit 2023-04-24 16:14:52 +02:00
abac119889 Fix crash on inserting links on simulation zone nodes.
When adding links to the sim zone nodes they modify the tosock/fromsock
with the socket generated for the new item. This search expects a socket
identifier rather than a name string. The identifier is now unique, so
that sockets can be reliably relinked, but the old code was using the
name instead.

Pull Request: #107303
Lukas Tönne added 1 commit 2023-04-24 18:22:28 +02:00
c13005fed9 Add support for attributes storage in simulation state
Support basic geometry node socket types in the simulation zone nodes.

This allows adding items to the simulation state for float, int, bool,
vector and color sockets. ID types like Material and Object are not
supported (yet).

Item state does not include storage yet, this will be implemented
separately. Item state consists of dummy GeometryStateItem structs.

Field types of the simulation input and output node sockets need to be
synchronized because they represent the same pieces of data. This can
create a cyclic dependency which complicates the
`update_field_inferencing` function. The simple topological sorting for
propagating output field constraints (right-to-left) and input field
state (left-to-right) is not sufficient any more, because now updating
a simulation input node also modifies the paired output node, and vice
versa. To solve this issue, the two propagation functions now can
perform several passes, if changing a simulation node modifies their
counterpart. Infinite updates are prevented by checking for actual
changes: each update can only simplify the field state, until no more
changes occur. A single simulation zone can cause at most 1 additional
update, more than that may happen when simulation zones are nested.

Resolves #106218

Pull Request: #107133
Jacques Lucke added 1 commit 2023-04-25 09:45:45 +02:00
Jacques Lucke added 1 commit 2023-04-25 12:16:24 +02:00
Jacques Lucke added 1 commit 2023-04-25 13:45:02 +02:00
d010aa5e23 Simulation Nodes: support primitive values in simulation state
The simulation state can contain individual floats, vectors, ints,
booleans, colors and strings now. Note, fields/anonymous attributes
are not yet supported.

This commit also contains baking support.

Furthermore, the code now makes better use of the identifiers
stored in #NodeSimulationItem.
Jacques Lucke added 1 commit 2023-04-26 10:22:53 +02:00
Jacques Lucke added 1 commit 2023-04-26 10:43:37 +02:00
Jacques Lucke added 1 commit 2023-04-26 10:56:52 +02:00
Jacques Lucke added 1 commit 2023-04-26 12:51:30 +02:00
614eb01911 Simulation Nodes: add socket usages
There is a new `LazyFunctionForSimulationInputsUsage` the outputs
booleans that indicate whether the inputs for the Simulation Input/Output
node is used.

Also, use the existing mapping from `bNodeSocket` to lazy function socket
indices.
Hans Goudey added 2 commits 2023-04-26 17:34:03 +02:00
Hans Goudey added 2 commits 2023-04-26 17:49:58 +02:00
Hans Goudey added 1 commit 2023-04-26 18:43:16 +02:00
Jacques Lucke added 1 commit 2023-04-26 19:16:11 +02:00
Jacques Lucke added 1 commit 2023-04-26 19:59:17 +02:00
cf682c9b8f Simulation Nodes: support storing "anonymous" attributes in sim state
Non-geometry sockets now work properly in simulation input/output
nodes. When a field is passed into them, it is evaluated one the
preceding geometry (this aspect might need further refinement)
and is stored as attribute. The evaluation domain can be changed
in the side bar similar to modifiers.

The attributes stored in the simulation state are not actually anonymous
but normal named attributes. This makes it much more obvious how
to the disk storage works. When the simulation state is output in
geometry nodes, the attributes become anonymous attributes again.

Anonymous attributes are not stored in the simulation state anymore,
because this can lead to unreliable and hard-to-predict results when
the set of required anonymous attributes changes over time.
Jacques Lucke added 1 commit 2023-04-26 20:20:53 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
c87b6fdba9
Simulation Nodes: improve simulation inputs usage
This can improve performance by skipping computation of
some anonymous attributes that would only be used by the
simulation.
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR104924) when ready.
Hans Goudey added 1 commit 2023-04-27 15:49:32 +02:00
Hans Goudey added 1 commit 2023-04-27 18:47:25 +02:00
Jacques Lucke added 1 commit 2023-04-28 10:27:01 +02:00
Jacques Lucke added 1 commit 2023-04-28 12:37:24 +02:00
buildbot/vexp-code-experimental-coordinator Build done. Details
5ee94fb263
Fix: anonymous attribute relations incorrect for simulation nodes
Jacques Lucke added 2 commits 2023-04-28 13:01:05 +02:00
Jacques Lucke added 1 commit 2023-04-28 13:02:06 +02:00
Jacques Lucke added 1 commit 2023-04-28 13:15:25 +02:00
Jacques Lucke added 1 commit 2023-04-28 13:20:21 +02:00
Jacques Lucke added 1 commit 2023-04-28 13:32:19 +02:00
Jacques Lucke added 1 commit 2023-04-28 13:38:09 +02:00
Jacques Lucke added 1 commit 2023-04-28 14:04:10 +02:00
Hans Goudey added 1 commit 2023-04-28 16:11:57 +02:00
Jacques Lucke added 1 commit 2023-04-28 16:22:01 +02:00
Jacques Lucke added 1 commit 2023-04-28 16:22:42 +02:00
Hans Goudey added 1 commit 2023-04-28 16:25:11 +02:00
Jacques Lucke added 2 commits 2023-04-28 17:01:17 +02:00
Hans Goudey added 3 commits 2023-05-01 20:34:01 +02:00
Hans Goudey added 3 commits 2023-05-01 21:09:34 +02:00
Hans Goudey added 3 commits 2023-05-01 21:36:20 +02:00
f9cd9b26a7 Cleanup: Use const pointers in simulation input node
This node isn't mean to write to the simulation state, just retrieve
from it. So it's best to make that clearer by making the context
and modifier data pointers const
Hans Goudey added 4 commits 2023-05-01 21:51:57 +02:00
Hans Goudey added 2 commits 2023-05-01 21:54:06 +02:00
Hans Goudey added 2 commits 2023-05-01 22:08:34 +02:00
Jacques Lucke added 1 commit 2023-05-02 11:13:39 +02:00
Jacques Lucke added 1 commit 2023-05-02 14:07:37 +02:00
Jacques Lucke added 1 commit 2023-05-02 14:56:04 +02:00
Jacques Lucke added 1 commit 2023-05-02 15:50:18 +02:00
Hans Goudey added 1 commit 2023-05-02 15:54:47 +02:00
Hans Goudey added 2 commits 2023-05-02 16:00:21 +02:00
Jacques Lucke added 2 commits 2023-05-02 16:03:59 +02:00
Hans Goudey added 1 commit 2023-05-02 16:06:33 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
05fb698608
Fix: Compile error from change in main
Hans Goudey changed title from WIP: Experimental geometry nodes simulation branch to Geometry Nodes: Simulation nodes 2023-05-02 16:15:38 +02:00
Jacques Lucke changed title from Geometry Nodes: Simulation nodes to Geometry Nodes: add simulation support 2023-05-02 16:54:58 +02:00
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR104924) when ready.
Jacques Lucke added 1 commit 2023-05-03 10:35:13 +02:00
Jacques Lucke added 1 commit 2023-05-03 10:46:16 +02:00
Jacques Lucke added 1 commit 2023-05-03 12:56:04 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
319f31b8ae
Merge branch 'main' into geometry-nodes-simulation
Member

@blender-bot build

@blender-bot build
Member
0de54b84c6f0e64e145db2356048fea63a734da9
Jacques Lucke closed this pull request 2023-05-03 13:26:03 +02:00
Jacques Lucke deleted branch geometry-nodes-simulation 2023-05-03 13:26:23 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:42 +02:00
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
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 Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#104924
No description provided.