Restriction of the nodes api to clearly define never-null function arguments.
Side effects: some assertions and null-check (with early return) were removed.
On the caller side is ensured to never derefer null to pass argument (mainly in RNA).
In addition, one pointer argument now actually a return type.
By-reference return types instead of pointers going to be separate kind of
change since also imply of cleaning up variables created from reference.
Also good future improvement would be to mark a copy-constructor as
explicit for DNA node types.
Pull Request: https://projects.blender.org/blender/blender/pulls/134627
The compositor crashes when the active viewer layers is deleted and
replaced by a new layer. That's because the depsgraph of the compositor
still references the old view layer. To fix this, we need to update the
view layer of the compositor if it changed since it was last created.
Pull Request: https://projects.blender.org/blender/blender/pulls/134326
When active node is clicked again, the image editor does not update and
keeps showing the old image. Always run `ED_space_image_sync`, when
clicked node is image texture node to resolve this issue.
Pull Request: https://projects.blender.org/blender/blender/pulls/133956
This patch allows the compositor context to specify exactly which
outputs it needs, selecting from: Composite, Viewer, File Output, and
Previews. Previously, the compositor fully executed if any of those were
needed, without granular control on which outputs are needed exactly.
For the viewport compositor engine, it requests Composite and Viewer,
with no Previews or File Outputs.
For the render pipeline, it requests Composite and File Output, with
node Viewer or Previews.
For the interactive compositor, it requests Viewer if the backdrop is
visible or an image editor with the viewer image is visible, it requests
Compositor if an image editor with the render result is visible, it
requests Previews if a node editor has previews overlay enabled. File
outputs are never requested.
Pull Request: https://projects.blender.org/blender/blender/pulls/133960
This uses the following accessor methods in more places in more places:
`is_group()`, `is_group_input()`, `is_group_output()`, `is_muted()`,
`is_frame()` and `is_reroute()`.
This results in simpler code and reduces the use of `bNode.type_legacy`.
Pull Request: https://projects.blender.org/blender/blender/pulls/132899
`BKE_main_ensure_invariants` was added in 1fae5fd8f6. The older
`ED_node_tree_propagate_change` was already implemented as a thin wrapper around
`BKE_main_ensure_invariants`. This patch removes the wrapper and calls the more
general function directly.
A new overload of `BKE_main_ensure_invariants` is added for the common case when
only a single data-block has been modified.
Pull Request: https://projects.blender.org/blender/blender/pulls/133048
This patch adds a new `BKE_main_ensure_invariants` function. For now it only
ensures node-tree related invariants, but more may be added over time.
The already existing `ED_node_tree_propagate_change` now internally calls
`BKE_main_ensure_invariants`. We can probably remove this indirection at some
point and call the new function directly, but for now it is kept to keep this
patch small.
This is based on a recent discussion in the Core module meeting:
https://devtalk.blender.org/t/2024-12-12-core-meeting/38074
```cpp
/**
* Makes sure that invariants in original DNA data are maintained after changes.
*
* This function has to be idempotent, i.e. after calling it once, additional calls should not
* modify DNA data further. If it would, it would imply that this function does more than
* maintaining invariants.
*
* This has to be called after any kind of change to original DNA data that may be involved in some
* of the maintained invariants. It's possible to do multiple changes in a row and then fixing all
* invariants with a single call in the end. Obviously, the invariants are not maintained in the
* meantime then and functions relying on them might not work.
*
* If nothing is changed, this function does nothing and it should not be slower than checking a
* flag on every data-block in the given bmain.
*
* Sometimes, it is known that only a single or very few data-blocks have been changed (e.g. when a
* node has been inserted in a node tree). Passing in #modified_ids can speed up the function
* because it may avoid the need to iterate over all data-blocks to find modified data-blocks.
*
* Examples of maintained invariants:
* - Group nodes need to have the correct sockets based on the referenced node group.
* - The geometry nodes modifier needs to have the correct inputs based on the referenced group.
*/
void BKE_main_ensure_invariants(Main &bmain,
std::optional<blender::Span<ID *>> modified_ids = std::nullopt);
```
This also adds `windowmanager` as a dependency of `blenkernel` to be able to
send notifiers.
Pull Request: https://projects.blender.org/blender/blender/pulls/132023
Main goals of this refactor:
* Make it more obvious which update function should be used.
* Make it more obvious which parameters are required by using references instead
of pointers.
* Support passing in multiple modified trees instead of just a single one.
No functional changes are expected.
Pull Request: https://projects.blender.org/blender/blender/pulls/132862
The new description for `bNode.type_legacy`:
```
/**
* Legacy integer type for nodes. It does not uniquely identify a node type, only the `idname`
* does that. For example, all custom nodes use #NODE_CUSTOM but do have different idnames.
* This is mainly kept for compatibility reasons.
*
* Currently, this type is also used in many parts of Blender, but that should slowly be phased
* out by either relying on idnames, accessor methods like `node.is_reroute()`.
*
* A main benefit of this integer type over using idnames currently is that integer comparison is
* much cheaper than string comparison, especially if many idnames have the same prefix (e.g.
* "GeometryNode"). Eventually, we could introduce cheap-to-compare runtime identifier for node
* types. That could mean e.g. using `ustring` for idnames (where string comparison is just
* pointer comparison), or using a run-time generated integer that is automatically assigned when
* node types are registered.
*/
```
Pull Request: https://projects.blender.org/blender/blender/pulls/132858
The part that used the context does not seem to be necessary anymore. If the
given tree has any update tag set, the same notifiers will be sent anyway by the
`tree_changed_fn` callback.
If it turns out that we are now missing some notifier, then we have to change
the caller. It either has to call the proper `BKE_ntree_update_tag_*` function,
or create the notifier directly.
This change helps to generalize the concept of propagating changes in original
data, because the context is rarely available.
Pull Request: https://projects.blender.org/blender/blender/pulls/132810
Make the type structs non-trivial, use new and delete for allocation and
freeing, and use std::string for most strings they contain. Also use
StringRef instead of char pointers in a few places. Mainly this improves
ergonomics when working with the strings.
Pull Request: https://projects.blender.org/blender/blender/pulls/132750
When "Developer Extras" is disabled, the experemental options
must not be used.
Some checks for experemental options weren't using the macro which
checks both are set.
Add comment to avoid this happening in the future.
Currently each node's position is stored in the coordinate space of
its parent. To find the location of a node on the canvas, we have to
apply the translation of each of its parents. Also, nodes have hidden
"offset" values used while transforming frame nodes. Together,
those made the system much more complicated than necessary,
and they made the Python API ineffective.
This commit removes usage of the offset values and moves nodes
to be stored in the "global" space of the node canvas. It also resolves
some weird behavior when resizing frame nodes, and fixes a few bugs.
The change is forward compatible, so we still write files with nodes in
the old parent-space format. In 5.0 the conversion when writing can be
removed. The existing Python API also stays the same. A new
"location_absolute" property gives node locations in global space,
and changing the old property also moves the child nodes of frames.
Resolves#92458, #72904.
Pull Request: https://projects.blender.org/blender/blender/pulls/131335
Add a new shader specifically for node sockets rather than using the
keyframe shader.
Motivation:
1. Allow easier addition of new socket shapes
2. Simplify socket drawing by avoiding special handling of multi-inputs
3. Support multi-inputs for all socket types (diamond, square, etc.)
The new shader is tweaked to look the same to the old ones.
**Comparison**
The biggest difference is that the multi socket is now more consistent
with the other sockets.
For single sockets there can be small size differences depending on zoom
level because the old socket shader always aligned the sockets to the
pixel grid. This could cause a bit of jiggling compared to the rest of
the node when slowly zooming. Therefore I left it out of the new shader
and it now scales strictly linear with the view.
**Multi Socket Types**
While there currently is no need for (.) internally, there are a few
obvious use-cases for multi-input field (diamond) sockets like
generalized math nodes with an arbitrary number of inputs (Add,
Multiply, Minimum etc.).
Co-authored-by: Jacques Lucke <jacques@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119243
NOTE: This also required some changes to Cycles code itself, who is now
directly including `BKE_image.hh` instead of declaring a few prototypes
of these functions in its `blender/utils.h` header (due to C++ functions
names mangling, this was not working anymore).
Pull Request: https://projects.blender.org/blender/blender/pulls/130174
For C/C++ doc-strings should be located in headers,
move function comments into the headers, in some cases merging
with existing doc-strings, in other cases, moving implementation
notes into the function body.
Send a WM notifier when deleting a node from a node tree/group. Removing
a node also removes its animation data, and thus animation editors need
to receive a notification to refresh.
Pull Request: https://projects.blender.org/blender/blender/pulls/128255
Previously, it was possible to get an invalid zone by copying e.g. the Simulation Input.
Now, whenever copying only one zone node, the other one will automatically be selected
as well. This effectively avoids the dangling zone node.
The same happens already when deleting and grouping nodes.
There are still ways to get dangling zone nodes, especially from Python.
Use snake style naming for all the kernel nodes functions.
Omit kernel prefix in the names since of the using namespace.
Use full forms of the terms
('iter' -> 'iterator', 'ntree' -> 'node_tree', 'rem' -> 'remove', ...).
Pull Request: https://projects.blender.org/blender/blender/pulls/126416
This patch introduces a new experimental option for the new CPU
compositor under development. This is to make development easier such
that it happens directly in main, but the compositor is not expected to
work and will probably crash.
Pull Request: https://projects.blender.org/blender/blender/pulls/125960
Previously, values for `ID.flag` and `ID.tag` used the prefixes `LIB_` and
`LIB_TAG` respectively. This was somewhat confusing because it's not really
related to libraries in general. This patch changes the prefix to `ID_FLAG_` and
`ID_TAG_`. This makes it more obvious what they correspond to, simplifying code.
Pull Request: https://projects.blender.org/blender/blender/pulls/125811
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.
It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.
Pull Request: https://projects.blender.org/blender/blender/pulls/124469
Masks are not updated when edited when using the GPU compositor. That's
because the GPU compositor caches static resources and invalidates them
according to the recalculate flags that the depsgraph flushes to IDs.
The issue is that the flags are not flushed to the evaluated IDs of the
compositor depsgraph, but rather to some other evaluated versions of the
IDs.
To fix this, we make the compositor depsgraph persistent and store it in
the scene runtime. This allows us to reliably track changes to resources
used by the compositor and also reduces the overhead of depsgraph
creation in the compositor job.
Patch originally provided by Sergey.
Fixes#121188.
Pull Request: https://projects.blender.org/blender/blender/pulls/123085
Blender crashes when toggling the compositor device from CPU to GPU.
This is because when submitting the compositor job, the device might be
set to CPU, so GPU related data are not initialized in the job, but
between the time the job is submitted and the time it gets executed, the
device might change to GPU, which then tries to accept the uninitialized
GPU data from the job.
To fix this, we use the evaluated scene from the depsgraph since it
captures the state of the scene used in the job initialization.
Pull Request: https://projects.blender.org/blender/blender/pulls/122661
Blender crashes when the interactive GPU compositor is running in a node
editor while rendering. This is because the GPU compositor is sharing
the same GPU context used for rendering, which is not allowed. To fix
this, we use a dedicated render list for interactive compositing, to use
its dedicated GPU context.
This is implemented by keeping another render list for the purpose of
compositing and similarly clearing its context when it is no longer
needed.
Pull Request: https://projects.blender.org/blender/blender/pulls/122472
This patch makes it such that the GPU context required for the
compositor is only created when the GPU compositor is in use. This
should fix#121761 for the CPU compositor, but generally also make the
CPU compositor more robust to such errors in the future, and a tiny bit
faster since context creation is skipped.
Pull Request: https://projects.blender.org/blender/blender/pulls/122420
Remove the button "Update Views" that requires the user to update visible views manually. This is now consistent with the automatic update of compositor tree, when views are added or deleted, see #120685.
The patch also addresses #109866 (not really a fix since behavior in that bug report is intentional).
Pull Request: https://projects.blender.org/blender/blender/pulls/122290
This patch adds support for timing GPU compositor executions. This was
previously not possible since there was no mechanism to measure GPU
calls, which is still the case. However, since 2cf8b5c4e1, we now flush
GPU calls immediately for interactive editing, so we can now measure the
GPU evaluation on the host, which is not a very accurate method, but it
is better than having no timing information. Therefore, timing is only
implemented for interactive editing.
This is different from the CPU implementation in that it measures the
total evaluation time, including any preprocessing of the inputs like
implicit type conversion as well as things like previews.
The profiling implementation was moved to the realtime compositor since
the compositor module is optional.
Pull Request: https://projects.blender.org/blender/blender/pulls/122230
The issue originates to the change in default view transform from Filmic
to AgX, which does slightly different clipping, and clips color to black
if there is any negative values.
This change implements an idea of skipping view transform for viewer
node when it is connected to the Pick output of the cryptomatte node.
It actually goes a bit deeper than this and any operation can tag its
result as a non-color data, and the viewer node will respect that.
It is achieved by passing some extra meta-data along the evaluation
pipeline. For the CPU compositor it is done via MetaData, and for the
GPU compositor it is done as part of Result.
Connecting any other node in-between of viewer and Cryptomatte's Pick
will treat the result as color values, and apply color management.
Connecting Pick to the Composite output will also consider it as color,
since there is no concept of non-color-managed render result.
An alternative approaches were tested, including:
- Doing negative value clamping at the viewer node.
It does not work for legacy cryptomatte node, as it needs to have
access to original non-modified Pick result.
- Change the order of components, and store ID in another channel.
Using one of other of Green or Blue channels might work for some view
transforms, but it does not work for AgX.
Using Alpha channel seemingly works better, but it is has different
issues caused by the fact that display transform de-associates alpha,
leading to over-exposed regions which are hard to see in the file from
the report. And might lead to the similar issues as the initial report
with other objects or view transforms.
- Use positive values in the Pick channel.
It does make things visible, but they are all white due to the nature
of how AgX works, making it not so useful as a result.
Pull Request: https://projects.blender.org/blender/blender/pulls/122177
Previously, when dropping a node on a link with incompatible sockets, the link
would be removed. While sometimes useful in super simple setup, it is generally
useless for most work. Even worse, users might not notice that they accidentally
removed a link (this has been reported in the recent geometry nodes workshop).
This patch changes this behavior in two ways:
* A node can't be inserted onto an incompatible link anymore.
* A link will be dimmed while dragging a node over it, if it is incompatible or if
alt is pressed.
Pull Request: https://projects.blender.org/blender/blender/pulls/121975
When not all links connecting to a multi-input socket are duplicated
with the multi-input, the link position needs to be updated to avoid
the links being offset.
Pull Request: https://projects.blender.org/blender/blender/pulls/122074
Effectively, make GPU compositor available without need to enable
an experimental feature set.
The compositor device is now exposed in the Performance panel of
Render Buttons. It is also still available in the compositor's
N-panel, together with some other options which are more about how
editing works, and not exactly related to render performance.
Pull Request: https://projects.blender.org/blender/blender/pulls/121398
Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.
Pull Request: https://projects.blender.org/blender/blender/pulls/121637
This allows to expose these settings in the Performance panel in the
render buttons. Also moves compositor-specific options away from the
generic node tree structure.
For the backwards-compatibility the options are still present in the
DNA for the bNodeTree. This is to minimize the impact on the Studio
which has used the GPU compositor for a while now. They can be
removed in a future release.
There is no functional changes expected.
Pull Request: https://projects.blender.org/blender/blender/pulls/121583
It was meant to be included into the previous commit in the area,
but was forgotten due to some technicalities.
Also remove the DisplaceSimpleOperation, which is now not used.
Pull Request: https://projects.blender.org/blender/blender/pulls/121580