Commit Graph

690 Commits

Author SHA1 Message Date
Omar Emara
149a47ba57 Compositor: Turn Menu options to inputs
This patch turns node Menu options into menu inputs. This patch only
covers node operations like Filter, Distort, and so on. Pixel nodes like
Color Balance, Matte, and so on will be done in a separate patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/144495
2025-08-28 08:45:23 +02:00
Sybren A. Stüvel
b33e372d02 Nodes: ensure tree topology cache is up to date before iterating sockets
Call `ntree->ensure_topology_cache();` to ensure the topology cache is
up to date, before iterating over each node's input sockets.

This is a follow-up of 3016cf650d.

Pull Request: https://projects.blender.org/blender/blender/pulls/145232
2025-08-27 13:27:33 +02:00
Sybren A. Stüvel
3016cf650d Geometry Nodes: implement file path callback for import nodes
Add geometry file import nodes support to the for-each-path logic.
This will make `bpy.data.file_path_map()` report the input files for
OBJ, PLY, etc. import nodes (and any other node that has a string
property of subtype `PROP_FILEPATH`).

Currently this only supports static file paths, so where the file path
is set as the input socket's default value. When the path is
determined via any noodle, this is ignored and the default value is
reported anyway.

This is necessary for the new version of Blender Asset Tracer, which
in turn is needed to resolve studio/flamenco#104423.

Pull Request: https://projects.blender.org/blender/blender/pulls/144874
2025-08-26 11:03:27 +02:00
W_Cloud
24308a9f21 Nodes: Inherit color tag when grouping a single node
The `Ctrl + G` make group operator now inherits the color_tag
from the selected node when only one node is selected.

Pull Request: https://projects.blender.org/blender/blender/pulls/144861
2025-08-21 14:50:19 +02:00
Jacques Lucke
c90a137a27 Nodes: wrap int in MenuValue type for menu sockets
Previously, we always just used `int` when dealing with menu values on the C++
side. It's currently the only type where we have the same base type (`int`) for
two different socket types (integer and menu sockets). This has some downsides:
* It requires special cases in some places.
* There is no function from static base type to socket type (which is useful for
  some utilities like `SocketValueVariant`).
* It implicitly allows operations on menu values that shouldn't be allowed such
  as arithmetic operations and conversions to and from other types.

This patch adds a new `MenuValue` type that is used for menu sockets in Geometry
Nodes and the (CPU) Compositor, clarifying the distinction between integer and
menu values.

Pull Request: https://projects.blender.org/blender/blender/pulls/144476
2025-08-13 15:43:37 +02:00
Jacques Lucke
d954c48d02 Fix #144175: assert when adding texture paint slot
Better type safety would have prevented this..
2025-08-08 10:48:20 +02:00
Omar Emara
68dc278fe5 Compositor: Redesign File Output node
This patch redesigns the File Output node to provide better UX and UI.
This is mainly achieved by allowing the user to create inputs by
dragging into an Extend socket and adjust existing inputs using the
familiar UI list design available in Blender. Additionally, various UI
changes were done:

- The Use Node Format option was renamed to Override Node Format for
  clarity.
- Socket types are now fixed and do not change as new links are made,
  allowing users to specify the exact output type and employ implicit
  conversion if needed.
- The distinction between images and Multi-Layer EXR was made clearer.
- Final output paths are drawn in the UI to remove guess work.
- The Base Path was split into a Directory and a File Name.
- Panels were added to group options, include a panel for the node
  format, items, and item formats.

Pull Request: https://projects.blender.org/blender/blender/pulls/141091
2025-08-07 14:46:34 +02:00
Jacques Lucke
9bf9f587f9 Fix #143983: crash when shader node from properties editor
This just reverts a very small part of 119fc054f8 that caused this regression.

Pull Request: https://projects.blender.org/blender/blender/pulls/144015
2025-08-06 20:11:38 +02:00
Jacques Lucke
8133f7aa13 Fix: crash due to wrong duplicate node name handling
Generally, node names are expected to be unique within a node tree. However,
`ntree_shader_copy_branch` currently does not enforce this for performance
reasons. This was broken by recent changes in 5b73f798d0 and 9fd877e174 which
allows for passing already unique names and identifiers to the node copy
function.

The main problem here was that the `use_unique` parameter of the `node_copy`
function was not well defined. Now, this function is completely removed in favor
of using `node_copy_with_mapping` directly. This also has a new
`allow_duplicate_names` parameter now which makes the expected behavior more
explicit.

Pull Request: https://projects.blender.org/blender/blender/pulls/143951
2025-08-04 19:57:43 +02:00
Jacques Lucke
99984b3b05 Nodes: optimize freeing all nodes
We generally expect `bNodeTreeRuntime::nodes_by_id` to be valid at all times, so
it also has to have the same order `bNodeTree.nodes`. When freeing a node, the
entire vector set was rebuild currently to ensure that invariant. This leads
O(n^2) behavior when all nodes are freed as is commonly the case with depsgraph
copies etc.

This patch implements an optimization where `nodes_by_id` is not rebuild if only
the last node was removed. In this case, that not can just be popped from
`nodes_by_id` without affecting the order of the other nodes. To use this
optimization, the node tree freeing code now frees nodes in reverse order.

Pull Request: https://projects.blender.org/blender/blender/pulls/143831
2025-08-02 12:35:16 +02:00
Jacques Lucke
9fd877e174 Fix: Nodes: copied node not always added to nodes_by_id 2025-08-02 11:34:09 +02:00
Jacques Lucke
5b73f798d0 Refactor: Nodes: allow passing already unique name/identifier to node copy function
This is useful when the src node name is not unique, but the caller can provide
a unique name more efficiently then if the function has to compute the name
automatically.
2025-08-02 11:02:10 +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
76a861ab41 Geometry Nodes: move more menu inputs to sockets
This is a continuation of #140705. It changes more menu node options to be input
sockets. It also changes the order of the input sockets in a few cases to make
the node look a bit better.

Forward and backward compatibility is preserved.

Pull Request: https://projects.blender.org/blender/blender/pulls/142220
2025-07-30 15:32:10 +02:00
Campbell Barton
649b89781e Cleanup: ensure UTF8 string copy for DNA & screen data
Use `BLI_strncpy_utf8` & `BLI_snprintf_utf8` for fixed size buffers in
DNA and screen data structures such as panels, menus & operators.

This could be considered a fix as copying a UTF8 string into a smaller
buffer without proper truncation can create an invalid UTF8 sequence.
However identifying which of these users are likely to run into would
be time consuming and not especially useful.
2025-07-26 12:33:15 +00:00
Jacques Lucke
2e48d33101 Geometry Nodes: improve internal bundle api
This extends the API for bundles in two main ways:
* Adds support for working with paths to reference nested bundles directly.
* Adds support for typed add/lookup, also taking into account implicit conversions.

Some unit tests have been added as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/142942
2025-07-23 11:23:32 +02:00
Jacques Lucke
f7f18cd0c7 Nodes: initial support for built-in menu sockets
So far, only node group were able to have menu input sockets. Built-in nodes did
not support them. Currently, all menus of built-in nodes are stored on the node
instead of on the sockets. This limits their flexibility because it's not
possible to expose these inputs.

This patch adds initial support for having menu inputs in built-in nodes. For
testing purposes, it also changes a couple built-in nodes to use an input socket
instead of a node property: Points to Volume, Transform Geometry, Triangulate,
Volume to Mesh and Match String.

### Compatibility

Forward and backward compatibility is maintained where possible (it's not
possible when the menu input is linked in 5.0). The overall compatibility
approach is the same as what was done for the compositor with two differences:
there are no wrapper RNA properties (not necessary for 5.0, those were removed
for the compositor already too), no need to version animation (animation on the
menu properties was already disabled).

This also makes menu sockets not animatable in general which is kind of brittle
(e.g. doesn't properly update when the menu definition changes). To animate a
menu it's better to animate an integer and to drive an index switch with it.

### Which nodes to update?

Many existing menu properties can become sockets, but it's currently not the
intention to convert all of them. In some cases, converting them might restrict
future improvements too much. This mainly affects Math nodes.

Other existing nodes should be updated but are a bit more tricky to update for
different reasons:
* We don't support dynamic output visibility yet. This is something I'll need to
  look into at some point.
* They are shared with shader/compositor nodes, which may be more limited in
  what can become a socket.
* There may be performance implications unless extra special cases are
  implemented, especially for multi-function nodes.
* Some nodes use socket renaming instead of dynamic socket visibility which
  isn't something we support more generally yet.

### Implementation

The core implementation is fairly straight forward. The heavy lifting is done by
the existing socket visibility inferencing. There is a new simple API that
allows individual nodes to implement custom input-usage-rules based on other
inputs in a decentralized way.

In most cases, the nodes to update just have a single menu, so there is a new
node-declaration utility that links a socket to a specific value of the menu
input. This internally handles the usage inferencing as well as making the
socket available when using link-drag-search.

In the modified nodes, I also had to explicitly set the "main input" now which
is used when inserting the node in a link. The automatic behavior doesn't work
currently when the first input is a menu. This is something we'll have to solve
more generally at some point but is out of scope for this patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/140705
2025-07-16 08:31:59 +02:00
Brecht Van Lommel
8d8e61fefd Logging: Change various categories and log levels
* Remove bke, ed and wm prefixes
* Add prefixes like: geom, object, blend, lib.
* Shorten some category names
* A few log level changes to improve --log-level info output

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Omar Emara
fd24e1001a Refactor: Move contextual init before socket declaration
Currently, the standard init function is called before socket
declaration, but the contextual init function is called after, which is
problematic if the declaration depends on the initialization step. This
patch moves the contextual init function to be called before declaration
just like the standard init function.

This is needed when moving the File Output node to use socket
declaration.

Pull Request: https://projects.blender.org/blender/blender/pulls/141203
2025-06-30 18:47:09 +02:00
Habib Gahbiche
f2d95e758d Fix: Crash when opening files with animated compositor normal node
Saved files in 4.5 with a compositing node tree containing a Normal
Node with animated 'Dot' input crash in 5.0.

A test case with animated dot and normal inputs was added as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/140908
2025-06-25 11:04:29 +02:00
Omar Emara
3ba4d8f58d Compositor: Remove Vector Curves node
This patch removes the Vector Curves node that was deprecated in 4.5 and
was planned for removal in 5.0. The common Shading Vector Curves node
should be used instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/140529
2025-06-17 12:14:39 +02:00
Bastien Montagne
9a41dc73f9 Merge branch 'blender-v4.5-release' 2025-06-16 18:49:45 +02:00
Bastien Montagne
2e5b4a120a Fix #140083: Nodes: Never attempt to read default value from custom socket.
Pull Request: https://projects.blender.org/blender/blender/pulls/140459
2025-06-16 18:48:19 +02:00
Omar Emara
35d21bd9d7 Compositor: Remove forward compatibility code
This patch removes the forward compatibility code for the compositor
that was introduced in 4.x and planned for removal in 5.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/140458
2025-06-16 12:38:45 +02:00
Brecht Van Lommel
b920f6f1a7 Shaders: Remove point density texture node
This is replaced by geometry nodes, where volumes can now be generated from
point clouds and meshes with more control, and more efficient rendering as a
sparse volume.

No backwareds compatibility is provided, as this would be complicated, and
probably this feature was not used much in the past few years.

This node was supported in Cycles only, not by EEVEE.

Pull Request: https://projects.blender.org/blender/blender/pulls/140292
2025-06-16 12:06:02 +02:00
Omar Emara
cf9c419fba Merge branch 'blender-v4.5-release' 2025-06-13 12:17:33 +03:00
Omar Emara
b62ef2cdd6 Compositor: Add forward compatibility for removed storage
This patch removes node init functions that currently exist only for
forward compatibility and moves the logic to the forward compatibility
section of node writing. This is to avoid allocating unused data
throughout the 5.x series.

Pull Request: https://projects.blender.org/blender/blender/pulls/140273
2025-06-13 11:15:51 +02:00
Habib Gahbiche
bd61e69be5 Compositor: make compositor node trees reusable
This is part of the short term roadmap goal of simplifying the
compositor workflow
(see https://projects.blender.org/blender/blender/issues/134214).
The problem is that many users don't know how to get started with
compositing in Blender, even when they have used Blender for other
areas, e.g. modeling.

Note: although the solution makes compositor node trees reusable
accross blend files, this is a nice side effect and not the main goal
of the PR.

This PR implements a "New" button that creates a new compositing node
tree, and manages trees as IDs. This has following advantages:
- Consistent with other node editors and other parts of Blender,
therefore making it easier to getting started with compositing if users
are familiar with shading or geometry nodes
- Give users the ability to reuse the compositing node tree by linking
or appending it.

Note: The parameter "Use Nodes" is still present in this PR, but will
be removed (in a backward compatible way) in a follow up PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/135223
2025-06-10 17:46:55 +02:00
Jacques Lucke
3afc1cbbe1 Refactor: Nodes: change int to enum for bNodeSocketType.type
This eliminates the need for explicit type casts in many places.

Pull Request: https://projects.blender.org/blender/blender/pulls/139710
2025-06-02 13:50:07 +02:00
Omar Emara
425be6bb02 Compositor: Turn Flip node options to inputs
This patch turns the Flip node options to inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/139722
2025-06-02 12:48:00 +02:00
Hans Goudey
b80f1f5322 Geometry Nodes: Socket structure type and display changes
Implementation of #127106.
This is just a visual representation of the field/single/grid
status of sockets to make the workflow more intuitive. With
a visual representation for volume grid sockets, volume features
should be unblocked for further development. The structure type
will also be used to distinguish list sockets in the interface.

Group input nodes now have a "Structure Type" option instead of
the existing "Single Value Only". Usually the auto option should be
enough, but in some cases where the inferencing cannot (yet) make
a clear determination, it can be helpful to choose a specific type.

The new visualization and the group input structure type option
are hidden behind a new experimental option for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/134811
2025-05-28 02:33:47 +02:00
Hans Goudey
e19fead49d Cleanup: Nodes: Remove always-null arguments
Pull Request: https://projects.blender.org/blender/blender/pulls/139505
2025-05-27 23:05:38 +02:00
Jacques Lucke
1a4c16a784 Geometry Nodes: initialize String node when using link-drag-search
This is similar to how Value/Vector/Integer/... nodes are automatically
initialized when they are created using link-drag-search.

Strings require some special case handling here but that seems fine. The
`node_socket_move_default_value` function is already fairly specific for the
different value nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/139478
2025-05-27 17:05:32 +02:00
Omar Emara
bab308bfa2 Compositor: Turn Blur node options to inputs
This patch turns the Blur node options to inputs.

Size is now a 2D vector and replaces the Size X and Y option. Bokeh was
renamed to Separable to reflect its actual function. Relative was
removed in favor of the newly added Relative To Pixel node workflow.

There is a slight difference in variable size blurring due to float vs
integer computations, so two tests were updated.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/139329
2025-05-26 16:18:48 +02:00
Omar Emara
02a95d088e Nodes: Add support for 2D and 4D vector sockets
This patch adds support for 2D and 4D vector sockets. The default value
structure for vectors was extended to include a new dimensions input,
which can be 2, 3, or 4. The default value was also extended to be a
float4, but only some of its components might be used depending on the
dimensions members.

Each vector subtype now has three variants ending with 2D or 4D as a
prefix depending on its dimensions, and the 2D/4D prefix was taken into
account for the socket type RNA enum functions.

All node systems currently always treat the vectors as 3D, but support
for it in the compositor will shortly follow in another patch.

Depends on #138805.

Pull Request: https://projects.blender.org/blender/blender/pulls/138824
2025-05-26 11:41:54 +02:00
Omar Emara
6c62fb5ff6 Compositor: Turn Color Balance options to inputs
This patch turns the options of the Color Balance node into inputs.

In the process, each of the wheels were split into two inputs, a base
float and a color. For instance, Gain is controlled using both a Base
Gain and Color Gain, the former controls the gain for all channels while
the latter controls it per channel.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138610
2025-05-23 15:42:54 +02:00
Campbell Barton
99a4c93081 Cleanup: inline array sizes in code-comments
Use a similar convention for struct member identifiers,
(the identifiers without surrounding spaces). This allows the values
to be scanned and validated.
2025-05-23 00:41:39 +10:00
Jacques Lucke
afe57f6598 Fix: unintentional fall-through in switch statement 2025-05-22 04:56:05 +02:00
Campbell Barton
e5deeafe92 Cleanup: spelling in comments (make check_spelling_*) 2025-05-22 11:11:48 +10:00
Campbell Barton
0bd62779e8 Cleanup: various non-functional changes for C++ 2025-05-22 01:01:08 +00:00
Campbell Barton
d603d872b9 Cleanup: quiet missing-declarations warning 2025-05-22 01:01:06 +00:00
Bastien Montagne
4397fa5056 Refactor: Convert Node Socket Default Value and Storage readfile code to typed DNA handling.
For default values, the fairly complex reasoning for the code is explained
in details in comments. The TL;DR: would be that this code is needed to
safely load blendfiles older than 2.83, which were saved without any DNA
type information for these default value data.

Storage data have always been written with DNA info (added in commits
3bae60d0c9 and 9d91bc38d3), so no need to add special handling for them.
Just use regular DNA struct reading.

Pull Request: https://projects.blender.org/blender/blender/pulls/139175
2025-05-21 18:47:31 +02:00
Omar Emara
14f7faf283 Compositor: Turn Crop node options to inputs
This patch turns the options of the Crop node into inputs.

Instead of specifying the bounds of the crop, the inputs now specify the
Width and Height of the crop region. The Crop Image Size option was
renamed to Alpha Crop and inverted, so it now defaults to actual
cropping. The Relative option was removed, as it is now superseded by
the Relative To Pixel node, and removal was done to facilitate the
options to inputs project.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/139163
2025-05-21 11:01:25 +02:00
Omar Emara
79d37720de Nodes: Add Factor and Percentage subtypes for vector sockets
This patch adds support for the Factor and Percentage subtypes for
vector sockets. This is needed by the compositor, since it has some node
inputs that specify locations and sizes relative to image size, and
having factor and percentage subtypes for those improves the UX quite a
bit according to user feedback.

Pull Request: https://projects.blender.org/blender/blender/pulls/138805
2025-05-15 08:29:41 +02:00
Omar Emara
0cee690de3 Fix: String file path interface socket has wrong type
The string interface sockets with a file path subtype are assigned a
vector translation type, which is probably a typo in the original
implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/138803
2025-05-13 10:56:56 +02:00
Jacques Lucke
23d5ae7da5 Refactor: Nodes: decentralize node storage blend read/write
Previously, whenever a node had a non-trivial storage struct, there would have
to be code for it in `node.cc`. Now there is a general callback that new node
types can use to implement their blend read/write behavior.

Some existing nodes were converted to use this decentralized method. However,
some older nodes can't use it in the same way, because the node types were
introduced before there were node idnames. It's also somewhat hard to reason
about special cases that versioning code might have for these nodes, so they
remain unchanged.

The node callback only writes the non-trivial data, while the main node storage
struct is written automatically by relying on `bNodeType::storagename`. This
simplifies the callback in many cases or makes it unnecessary for trivial types.

Some nodes have specific handling for forward-compatibility. This
forward-compatibility code is kept in `node.cc` for now, because it also affects
the main storage struct and therefore has to be changed before that struct is
written.

Pull Request: https://projects.blender.org/blender/blender/pulls/138722
2025-05-13 07:00:03 +02:00
Omar Emara
fd3ca68b5e Compositor: Turn Bokeh Blur options to inputs
This patch turns the options of the Bokeh Blur node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138664
2025-05-09 14:15:14 +02:00
Campbell Barton
fd6ac498b0 Cleanup: spelling in comments, strings (make check_spelling_*)
Also replace some triple-quoted non-doc-string strings with commented
blocks in examples.
2025-05-06 00:18:39 +00:00
Jacques Lucke
e09ccc9b35 Core: add templated version of BKE_id_new_nomain to reduce explicit casting
This adds a version of `BKE_id_new_nomain` that takes the ID type parameter as
template argument. This allows the function the return the newly created ID with
the correct type, removing the need to use `static_cast` on the call-site.

To make this work, I added a static `id_type` member to every ID struct. This
can also be used to create a similar API for other id management functions in
future patches.

```cpp
// Old
Mesh *mesh = static_cast<Mesh *>(BKE_id_new_nomain(ID_ME, "Mesh"));

// New
Mesh *mesh = BKE_id_new_nomain<Mesh>("Mesh");
```

Pull Request: https://projects.blender.org/blender/blender/pulls/138383
2025-05-05 18:41:03 +02:00
Omar Emara
1f51172692 Compositor: Turn Alpha Over options to inputs
This patch turns the options of the Alpha Over node into inputs.

In the process, Convert Premultiplied option was renamed to Straight
Alpha.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138441
2025-05-05 14:16:27 +02:00