WIP: Volume grid attribute support in geometry nodes #110044

Closed
Lukas Tönne wants to merge 130 commits from LukasTonne/blender:geometry-nodes-flip into main

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

130 Commits

Author SHA1 Message Date
Lukas Tönne 247f3df064 Merge branch 'main' into geometry-nodes-flip 2023-09-17 09:01:04 +02:00
Lukas Tönne 1b5299408c Added missing include path to spreadsheet editor. 2023-09-17 09:00:14 +02:00
Lukas Tönne ad8736ee62 Added back stub functions to fix MSVC linker errors. 2023-09-16 23:36:30 +02:00
Lukas Tönne b82e55ad03 Merge branch 'main' into geometry-nodes-flip 2023-09-16 10:43:23 +02:00
Lukas Tönne 90d803e5ac Revert "Partial runtime grid representation for point clouds."
This reverts commit 190035a1e8.
2023-09-16 10:25:54 +02:00
Lukas Tönne 190035a1e8 Partial runtime grid representation for point clouds. 2023-09-15 18:00:58 +02:00
Lukas Tönne cba1f0ed6b Removed the deprecated link search functions from new nodes. 2023-09-15 12:04:48 +02:00
Lukas Tönne dac4fdc263 Merge branch 'main' into geometry-nodes-flip 2023-09-15 12:00:55 +02:00
Lukas Tönne dd6581779f Revert some hacks. 2023-09-14 20:20:56 +02:00
Lukas Tönne 5430b8057a Merge branch 'main' into geometry-nodes-flip 2023-09-13 08:10:21 +02:00
Lukas Tönne d97140e0b3 Merge branch 'main' into geometry-nodes-flip 2023-09-12 22:42:07 +02:00
Lukas Tönne c46ebd869b Finished implementation of generic grid materialization. 2023-09-12 09:30:10 +02:00
Lukas Tönne 4c6470a24e Some more work on generic vgrid materialize. 2023-09-11 11:05:50 +02:00
Lukas Tönne bdeb55bfe5 Fixed incorrect use of WITH_OPENVDB define. 2023-09-11 10:35:00 +02:00
Lukas Tönne d4cfe0b5ba Partial implementation of materialization for general grids. 2023-09-10 23:28:18 +02:00
Lukas Tönne 536feda87f Fixed return value when using static type dispatchers. 2023-09-10 15:41:11 +02:00
Lukas Tönne 50a490c507 Return actual cell center positions from the position attribute. 2023-09-10 14:54:44 +02:00
Lukas Tönne ae781693c7 Capture grid accessor by value since it goes out of scope. 2023-09-10 14:08:26 +02:00
Lukas Tönne bf7739fa7a Linker fix: Added a stub in makesrna for a missing reference.
It's unclear why makesrna needs this implementation in the first place
(maybe the source crawling preprocess adds this dependency somehow).
Linking to bf_blenlib does not solve the problem, the only thing that
seems to work is adding a stub in bf_rna itself.
2023-09-10 13:59:06 +02:00
Lukas Tönne 192dc6d19d Moving virtual array leaf buffer access directly into virtual grids. 2023-09-09 18:59:40 +02:00
Lukas Tönne e1609d8759 Support single-value grid readers when evaluating multifunctions. 2023-09-09 14:01:54 +02:00
Lukas Tönne 23482e9583 Initialize buffer topology before evaluating input fields.
When evaluating input volume fields the output buffers are initialized
as empty grids. In order to have leaf node buffers to store values in
the output buffers needs to have the combined topology of all input
grids.
2023-09-09 11:20:42 +02:00
Lukas Tönne bfe8e92567 Apply the domain matrix to newly created grids. 2023-09-09 10:00:58 +02:00
Lukas Tönne 2e04486981 Cleanup: Removed leftover bits of outdated nodes. 2023-09-09 09:22:53 +02:00
Lukas Tönne b7566d15e6 Fixed merge and build errors. 2023-09-08 22:09:39 +02:00
Lukas Tönne 2916efe9c7 Merge branch 'main' into geometry-nodes-flip 2023-09-08 19:43:30 +02:00
Lukas Tönne 15ca2dd1ab Added a domain_transform callback to initialize grid buffer transforms. 2023-08-29 09:12:08 +02:00
Lukas Tönne 6974117159 Fixed linker error for BLI_volume function. 2023-08-28 22:01:52 +02:00
Lukas Tönne e349de2841 Use the standard C++ allocator for grids to avoid incoherent free.
Grids are stored in shared_ptr and eventually freed using delete.
2023-08-28 18:05:33 +02:00
Lukas Tönne 32feda19a4 Merge branch 'main' into geometry-nodes-flip 2023-08-28 16:44:34 +02:00
Lukas Tönne 8145c5ab93 Convenience functions for creating grids and trees. 2023-08-28 12:11:54 +02:00
Lukas Tönne a64e72c804 Partial fix for constant output buffers. 2023-08-27 23:31:42 +02:00
Lukas Tönne 5844ead0be Fixed incorrect code for casting to typed grids. 2023-08-27 20:38:48 +02:00
Lukas Tönne 068c58b362 Fixed remaining build issues. 2023-08-27 18:51:57 +02:00
Lukas Tönne acf3f9da79 Merge branch 'main' into geometry-nodes-flip 2023-08-26 09:45:39 +02:00
Lukas Tönne bb47b5f1fa Fixed a few more build issues. 2023-08-21 18:07:34 +02:00
Lukas Tönne ce3fae522a Temp: Added a virtualized grid class similar to VArray. 2023-08-21 09:25:09 +02:00
Lukas Tönne 6aa68ee85b Added virtual grid classes to enable fields without implicit topology.
Example: voxel positions can be a virtual grid without actual voxel
values stored in a grid. As a virtual grid with a function
implementation they can be evaluated at any location without requiring
grid storage.
2023-08-20 11:40:53 +02:00
Lukas Tönne 360e70b974 Removed the GridMask class.
A MaskGrid can be represented simply as a volume::Grid<bool>.
2023-08-18 15:30:39 +02:00
Lukas Tönne 569c2dc636 Removed outdated node types for grid value access. 2023-08-18 14:40:55 +02:00
Lukas Tönne fb19f8dab4 Cleanup: Removed old unused code. 2023-08-18 14:36:24 +02:00
Lukas Tönne a539206aaf Merge branch 'main' into geometry-nodes-flip 2023-08-18 13:57:23 +02:00
Lukas Tönne 67bd1671cf Disabled unused type adaptation for grids (TBD). 2023-08-18 12:44:27 +02:00
Lukas Tönne 45e0cbb1f0 Completed grid value converter for reinterpreting Blender math as OpenVDB types. 2023-08-18 12:44:03 +02:00
Lukas Tönne 09ed2e7664 Completed grid value converter for reinterpreting Blender math as OpenVDB types. 2023-08-18 10:33:44 +02:00
Lukas Tönne f16101c976 Fixed registration for the "set grid value" node. 2023-08-18 10:33:19 +02:00
Lukas Tönne 36fedfa64f Temp: progress with OpenVDB grid converters. 2023-08-17 18:32:31 +02:00
Lukas Tönne 43d1589078 Need converter specialization for both MaskGrid and BoolGrid.
Bool grids also effectively use the same LeafBuffer type as MaskGrids,
which directly exposes the bit fields of the activation state (WordType,
unsigned long int).
2023-08-17 17:34:10 +02:00
Lukas Tönne 3d99cd075d Merge branch 'main' into geometry-nodes-flip 2023-08-17 15:51:46 +02:00
Lukas Tönne 5aa82e52f7 Temp: Change grid types from custom blender value types to use OpenVDB default types again.
This makes it easier to load compatible grids from files and use
existing OpenVDB tools and algorithms. It requires some converter utils
to reinterpret vector types like `openvdb::Vec3f` as the equivalent
Blender vector types.
2023-08-17 08:51:01 +02:00
Lukas Tönne 8d69877c03 Fixed selection mask construction when the selection is constant.
The selection grid can be empty but still `true` everywhere, in which
case the full mask should be used.
2023-08-15 11:44:15 +02:00
Lukas Tönne 1a34d5b4a9 Include BLI volume grid types when finding VolumeGrid enum type.
This needs to be unified, for now just make it work.
2023-08-14 21:48:10 +02:00
Lukas Tönne 3bc521f246 Fixed mask calculation, use correct constructor to convert arbitrary mask tree to openvdb::MaskTree. 2023-08-14 21:35:24 +02:00
Lukas Tönne 908bb07d4a Added debug prints to volume attribute provider for easier debugging. 2023-08-14 10:10:44 +02:00
Lukas Tönne 027f902488 Voxelize active nodes before evaluating the multifunction.
Grids can have active nodes with all-constant values, in which case
OpenVDB will optimize away leaf buffers. To be able to evaluate the
multifunction on each voxel we first need to voxelize the output grid.
2023-08-14 09:42:45 +02:00
Lukas Tönne 0fe3f15aaa Copy the mask transform to newly generated grids. 2023-08-13 17:39:30 +02:00
Lukas Tönne 35947a84f5 When evaluating varying grid fields the destination does not have to contain a grid in advance. 2023-08-13 17:38:45 +02:00
Lukas Tönne f686c8cbf2 Copy grid pointer instead of its contents after capturing attributes. 2023-08-13 14:29:17 +02:00
Lukas Tönne 941801416d When "moving" a grid simply copy the pointer. 2023-08-13 13:45:07 +02:00
Lukas Tönne fd7c4a572b Renamed dynamic paint internal `VolumeGrid` struct to avoid ambiguity. 2023-08-10 19:40:24 +02:00
Lukas Tönne 033a78b93b Added grid functions to remaining FieldInput classes. 2023-08-10 14:52:54 +02:00
Lukas Tönne 8a7f110f98 Make field input grid functions abstract and implement for all types. 2023-08-10 10:45:54 +02:00
Lukas Tönne b634aa6422 Make sure input fields are always valid when evaluating.
Moving a grid pointer to the resource scope invalidates the pointer,
have to use the result of scope.add to return the actual grid.
2023-08-10 08:58:17 +02:00
Lukas Tönne 27f56153dc Default grid mask callback for non-volume attribute accessor functions. 2023-08-10 07:59:33 +02:00
Lukas Tönne c052997401 Merge branch 'main' into geometry-nodes-flip 2023-08-09 15:09:46 +02:00
Lukas Tönne 13dc967a3a Removed unused type aliases. 2023-08-07 16:42:39 +02:00
Lukas Tönne d1c3cb152b Use a callback to avoid nesting static type dispatches.
Static type dispatchers like `field_to_static_type` and
`grid_to_static_type` generate a lot of code, leading to combinatorial
explosion when they are nested. This can easily overwhelm the linker
and break the build, in addition to making it slow.
2023-08-07 16:28:40 +02:00
Lukas Tönne 695022bba8 Merge branch 'main' into geometry-nodes-flip 2023-08-07 14:05:30 +02:00
Lukas Tönne aaaf5e75da Fixed some build errors. 2023-08-07 10:42:11 +02:00
Lukas Tönne 490f49fa93 Formatting fixes. 2023-08-07 10:30:31 +02:00
Lukas Tönne 0ba80a7b23 Removed check for exact destination voxel count match in VolumeFieldEvaluator.
This assert makes sense for VArrays which are pre-allocated, but grids
change size dynamically and the destination can be just an empty grid.
2023-08-07 09:23:08 +02:00
Lukas Tönne a738632303 Use the active grid as domain mask also when storing final outputs. 2023-08-07 09:18:47 +02:00
Lukas Tönne 9a8844432a Use static variable for empty masks to avoid reference going out of scope. 2023-08-07 09:06:52 +02:00
Lukas Tönne 9c7b6631a7 Use the "active" volume grid as the default domain mask for active voxels. 2023-08-07 00:32:58 +02:00
Lukas Tönne 9c42b468f2 Store named output grid attributes in the volume and use the first as the active grid. 2023-08-06 16:35:07 +02:00
Lukas Tönne d900309880 Merge branch 'main' into geometry-nodes-flip 2023-08-06 13:57:53 +02:00
Lukas Tönne 3898592838 Added new custom grid attribute provider. 2023-08-06 13:51:15 +02:00
Lukas Tönne 39fd31c7ee Implemented mask function for combining with a selection. 2023-08-05 17:37:20 +02:00
Lukas Tönne 04753cc36a Removed OpenVDB includes from BKE_volume_openvdb as well. 2023-08-05 16:18:47 +02:00
Lukas Tönne 681c689a28 Removed another openvdb.h include. 2023-08-05 14:42:54 +02:00
Lukas Tönne 66cb07d056 Fixed node files after recent C++ conversions. 2023-08-05 14:09:44 +02:00
Lukas Tönne ec90cf63d5 Fix merge error. 2023-08-05 13:55:34 +02:00
Lukas Tönne 34a79e6d37 Merge branch 'main' into geometry-nodes-flip 2023-08-05 13:33:48 +02:00
Lukas Tönne 498656a2bf Removed OpenVDB includes from blenkernel headers. 2023-08-05 13:27:40 +02:00
Lukas Tönne ce26803d3a Build improvement: Use forward declaration for OpenVDB types.
OpenVDB is heavily templated and can dramatically increase build times
and memory requirement, if OpenVDB headers are included in too many
places. The solution is to avoid including openvdb.h in other header
files and only do this in .cc source files where the implementation is
really needed. The BLI_volume.hh header now only forward-declares
the OpenVDB types.
2023-08-05 12:42:16 +02:00
Lukas Tönne a950aa2067 Added attribute initializers specifically for grids. 2023-07-30 10:18:28 +02:00
Lukas Tönne b7c515badf Fixed missing implementation of the empty grid mask. 2023-07-26 20:08:04 +02:00
Lukas Tönne 37f90cde4f Fixed some undefined functions. 2023-07-26 19:46:41 +02:00
Lukas Tönne 1d86f7cdad Fixed more build issues. 2023-07-26 09:01:24 +02:00
Lukas Tönne f4e08ff213 Function for merging a grid mask with a boolean field. 2023-07-24 15:17:51 +02:00
Lukas Tönne 9c1fb1319a Questionable linker hack. 2023-07-24 14:29:06 +02:00
Lukas Tönne a7a1ab382c Fixed some build errors. 2023-07-24 14:19:32 +02:00
Lukas Tönne 5e1ead458c Added new FieldEvaluator variant for grids. 2023-07-24 09:00:42 +02:00
Lukas Tönne 8df11ebbcf Disabled old attribute code to avoid build issues. 2023-07-23 16:13:26 +02:00
Lukas Tönne dbe2d5f5c7 Fixed missing TBB dependency in makesrna. 2023-07-23 11:44:35 +02:00
Lukas Tönne afd443f76b Removed invalid include. 2023-07-22 19:26:50 +02:00
Lukas Tönne c06f97e781 Fixed build errors and completed switch to volume::Grid. 2023-07-22 17:08:06 +02:00
Lukas Tönne 888f02d1a9 Merge branch 'main' into geometry-nodes-flip 2023-07-22 13:00:55 +02:00
Lukas Tönne 0ab5983640 Merge branch 'main' into geometry-nodes-flip 2023-07-22 12:44:53 +02:00
Lukas Tönne e9fd92ad11 Temp: making generic volume::GGrid and type volume::Grid classes. 2023-07-19 18:31:39 +02:00
Lukas Tönne 85b45987c9 Fix error with gcc: template specialization inside struct not allowed. 2023-07-19 12:56:00 +02:00
Lukas Tönne a6ed9f7224 Temp: Adding grid attribute accessors. 2023-07-19 10:22:04 +02:00
Lukas Tönne 831f492458 Renamed VolumeGrid and VolumeMask to avoid conflicts with BKE structs.
The new Grid and GridMask classes will act similar to VArrays during
field evaluation. The VolumeGrid struct is equivalent to
CustomDataLayers, it provides the attribute inputs for the field graph.
2023-07-18 22:06:03 +02:00
Lukas Tönne ca6d21e624 Moved volume grid and mask base implementation to BLI. 2023-07-18 01:13:07 +02:00
Lukas Tönne e331fb5298 Partial: move volume classes to BLI for acccess by both BKE and FN. 2023-07-17 09:30:04 +02:00
Lukas Tönne ae41cf02a8 Optional methods in FieldInputs for providing volume grid inputs. 2023-07-17 00:10:59 +02:00
Lukas Tönne 68be105a94 Implemented evaluation for constant fields. 2023-07-16 21:44:17 +02:00
Lukas Tönne acc190463d Disable types that don't have CPPType registration to fix linker errors. 2023-07-16 19:49:21 +02:00
Lukas Tönne 4e69ceb8ef Implemented dedicated evaluation of fields for volumes. 2023-07-16 19:16:03 +02:00
Lukas Tönne 97fa985ff6 Started replacing VArrays with grid wrappers (VolumeGrid). 2023-07-15 02:18:21 +02:00
Lukas Tönne 45038ee927 Stub function for evaluating volume fields. 2023-07-14 09:21:54 +02:00
Lukas Tönne 0ae4ac4b64 Fixed some build errors with gcc. 2023-07-13 10:39:15 +02:00
Lukas Tönne 61c89fadcb Partial fix for set_all. 2023-07-13 09:31:31 +02:00
Lukas Tönne a5e92c0daa Mostly added support for custom grid attributes. 2023-07-13 01:47:45 +02:00
Lukas Tönne fb2b362b5d Fix incorrect starting index when searching in leaf buffers. 2023-07-12 09:23:08 +02:00
Lukas Tönne 2d687e122a Added new Voxel domain type for grids. 2023-07-12 08:15:14 +02:00
Lukas Tönne c4034dac33 Implemented grid value setter. 2023-07-11 23:05:47 +02:00
Lukas Tönne 441b745bbf Added another node for setting the grid value. 2023-07-10 20:18:39 +02:00
Lukas Tönne 501d7d4f50 Added menu entries for new nodes. 2023-07-10 17:43:21 +02:00
Lukas Tönne 8336d13e1d Fix non-inlined function. 2023-07-10 17:33:00 +02:00
Lukas Tönne ee37d0ab14 Added a bunch of new node types (empty prototypes) for volumes. 2023-07-10 17:14:29 +02:00
Lukas Tönne 4417fec18f Implementing the materialize function for volume VArrays. 2023-06-29 00:44:51 +02:00
Lukas Tönne b945357a1c Implemented set_all for the VArrayImpl. 2023-06-28 22:48:43 +02:00
Lukas Tönne be3155ab2c Switch to enum-based type resolution to avoid insane error messages. 2023-06-28 17:16:30 +02:00
Lukas Tönne f6f2dc3973 Cleanup: Redesign data layout for a single grid. 2023-06-28 16:24:40 +02:00
Lukas Tönne 29be6acb7a Merge branch 'main' into geometry-nodes-flip 2023-06-28 11:05:44 +02:00
Lukas Tönne db75107fff Use VolumeGeometry same way as CurvesGeometry. 2023-06-28 11:04:45 +02:00
Lukas Tönne 54cc5d17e1 Reenabling the VolumeGeometry struct. 2023-06-28 09:32:09 +02:00
Lukas Tönne 7585994cb4 Added value conversion and fixed compiler errors. 2023-06-27 20:49:06 +02:00
Lukas Tönne 419e90c175 Solving template errors. 2023-06-27 09:53:45 +02:00