Commit Graph

5120 Commits

Author SHA1 Message Date
Jacques Lucke
b36bf15e28 Geometry Nodes: improve detecting data-block dependencies
Previously, the data-block dependencies were always detected in
`update_depsgraph` in `MOD_nodes.cc`. This would only be called when something
called `DEG_relations_tag_update` before. We don't want to trigger a depsgraph
rebuild after each operation in the node editor, as that would be expensive.
However, that also meant that we often had to add data-block dependencies that
are not actually used, but might be used if the user changed e.g. a link. A
typical example for that is a object socket that has a default value, but the
socket is also linked.

Now, the dependencies referenced by the node tree are collected by the node tree
update code which runs after all changes. This way we can detect whether the
dependencies have changed. Only if they have changed, a depsgraph rebuild is
triggered. This now allows also taking into account the mute status of nodes and
whether an input is linked.

There are still more things that could be taken into account. Most obviously
whether a node is connected to an output. This can be done later. The most
tricky aspect here is probably that we also have to consider all viewer nodes as
output, because at the time the node runs, it's not known which viewer will
actually be used (which depends on other editors).

This also cleans up some special cases we had for e.g. the scene time node where
we always had to trigger a depsgraph rebuild when it was added/removed because
of its time dependence. This is now part of a more general system.

This fixes #109219.

Pull Request: https://projects.blender.org/blender/blender/pulls/131446
2024-12-05 18:02:14 +01:00
Jonas Holzman
6cd33510c3 Nodes: Expose Node Color Tag to the Python API
This commit adds a new `color_tag` read-only enum property to nodes,
expanding on the existing node group `color_tag` property. The existing
node group color tag enum (`NodeGroupColorTag`) was renamed to the more
generic `NodeColorTag` and expanded to support all possible color tags.
This new property also works on node group nodes with custom color tags
set by the user.

Pull Request: https://projects.blender.org/blender/blender/pulls/131101
2024-12-05 17:14:34 +01:00
Omar Emara
6dd2ad061f Compositor: Optimize pixel access in new CPU compositor
Optimize pixel access in the new CPU compositor by specializing pixel
load and store for the type of the result that is being loaded or
stored. Gives up to 10% improvement.

Pull Request: https://projects.blender.org/blender/blender/pulls/131441
2024-12-05 16:55:06 +01:00
Jonas Holzman
a730d5f8ba Nodes: Change Compositing Switch node class from Layout to Converter
Currently, the Layout node class is used by the Reroute, Frame and
Compositing Switch node. To bring more uniformity, and clear up the use
of each class, this commit moves the Compositing Switch node from
the Layout class to the Converter class. This aligns it with similar
nodes (Compositing Split, Compositing Switch View, Geometry Switch)
which use the same class, and limits the Layout class to layout-related
nodes. On the UI side, this also gives the Compositing Switch node a
more relevant header color.

Pull Request: https://projects.blender.org/blender/blender/pulls/131392
2024-12-05 13:13:05 +01:00
Omar Emara
9fcc15f8a6 Fix: Dilate node uses wrong result types
The Dilate node created Color results for its intermediate separable
results, but they should actually be floats.
2024-12-05 13:44:05 +02:00
Hans Goudey
af79b4e7b5 Cleanup: Use constexpr for geometry nodes string, avoid .c_str() 2024-12-04 12:38:00 -05:00
Hans Goudey
19ab63e513 Cleanup: Remove unnecessary namespace specification 2024-12-04 12:38:00 -05:00
Hans Goudey
f9b627d29c Mesh: Move custom normals to a generic attribute
Move `CD_CUSTOMLOOPNORMAL` to the newly added
`CD_PROP_INT16_2D` generic attribute type. This is similar to
previous commits moving specific custom data types.

The attribute name is `custom_normal`. When the attribute with
that name is on the face corner domain, the code will interpret it
as stored in the existing deformation-invariant spherical coordinate
space.

The API remains the same, with the additional opportunity to edit
custom normal data as an attribute directly (which admittedly is fairly
unintuitive currently).

See #130484.

Pull Request: https://projects.blender.org/blender/blender/pulls/130689
2024-12-04 16:06:36 +01:00
quackarooni
65b1ab43bf Geometry Nodes: Add "Collection" and "Object" input nodes
Pull Request: https://projects.blender.org/blender/blender/pulls/131075
2024-12-04 15:01:44 +01:00
Hans Goudey
024d7d12e2 Mesh: Move BVH storage to shared cache system
Avoid rebuilding BVH trees when meshes are copied.
Similar to the other uses of the shared cache system,
this can arbitrarily improve performance when meshes
are copied but not deformed and BVH building is the
main bottleneck. In a simple test file I got a 6x speedup.

The amount of code is also reduced and the system is
much simpler overall-- built out of common threading
patterns like `SharedCache` with its double-checked lock.
RAII is used in a few places to simplify memory management
too.

The downside is storing more `SharedCache` items in the
mesh runtime struct. That has a slight cost when copying
a small mesh many times, but we have ideas to improve that
in the future anyway (#104327).

Pull Request: https://projects.blender.org/blender/blender/pulls/130865
2024-12-04 00:17:17 +01:00
Omar Emara
3b69fe0f40 Fix: Defocus node crashes for single value inputs
The Defocus node crashes for single value inputs, because single values
were not handled. Fix this by handling single values independently.
2024-12-03 12:24:27 +02:00
Omar Emara
1fc9ff4a4e Fix: Variable size Bokeh Blur node crashes
The Variable size Bokeh Blur node crashes due to access to pixels
outside of the image boundary. Fix this by accessing using extended
boundaries.
2024-12-03 12:22:15 +02:00
Bartosz Kosiorek
c37e6290ec UI: Add missing tooltips to Principled BSDF for Sheen and Thin Film
This adds tooltip descriptions for five items in the Principled BSDF
that currently have no descriptions at all. Sheen Weight: "Intensity
of the sheen layer, which simulates very small fibers on the surface".
Sheen Roughness: "Roughness of the sheen layer. Low and high roughness
values produce fuzzy or dusty appearance, respectively". Tint Color:
"Color of the sheen reflection". Thin Film Thickness: "Thickness of the
film in nanometers". Thin Film IOR: "Index of refraction (IOR) of the
thin film".

Pull Request: https://projects.blender.org/blender/blender/pulls/126735
2024-12-03 10:34:20 +01:00
Hans Goudey
56be16b21e Fix: Compile error after recent StringRefNull cleanup 2024-12-02 13:58:28 -05:00
Iliya Katueshenock
7348e670b3 Cleanup: BKE: Use StringRefNull instead of char *
Use StringRefNull for all function arguments and return types.
Not a StringRef but StringRefNull since there is still large
interaction with C api so null-termination usually necessary.

If string is expected to be not only empty but also a null then
optional is used. This change depends on #130935.

Pull Request: https://projects.blender.org/blender/blender/pulls/131204
2024-12-02 19:24:07 +01:00
Omar Emara
7ec9fa680e Compositor: Implement Scale node or new CPU compositor
Reference #125968.
2024-12-02 18:02:38 +02:00
Omar Emara
377d272f72 Fix: Zero division in Tone Map Photoreceptor node 2024-12-02 13:45:35 +02:00
Omar Emara
4eb1b78d82 Fix: Compositor: Compile error with WITH_FFTW3 off 2024-11-29 15:23:49 +02:00
Omar Emara
b71338ba8d Compositor: Implement Glare node for new CPU compositor
Reference #125968.
2024-11-29 15:04:40 +02:00
Omar Emara
a9436b04b8 Fix: Compositor: Crash using Keying node in new CPU compositor
The Keying node crashes in the new CPU compositor because it was writing
to an output that shouldn't be computed and is thus unallocated.
2024-11-28 10:58:14 +02:00
Omar Emara
292ad6b00e Compositor: Implement Keying node for new CPU compositor
Reference #125968.
2024-11-27 19:28:16 +02:00
Omar Emara
0efb0ce48e Compositor: Implement Dilate node for new CPU compositor
Reference #125968.
2024-11-27 19:28:16 +02:00
Omar Emara
8f77e0d7fe Fix: Zero division in Dilate node 2024-11-27 19:28:16 +02:00
Campbell Barton
b9f055459a Cleanup: ensure trailing space around comment blocks 2024-11-27 19:01:00 +11:00
seanterelle
6e9d988018 Geometry Nodes: Add dynamic label to warning node
Implementation of auto-label for the warning node based on the type
(similar to the Math node).

Pull Request: https://projects.blender.org/blender/blender/pulls/131000
2024-11-27 01:41:49 +01:00
Omar Emara
f9420bd58a Compositor: Implement vector Blur for new CPU compositor
Reference #125968.
2024-11-26 16:10:56 +02:00
Omar Emara
43d2538087 Compositor: Implement Inpaint node for new CPU compositor
Reference #125968.
2024-11-26 16:10:56 +02:00
Omar Emara
be19daaa06 Compositor: Implement Directional Blur for new CPU compositor
Reference #125968.
2024-11-26 16:10:56 +02:00
Omar Emara
10e663e001 Compositor: Implement Defocus node for new CPU compositor
Reference #125968.
2024-11-25 16:23:23 +02:00
Omar Emara
da36ba3b8e Compositor: Implement Bokeh Blur for new CPU compositor
Reference #125968.
2024-11-25 16:20:50 +02:00
Campbell Barton
0de8ae8046 Cleanup: spelling in comments 2024-11-25 13:24:46 +11:00
Hans Goudey
ea875f6f32 Geometry Nodes: Port triangulate node from BMesh to Mesh
Add a Mesh implementation of triangulation, which is currently just
implemented for BMesh. The main benefit of this is performance and
decreased memory usage. The benefit is especially large because the
node currently converts to BMesh, triangulates, and then converts back.
But the BMesh implementation is entirely single threaded, so it will
always be much slower.

The new implementation uses the principle of "never just process a
single element at a time" but it also tries to avoid processing _too_
many elements at once, to decrease the size of temporary buffers.
Practically that means the work is organized into chunks of selected
faces, but within each chunk, each task is done in a separate loop.
Arguably I went a bit far with some optimizations, and some of the
complexity isn't necessary, but I hope everything is clear anyway.

Unlike some other Mesh ports like the extrude node or the split edges
code, this generates a new mesh. I still go back and forth on that
aspect, but reusing the same mesh would have required reallocating
face attributes from scratch anyway. Implicit sharing is used to
avoid copying vertex attributes though.

The result mesh is reorganized a bit. Unselected face data comes first,
then selected triangles, then triangulated NGons, then triangulated
quads. This makes attribute interpolation and internal calculations
more efficient.

The "Minimum Vertices" socket is replaced with versioning. In the new
implementation it would have an impact on code complexity, and for a
builtin "atomic" node it makes more sense as part of the selection.

The performance difference depends on the number of CPU threads, the
number of attributes, and the selection size. As all of those numbers
go up, the benefit will grow. The "modes" also affect the performance,
obviously.

With a Ryzen 7950x, I tested performance in a few situations (in ms):
|                            | Selection | Before | After | Change |
| -------------------------- | --------- | ------ | ----- | ------ |
| 1.4 m quads (fixed)        | 50%       | 1533   | 15.9  | 96x    |
| 10 m quads (shortest)      | 100%      | 9700   | 165.0 | 59x    |
| 1 m 10-side Ngons (beauty) | 90%       | 3785   | 115.9 | 33x    |
| 1 m quads many attributes  | 100%      | 54600  | 332.3 | 164x   |

In follow-up commits, I'll move other areas to use mesh triangulation
instead of BMesh. This is the last geometry node using BMesh besides
the Ico Sphere primitive.

Pull Request: https://projects.blender.org/blender/blender/pulls/112264
2024-11-23 00:25:52 +01:00
Omar Emara
fa9bde230b Compositor: Implement Anisotropic Kuwahara for new CPU compositor
Reference #125968.
2024-11-22 16:35:15 +02:00
Omar Emara
01af6ffd22 Compositor: Implement Blur node for new CPU compositor
Reference #125968.
2024-11-22 15:22:32 +02:00
Omar Emara
80a054c15d Compositor: Implement Symmetric Blur Weights for new CPU compositor
Reference #125968.
2024-11-21 16:40:03 +02:00
Omar Emara
0d83aafd4b Compositor: Implement Bilateral Blur for new CPU compositor
Reference #125968.
2024-11-21 16:24:21 +02:00
Omar Emara
8b720eb6ea Compositor: Implement Filter node for new CPU compositor
Reference #125968.
2024-11-21 16:22:43 +02:00
Omar Emara
15cdeae620 Fix: Compile error in Despeckle node for Metal
We can't use the `threshold` uniform name in Metal because it is used as
a local variable in one of the library files, because uniforms are
defines in Metal, so it causes an error. Change the name to
`color_threshold` as a fix.
2024-11-21 09:37:44 +02:00
Omar Emara
e49498a795 Compositor: Implement Classic Kuwahara for new CPU compositor
Reference #125968.
2024-11-20 16:15:49 +02:00
Omar Emara
f4767bea72 Compositor: Implement Pixelate for new CPU compositor
Reference #125968.
2024-11-20 15:56:21 +02:00
Omar Emara
11a5e362d4 Compositor: Implement Denoise for new CPU compositor
Reference #125968.
2024-11-20 15:55:33 +02:00
Omar Emara
5e806db594 Compositor: Implement Despeckle for new CPU compositor
Reference #125968.
2024-11-20 15:53:28 +02:00
Omar Emara
5036c5338b Compositor: Implement Sun Beams for new CPU compositor
Reference #125968.
2024-11-20 15:51:30 +02:00
Jacques Lucke
e62aa986b2 Format: use fmt::format correctly with runtime format strings
The `fmt::format` can process the format string at compile time. Currently, we
don't seem to be using that as we don't use `FMT_STRING`. Starting with C++20,
that will be the default though, and one has to explicitly opt out in places
where the string is not known at compile time using `fmt::runtime(...)`.
Currently, our code does not compile as C++20 because of that. Unfortunately, we
have many places with runtime format strings, because of i18n.

Pull Request: https://projects.blender.org/blender/blender/pulls/130392
2024-11-20 10:41:29 +01:00
Hans Goudey
c57ebc99eb Cleanup: Use StringRef instead of std::string in a few cases
Pull Request: https://projects.blender.org/blender/blender/pulls/130534
2024-11-19 19:47:27 +01:00
Jacques Lucke
1125d6ee15 Cleanup: Attributes: rename AttributeKind to AttributeDomainAndType
There is not really a good definition for what an "attribute kind". There are
many possibilities, it could include domain, type, geometry type, default value,
usage, ...

So it's better not to use this generic name. With the current name, one always
has to look at the definition again to be sure what it contains and what it does
not.

The name `AttributeDomainAndType` is way more explicit and does not have the
same problems. It's a bit longer, but that does not seem to be a problem in the
places where we use it.

Pull Request: https://projects.blender.org/blender/blender/pulls/130505
2024-11-19 14:31:19 +01:00
Omar Emara
54fa1f9bb7 Compositor: Implement Cryptomatte for new CPU compositor
Reference #125968.
2024-11-19 12:47:23 +02:00
Omar Emara
24d1733059 Compositor: Implement Double Edge Mask for new CPU compositor
Reference #125968.
2024-11-18 17:35:22 +02:00
Omar Emara
a8591c9efb Compositor: Implement Box Mask for new CPU compositor
Reference #125968.
2024-11-18 17:35:22 +02:00
Omar Emara
c9e974249e Compositor: Implement Ellipse Mask for new CPU compositor
Reference #125968.
2024-11-18 17:35:22 +02:00