138 Commits

Author SHA1 Message Date
Brady Johnston
56bb70fee8 Geometry Nodes: Advect Grid node
Given a grid of velocities, this node advects the values of the input
grid. Different options for integration scheme and clamping are
exposed. Currently their names are just as defined in OpenVDB.

Pull Request: https://projects.blender.org/blender/blender/pulls/147273
2025-10-07 16:19:19 +02:00
Campbell Barton
cc1a3f19b4 Cleanup: resolve various pylint warnings from recent changes 2025-10-07 10:19:46 +11:00
W_Cloud
247c19f6cf Fix #147355: Nodes: Inconsistent vector add menu
- Add the missing `Vector Math` node to the Compositor add menu.
- Adjust the position of the `Separate XYZ` node in Geometry Nodes.
- Adjust the position of the `Vector Math` node in Shader Nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/147435
2025-10-06 19:09:01 +02:00
Brady Johnston
438b8c303e Geometry Nodes: SDF Grid filtering nodes
This PR gives access to OpenVDB's level set filtering operations
through individual **SDF Grid** nodes.

- **Mean Curvature**: Smoothens high curvature areas more than flatter
  ones.
- **Laplacian**: Approximates mean curvature flow for true SDFs at lower
  computational cost.
- **Median**: Reduces noise while preserving sharp features.
- **Mean**: Fast separable averaging filter for general-purpose
  smoothing with linear computational complexity.
- **Offset**: Uniform dilation/erosion operation that shifts the SDF
  surface by a world-space distance.
- **Fillet**: Rounds off concave internal corners by operating only on
  regions with negative principal curvature.

Pull Request: https://projects.blender.org/blender/blender/pulls/147224
2025-10-06 17:54:25 +02:00
Brady Johnston
83ea4788bd Geometry Nodes: Bring Volume nodes out of experimental
Discussed in the post-BCON Geometry Nodes workshop, this PR brings the
currently implemented Grid & Volume nodes out of experimental.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/146789
2025-10-03 15:04:55 +02:00
Jacques Lucke
2a0a07654a Geometry Nodes: add Voxel Index node
This node gives access to the integer coordinates of the the voxel that is
currently being evaluated by a field. It can be used together with e.g. the
Integer Math and Sample Grid Index node to sample neighboring voxel values.
Previously, one could only get the position of the voxel in object space.

Since sometimes field are evaluated on tiles of many voxels, just having the
voxel coordinates can be misleading. Therefore, this same node also outputs
whether it is a tile and the extent of the tile (which is 1 for normal voxels).

Pull Request: https://projects.blender.org/blender/blender/pulls/147268
2025-10-03 14:25:14 +02:00
Hans Goudey
10dababb09 Geometry Nodes: Set Grid Background node
It's useful when creating a grid procedurally to be explicit
about what background value it gets. This PR adds a very
simple node just to do that.

Pull Request: https://projects.blender.org/blender/blender/pulls/147235
2025-10-02 21:25:11 +02:00
Hans Goudey
d3278249a8 Geometry Nodes: Volume grid Prune and Voxelize nodes
Add two common building blocks for volume-grid workflows.

- **Voxelize** turns all active tiles into fully dense voxels. For fog
  volumes, this will mean the "inside" sparse tiles will become
  individually adjustable voxel values.
- **Prune** is the opposite action as voxelize. It can be important for
  certain workflows when large regions of constant values are created.
  The node can collapsed those regions into more efficient tiles or
  inner nodes. There are a few modes which are each useful for
  different use cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/147148
2025-10-02 20:53:42 +02:00
Brady Johnston
4a56973fe7 Geometry Nodes: Set Grid Transform
Explicitly set the transform of a grid.

The new transform can fail to be applied if the input transform isn't
invertible or for some extremes of scaling (0 or combinations of
negative and positive) and numerical errors with `openvdb`. If a
transform is not applied an error is raised and the `Is Valid`
returns false.

Pull Request: https://projects.blender.org/blender/blender/pulls/146824
2025-10-02 19:12:39 +02:00
Brady Johnston
0a77a57c4e Geometry Nodes: Add OpenVDB grid operators
Adds four new grid operator nodes that wrap OpenVDB's differential
operators. All nodes take a grid input and output a grid, potentially
with a different data type.

New nodes:
- Grid Curl: Calculate curl of vector field (Vec3 → Vec3)
- Grid Divergence: Calculate divergence of vector field (Vec3 → Float)
- Grid Gradient: Calculate gradient of scalar field (Float → Vec3)
- Grid Laplacian: Calculate Laplacian of scalar field (Float → Float)

These operators enable vector calculus operations on volume grids for
effects like flow analysis, vortex detection, etc.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/146845
2025-10-02 16:28:46 +02:00
Habib Gahbiche
5e0b244066 Nodes: Unify add menus
The general idea is to order all menus as:
```
Common categories
(e.g. Input/output)
---
Specific categories
---
Assets
--
Common categories
(e.g. Group/Layout)
```

## Changes:
### Compositor
- Removed Color/Mix submenu
- Moved Vector to Utilities
- New Category: "Creative". This is where most new assets will fit in.
- Moved to Creative:
	- Kuwahara
    - Pixelate
    - Posterize

### Geo Nodes
- Moved 'Vector' to 'Utilities'
- Moved 'Attribute' before 'Geometry'
- Moved 'Material' to 'Geometry'
- Moved 'Color' to top level, grouped with Utilities

### Shader
- Moved 'Vector' to 'Utilities'
- Deleted 'Converter'
- New 'Displacement' menu
- Grouped 'Color' with Utilities (remains top level)

Ref: https://devtalk.blender.org/t/2025-09-05-design-session-node-groups-different-editors/42244
Pull Request: https://projects.blender.org/blender/blender/pulls/146806
2025-10-02 11:07:25 +02:00
Hans Goudey
a774ebd5af Geometry Nodes: Field to Grid Node
The purpose of this node is to create a grid with new voxel values on
the same grid topology as an existing grid. The new values are the
result of field evaluation. Multiple grids can be created at the same
time, so that intermediate results used for multiple grids can be
efficiently reused during evaluation. This is more efficient than the
"Volume Cube" node, for instance, because the output grid shares the
sparseness of the input topology grid.

Pull Request: https://projects.blender.org/blender/blender/pulls/147074
2025-10-01 18:40:49 +02:00
Brady Johnston
8b3be68b3d Geometry Nodes: new Join Bundle Node
Adds a Join Bundle node with a multi-input Bundle socket. Bundles are
iterated on the top level of each input bundle and items added to the resulting
single bundle. While creating the final bundle existing items have priority and
new items with an already existing name are discarded.

There is an info message when there are duplicate keys in the input bundles.

Co-authored-by: Brady Johnston
Co-authored-by: Jacques Lucke
Pull Request: https://projects.blender.org/blender/blender/pulls/146750
2025-10-01 09:20:11 +02:00
quackarooni
4498cb7baa Geometry Nodes: add "Mix Rotation" to Add menu
This patch exposes the "Rotation" subtype of the Mix node in the Geometry Node Add Menu.

This is in a similar vein to "Mix Color" & "Mix Vector", as it makes this subtype more easily
accessible and searchable in the menu.

Pull Request: https://projects.blender.org/blender/blender/pulls/142887
2025-09-28 14:20:14 +02:00
Hans Goudey
eef9a1b9ae Geometry Nodes: UV tangent node
This node outputs tangent values for face corners. There are two methods:
- **Exact** is the same MikkTSpace calculation used elsewhere in Blender.
- **Fast** (from #131308) is over 4x faster, and useful in many of
  the same situations, though not necessarily tangential to the surface.

The reason to include both methods is that there are use cases where the
quality of the tangents don't matter (though the results are actually very
similar visually), we just need some continuous values across faces.

Pull Request: https://projects.blender.org/blender/blender/pulls/145813
2025-09-27 18:57:18 +02:00
Jacques Lucke
b186e60759 Nodes: support node output visibility inferencing
Currently, only the visibility of input sockets can be changed dynamically based
on other menu inputs. However, under some circumstances, it can also be useful
to hide certain outputs. For example, the built-in Curve Arc primitive node does
that.

This patch adds support for automatic detection of unused outputs. How to detect
unused outputs is less straight forward compared to inputs. This patch uses the
rule that an output is unused if it always outputs a "fallback value" (typically
0) irrespective of the currently used inputs. If the output is independent of
all inputs, it stays visible though.

There is a new small utility node called "Enable Output". It replaces a value
with it's fallback value unless it is disabled. This simplifies setting up
unused outputs. In theory, a normal switch node can also be used, but that is
less usable and the user will have to hardcode the fallback value for each type
which is not something that is explicitly exposed yet.

Supporting dynamic output visibility is also a prerequisite for exposing some
menu node options as sockets (e.g. in the Arc node).

Pull Request: https://projects.blender.org/blender/blender/pulls/140856
2025-09-27 10:09:48 +02:00
Campbell Barton
b4fbc0c32d Cleanup: remove f-strings use, use double quotes, quiet pylint warnings 2025-09-26 14:31:05 +10:00
quackarooni
2a1a658492 Nodes: Swap Node Operator
Implement a native method to swap between different node and zone types.

This implementation repurposes the existing menu definitions as base
classes, from which both an "Add" and a "Swap" version would be generated
from. This allows both menus to have the same layout, but use their own
operators for handling the different node/zone types.

In this PR, support for all node editors has been implemented.

Invoking the menu is currently bound to `Shift + S`, same as the old
implementation in Node Wrangler. Since "Swap" is implemented as a
regular menu, features that menus already have such as type-to-search
and adding to Quick Favorites don't require any extra caveats to
consider.

Resolves #133452

Pull Request: https://projects.blender.org/blender/blender/pulls/143997
2025-09-25 16:12:02 +02:00
Tenkai Raiko
f8d579d153 Nodes: Add Radial Tiling Node
On its own, the main functionality of the Radial Tiling node
is the ability to divide a 2D Cartesian coordinate system into
as many radial segments as specified by the "Segments" input.
Each segment has its own affinely transformed coordinate system,
provided through the "Segment Coordinates" output, which can be
used to tile textures in a radially symmetric manner.

Additionally, a unique index is provided for every segment through
the "Segment ID" output, the width of each segment at Y-coordinate
of the "Segment Coordinates" output without normalization = 0 is
provided through the "Segment Width" output and the rotation value
of the affine transformation of the coordinate system of each segment
is provided through the "Segment Rotation" output.

The roundness of the coordinate lines of the "Segment Coordinates"
output can be controlled through the "Roundness" inputs.
This can be used to make the coordinate systems of the segments
a mix of Cartesian and polar coordinates.

Lastly, the lines of points of the "Segment Coordinates" output with
constant Y-coordinates have the shape of polygon with rounded corners,
which can be used to procedurally create rounded polygons.

Pull Request: https://projects.blender.org/blender/blender/pulls/127711
2025-09-22 16:02:37 +02:00
David-Sebald
ad83a1017f Geometry Nodes: new String to Value node
An existing node converts a value (float) to string. This node is intended as a conversion in
the other direction. If parsing is unsuccessful, floating point 0 is output. This node also
outputs the length of the parsed string (i.e. the index of the first character where the
number stopped).

Pull Request: https://projects.blender.org/blender/blender/pulls/112174
2025-09-05 08:51:38 +02:00
Omar Emara
3d7c8d022e Refactor: Nodes: Generalize node tree subtypes
This patch generalizes node tree subtypes to be usable for node trees
other than Geometry Nodes. In particular, this:

- Renames SpaceNode.geometry_nodes_type to node_tree_sub_type, which now
  store a tree type-specific enum.
- Renames SpaceNode.geometry_nodes_tool_tree to selected_node_group,
  which now stores any context-less tree of any type.

This breaks the python API due to renaming.

Pull Request: https://projects.blender.org/blender/blender/pulls/144544
2025-08-21 09:04:13 +02:00
Alberto12345678999
d803ee4c79 Nodes: Port shader Gamma node to Geometry Nodes
This patch unifies the Gamma node across editors:

- Compositor now uses the Shader Gamma node implementation.
- Geometry Nodes also uses the node as a new addition.
- UI-wise in the Compositor, only socket labels change to "Color".

Forward compatibility is broken for the compositor, and the python API
changed, since the node's ID name is now ShaderNodeGamma as opposed to
CompositorNodeGamma.

Pull Request: https://projects.blender.org/blender/blender/pulls/142414
2025-08-20 08:46:34 +02:00
Jacques Lucke
24c4e0a3f7 Geometry Nodes: move bundle and closure nodes out of experimental
This moves the bundles and closures features out of experimental,
making them an official part of Blender 5.0.

Also see #134029.

Pull Request: https://projects.blender.org/blender/blender/pulls/143750
2025-08-08 13:48:02 +02:00
Jacques Lucke
252b983c0c Geometry Nodes: change idnames of experimental bundle and closure nodes
This removes the "Geometry" part from their name because we want to use them in
other node tree types too (see #141936).

Usually, we don't change idnames because they are the primary identifier of
nodes and is expected to stay the same. Since they are generally not shown to
users (just Python developers), it's also not urgent to change them. However, in
this specific case we have the opportunity to update the idname before the node
becomes an official feature, so it's not as bad to change it.

This patch has full backward compatibility, but no forward compatibility (for
files that used the experimental feature).

Pull Request: https://projects.blender.org/blender/blender/pulls/143823
2025-08-02 10:17:39 +02:00
Jacques Lucke
f73f9ad477 Geometry Nodes: move closure and bundle nodes to their own menu
This is still only visible if the experimental feature is enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/143749
2025-07-31 21:08:47 +02:00
Hans Goudey
4f372d64d4 Geometry Nodes: Initial very basic list support
This includes a new list structure type and socket shape, a node
to create lists, a node to retrieve values from lists, and a node to
retrieve the length of lists. It also implements multi-function support
so that function nodes work on lists.

There are three nodes included in this PR.
- **List** Creates a list of elements with a given size. The values
  are computed with a field that can use the index as an input.
- **Get List Item** A field node that retrieves an element from a
  a list at a given index. The index input is dynamic, so if the input
  is a list, the output will be a list too.
- **List Length** Just gives the length of a list.

When a function node is used with multiple list inputs, the shorter
lists are repeated to extend it to the length of the longest.

The list nodes and structure type are hidden behind an experimental
feature until we can be sure they're useful for an actual use case.

Pull Request: https://projects.blender.org/blender/blender/pulls/140679
2025-07-24 16:16:40 +02:00
Campbell Barton
808cc599f8 Cleanup: reduce right shift, wrap long lines 2025-07-11 16:48:15 +10:00
Damien Picard
0ba83d8958 I18n: Translate GN Add > Input > Import menu items
Geometry Nodes' Add > Input > Import menu includes file format items
such as "Standford PLY (.ply)", "STL (.stl)", "Text (.txt)". The
latter needs to be translated because "Text" is a generic format.

These items are declared using a custom function
`node_add_menu.add_node_type`, with a `label` argument. This commit
adds the `label` argument to the function arguments that can be
extracted from specific node declaration functions, and specifies the
argument position for each:

"add_node_type", "add_node_type_with_outputs", "add_simulation_zone",
"add_repeat_zone", "add_foreach_geometry_element_zone",
"add_closure_zone".

There is currently no facility to specify a translation context but it
could be easily added if the need arises.

Most of these functions do not actually declare new, unique messages,
but it could happen in the future. In addition, two messages were
extracted using manual `iface_()` calls, which are no longer needed
after this change.

Reported by Ye Gui in #43295.
2025-07-01 10:47:09 +02:00
quackarooni
633463c586 Fix: Nodes: Add menu entries not in alphabetical order
It is generally expected that items within the same section in the Node
Add menu appear in alphabetical order.

However, certain handful of places in the different node editor menus
don't seem to follow this convention. This patch simply re-arranges the
items in some places to follow alphabetical order.

Pull Request: https://projects.blender.org/blender/blender/pulls/140070
2025-06-10 15:49:31 +02:00
Jacques Lucke
182797ea61 Geometry Nodes: new Format String node
This adds a new Format String node which simplifies constructing strings from
multiple values. The node takes a format string and a dynamic number of
additional parameters as input. The format string determines how the other
inputs are inserted into the string. Only integer, float and string inputs are
supported for now.

It supports two different format syntaxes:
* Python compatible format syntax which also mostly matches the behavior of the
  `fmt` C++ library. Most of this is supported, but there are some small
  limitations.
* Syntax of the form `###.##` where each `#` stands for a digit. This is the
  syntax that was introduced in #134860.

This node greatly simplifies common string operations which would have required
potentially many nodes before to convert numbers to strings and to concatenate
them. It also makes new conversions possible that were not supported before.
This node can also be used to insert e.g. frame numbers into a file path which
was surprisingly complex before.

This node has special behavior for the name of new inputs. For the purpose of
the node, the name of the inputs must be valid identifiers and it's usually
helpful when they are short. New names are therefore initialized to be single
characters. If possible, the first character of the linked input is used. This
works well when connecting e.g. a Separate Vector/Color node. Otherwise, inputs
are named `a` to `z` by default. If that's not possible, the source socket name
is used instead (converted to be a valid identifier). If that still doesn't
work, the name is made unique using the normal `.001` mechanism except that `_`
instead of `.` is used as separator to make the name a valid identifier.

Python Syntax references:
* Python: https://docs.python.org/3/library/string.html#formatspec
* `fmt`: https://fmt.dev/latest/syntax/

More detailed notes about compatibility with the above syntax specifications:
* Conversion using e.g. `!r` like in Python is not supported (maybe the future).
* Sub-attribute access like `{vector.x}` is not supported (maybe the future).
* Using `%` like in Python is not supported (maybe in future).
* Using `#` for an alternate form is not supported. This might help in the
  future to make the syntax compatible with #134860.
* Using `L` like in the `fmt` library is not supported because it depends on the
  locale which is not good for determinism.
* Grouping with e.g. thousands separators using e.g. `,` or `_` like in Python
  is not supported (maybe in future). Need to think about the locale here too.
* Mixing of unnamed (`{}`) and named (`{x} or {0}`) specifiers is allowed.
  However, all unnamed specifiers must come before any named specifier.

The implementation uses the `fmt` library for the actual formatting. However,
the inputs are preprocessed to give us more control over the exact supported
syntax and error messages. The code is already somewhat written so that many
strings could be formatted with the same format but that's not actually used yet
because we don't have string fields yet.

Error messages are propagated using a new mechanism that allows a limited form
of error propagation from multi-functions to the node that evaluates them.
Currently, this only works in fairly limited circumstances, e.g. it does not
work during field evaluation. Since this node is never part of field evaluation
yet, that limitation seems ok, but it's something to work on at some point.
Properly supporting that requires some more changes to propagate enough context
information everywhere. Also showing errors of field evaluation on the field
node itself (instead of on the evaluation node) requires even more work because
our current logging system is not setup to support that yet.

This node comes with a few new requirements for the socket items system: names
must be valid identifiers and they are initialized in a non-trivial way.
Overall, this was fairly straight forward to implement but currently it requires
to adding a bunch of new members to all the accessors that don't really need it.
This is something that we should simplify at some point even if I'm not entirely
sure how yet. The same new requirements used in this node would probably also
exist in a potential future expression node.

Pull Request: https://projects.blender.org/blender/blender/pulls/138860
2025-05-29 13:17:03 +02:00
Jacques Lucke
39a3b44a72 Nodes: support searching for outputs of various input nodes directly
Previously, one had to search for the name of an input node (Geometry, Light
Path, etc.) instead of for the actual desired values.

This patch makes it possible to search for the output names of various input
nodes directly. All other outputs of the input node are hidden automatically.
This was partially support for the Scene Time before.

Supported nodes:
* Compositor: Scene Time
* Geometry Nodes: Camera Info, Mouse Position, Scene Time, Viewport Transform
* Shader Nodes: Camera Data, Curves Info, Geometry, Volume Info, Light Path,
  Object Info, Particle Info

Right now, the output names are hardcoded in the menu. We don't have a great way
to access those without an actual node instance currently. For that we'll need
to make the node declarations available in Python, which is a good project but
out of scope for this this feature. It also does not seem too bad to have more
explicit control over what's shown in the search.

Pull Request: https://projects.blender.org/blender/blender/pulls/139477
2025-05-28 05:41:37 +02:00
Jacques Lucke
4f53677dcd Nodes: support searching for warning types directly 2025-05-27 09:02:06 +02:00
quackarooni
ad90cceb1e Geometry Nodes: Add "Set Grease Pencil Softness" node
How solid/faded the edges of a Grease Pencil stroke is
controlled by the `softness` attribute. This change adds a
node that exposes that attribute, allowing the user to
control it via Geometry Nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/138939
2025-05-23 07:30:23 +02:00
Colin Basnett
39c2f01b51 Nodes: add Bit Math node
This adds a new Bit Math node which supports the following operations: `and`,
`or`, `xor`, `not`, `shift` and `rotate`.

For the `shift` and `rotate` operations, a posititive shift is a left shift and
a negative shift is a right shift.

Currently, the node always works on 32-bit integers which is what Geometry Nodes
uses internally for integers. If required, this can be extended to work on other
bit widths in the future.

The need for this came up every now and then. It can be useful when encoding
specific bits in integer attributes (for efficiency or because the geometry is
exported to other software that expects a certain format). Also, this node is
useful for some people doing crazy but fun things with Geometry Nodes like
emulating hardware. Even if the use-cases are not common, if they arise, it's
hard to work around and the cost of having this node is quite low for us.

Co-authored-by: Charlie Jolly <charliejolly@noreply.localhost>

Pull Request: https://projects.blender.org/blender/blender/pulls/138290
2025-05-19 18:03:05 +02:00
Jacques Lucke
c157fecc4e Nodes: support searching for frame/seconds to find Scene Time node
Previously, one had to search for "Time" to get the Scene Time node which
provides access to the current frame and second. Intuitively I often start
searching for "frame" or "seconds" instead and only later remember what I
actually have to search for.

This patch improves the UX by allowing to create a Scene Time node by searching
for "frame" or "seconds" directly. This works in Geometry Nodes and the
compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/138927
2025-05-15 20:56:33 +02:00
quackarooni
8f232517f0 Fix: Nodes: Missing builtin categories for handling asset catalogs
The current behavior for the Node Editor's Add menu is to list the
user's asset catalogs at the root level of the menu. However, an
exception is made if the catalog has the same name as a builtin menu.
In such case, the asset catalog is appended to that builtin menu,
instead of being drawn at the root level.

How this is currently implemented right now is to have a hard-coded set
of builtin menus in `add_menu_assets.cc`. Certain menus are missing from
this set, particularly newer ones, which may be an oversight during the
creation of these menus.

This patch adds those menus to that list, which are as follows:
- Input/Gizmo
- Input/Import
- Grease Pencil (and all its submenus)
- Texture (in Compositor Nodes)

Pull Request: https://projects.blender.org/blender/blender/pulls/138870
2025-05-14 16:12:29 +02:00
Lukas Tönne
11ceddb9df New Grid Info node for reading grid transforms and background value
These are generic properties of grids (not stored in voxels) which are
useful to know in geometry nodes. The transform in particular defines
the voxel size. Background value is used outside of active voxels.

Pull Request: https://projects.blender.org/blender/blender/pulls/138592
2025-05-12 13:46:40 +02:00
Jacques Lucke
fb86bf0367 Nodes: support searching for color blend modes in Add menu
This is a follow up to #138534. It adds support for searching for all color blend
operations. It's supported in Geometry Nodes, Compositor and Shader Nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/138581
2025-05-09 04:02:50 +02:00
Jacques Lucke
156a405dd5 Nodes: support searching for specific math operations in Add menu
Previously, it was possible to search for specific math operations in
link-drag-search but not in the normal add menu. This patch adds support for
searching for specific operations in various math nodes.

A good trick for adding e.g. a vector add node is to search for `vadd`
(similarly with `iadd`).

The menu itself looks unchanged. This patch only adds additional elements to the
search.

Pull Request: https://projects.blender.org/blender/blender/pulls/138534
2025-05-08 04:28:22 +02:00
Jacques Lucke
1363319844 Geometry Nodes: add Import VDB node
This adds an Import VDB node. It loads all the grids from a .vdb file and hence
outputs a Volume geometry instead of an individual grid.

The grids are cached through the existing volume grid file cache, so they are
automatically deduplicated when volume grids are loaded from files in other
ways.

Pull Request: https://projects.blender.org/blender/blender/pulls/138380
2025-05-06 04:13:11 +02:00
Cartesian Caramel
3d1b6f53f3 Geometry Nodes: new Instance Bounds Node
This adds a new Instance Bounds nodes which provides an easy and
efficient way to get the bounding box of each instance.

Nested instances or not taken into account to compute the bounding
box. That would result in a major performance degredation because
one would have to basically realize all instances to do that.

Also see #135933 for some examples.

Pull Request: https://projects.blender.org/blender/blender/pulls/135933
2025-04-17 13:34:26 +02:00
quackarooni
17b5ab6965 Geometry Nodes: Field Statistic Nodes
Adds field versions of the operations from Attribute Statistic, can
support grouping via Group IDs. These operations are added as separate
nodes: `Field Average`, `Field Min & Max`, & `Field Variance` which
group the different statistic operations according to their use.

Supported Data Types:
- Field Average - (Float, Vector)
- Field Min & Max - (Float, Integer, Vector)
- Field Variance - (Float, Vector)

Pull Request: https://projects.blender.org/blender/blender/pulls/134640
2025-04-08 17:12:08 +02:00
Hans Goudey
d835c02607 Cleanup: Avoid capitals in Geometry Nodes Grease Pencil add menu
The capitals were only used for API compatibility when the add menu
was first added, they're not needed for new menus. Better to avoid
since they're non-standard for menu names.
2025-04-08 10:45:46 -04:00
Falk David
20ce477ea0 Geometry Nodes: Add node to set the Grease Pencil depth order
Adds a new node to set the Grease Pencil depth ordering.

Here are the options:
* 2D Layers: Uses the Layer order + Stroke order to calculate the depth ordering.
* 3D Location: Uses the 3D position of the points as the depth.

This reflects the same setting that is available in the Grease Pencil
object-data properties.

The node is added to the `Grease Pencil` > `Write` menu.

Resolves #129458.

Pull Request: https://projects.blender.org/blender/blender/pulls/135914
2025-04-08 15:24:51 +02:00
Falk David
8a01c9b8ec Geometry Nodes: Add Set Grease Pencil Color node
Adds a new `Set Grease Pencil Color` node.
It was already possible to write to the color and opacity attributes using the
`Store Named Attribute` node, but this required the user to know the names
of the "built in" attributes.

Similar to how we can set other built-in attributes (e.g. the curve radius) this
adds a node to write to the following Grease Pencil attributes:
* `vertex_color` (point domain): The color of a point (the alpha value is used
    as a mix factor with the base material color).
* `opacity` (point domain): The opacity of a point.
* `fill_color` (curve domain): The fill color of a stroke (the alpha value is used
    as a mix factor with the base material color).
* `fill_opacity` (curve domain): The fill opacity of a stroke.

For consistency with other nodes, there is a mode to switch between writing
to the points (`Stroke` mode) and the fills (`Fill` mode).

Pull Request: https://projects.blender.org/blender/blender/pulls/136260
2025-04-05 12:11:26 +02:00
Hans Goudey
d3f84449ad Mesh: Add "free" custom normals
Add a "dumb vector" storage option for custom normals, with the
"custom_normal" attribute. Adjust the mesh normals caching to
provide this attribute if it's available, and add a geometry node to
store custom normals.

## Free Normals
They're called "free" in the sense that they're just direction vectors
in the object's local space, rather than the existing "smooth corner
fan space" storage. They're also "free" in that they make further
normals calculation very inexpensive, since we just use the custom
normals instead. That's a big improvement from the existing custom
normals storage, which usually significantly decreases
viewport performance. For example, in a simple test file just storing
the vertex normals on a UV sphere, using free normals gives 25 times
better playback performance and 10% lower memory usage.

Free normals are adjusted when applying a transformation to the entire
mesh or when realizing instances, but in general they're not updated for
vertex deformations.

## Set Mesh Normal Node
The new geometry node allows storing free custom normals as well as
the existing corner fan space normals. When free normals are chosen,
free normals can be stored on vertices, faces, or face corners. Using
the face corner domain is necessary to bake existing mixed sharp and
smooth edges into the custom normal vectors.

The node also has a mode for storing edge and mesh sharpness, meant
as a "soft" replacement to the "Set Shade Smooth" node that's a bit
more convenient.

## Normal Input Node
The normal node outputs free custom normals mixed to whatever domain is
requested. A "true normal" output that ignores custom normals and
sharpness is added as well.

Across Blender, custom normals are generally accessed via face and
vertex normals, when "true normals" are not requested explicitly.
In many cases that means they are mixed from the face corner domain.

## Future Work
1. There are many places where propagation of free normals could be
   improved. They should probably be normalized after mixing, and it
   may be useful to not just use 0 vectors for new elements. To keep
   the scope of this change smaller, that sort of thing generally isn't
   handled here. Searching `CD_NORMAL` gives a hint of where better
   propagation could be useful.
2. Free normals are displayed properly in edit mode, but the existing
   custom normal editing operators don't work with free normals yet.
   This will hopefully be fairly straightforward since custom normals
   are usually converted to `float3` for editing anyway. Edit mode
   changes aren't included here because they're unnecessary for the
   procedural custom normals use cases.
3. Most importers can probably switch to using free normals instead,
   or at least provide an option for it. That will give a significant
   import performance improvement, and an improvement of Blender's
   FPS for imported scenes too.

Pull Request: https://projects.blender.org/blender/blender/pulls/132583
2025-04-04 19:16:51 +02:00
Jacques Lucke
8ec9c62d3e Geometry Nodes: add Closures and Bundles behind experimental feature flag
This implements bundles and closures which are described in more detail in this
blog post: https://code.blender.org/2024/11/geometry-nodes-workshop-october-2024/

tl;dr:
* Bundles are containers that allow storing multiple socket values in a single
  value. Each value in the bundle is identified by a name. Bundles can be
  nested.
* Closures are functions that are created with the Closure Zone and can be
  evaluated with the Evaluate Closure node.

To use the patch, the `Bundle and Closure Nodes` experimental feature has to be
enabled. This is necessary, because these features are not fully done yet and
still need iterations to improve the workflow before they can be officially
released. These iterations are easier to do in `main` than in a separate branch
though. That's because this patch is quite large and somewhat prone to merge
conflicts. Also other work we want to do, depends on this.

This adds the following new nodes:
* Combine Bundle: can pack multiple values into one.
* Separate Bundle: extracts values from a bundle.
* Closure Zone: outputs a closure zone for use in the `Evaluate Closure` node.
* Evaluate Closure: evaluates the passed in closure.

Things that will be added soon after this lands:
* Fields in bundles and closures. The way this is done changes with #134811, so
  I rather implement this once both are in `main`.
* UI features for keeping sockets in sync (right now there are warnings only).

One bigger issue is the limited support for lazyness. For example, all inputs of
a Combine Bundle node will be evaluated, even if they are not all needed. The
same is true for all captured values of a closure. This is a deeper limitation
that needs to be resolved at some point. This will likely be done after an
initial version of this patch is done.

Pull Request: https://projects.blender.org/blender/blender/pulls/128340
2025-04-03 15:44:06 +02:00
quackarooni
8a869c20e9 Geometry Nodes: Match String node
Adds "Starts With", "Ends With", and "Compare" string operations as a
standalone node.

Pull Request: https://projects.blender.org/blender/blender/pulls/136021
2025-04-03 02:57:39 +02:00
Cartesian Caramel
ade8576bf7 Geometry Nodes: new Camera Info Node
This adds a new Camera Info node to Geometry Nodes. It provides information
about the passed in camera like its projection matrix and focus distance.

This can be used for camera culling which was must more complex before.
It also allows building other view-dependent effects.

Pull Request: https://projects.blender.org/blender/blender/pulls/135311
2025-03-28 22:54:13 +01:00
Falk David
a910486fe0 Geometry Nodes: Add "Grease Pencil" menu
This adds a new Grease Pencil menu and moves the existing
Grease Pencil related nodes into it.

Pull Request: https://projects.blender.org/blender/blender/pulls/136498
2025-03-25 16:38:18 +01:00