Commit Graph

4445 Commits

Author SHA1 Message Date
Omar Emara
ce2a945dff Cleanup: Correctly name bokeh blur shaders
The bokeh blur shaders are incorrectly named as standard blur shaders,
while this isn't the case. Rename them to include the bokeh keyword.
2024-02-02 13:15:59 +02:00
Philipp Oeser
79a7bdf33e Cleanup: remove empty statements 2024-02-02 11:57:51 +01:00
Jacques Lucke
7d3003be4d Geometry Nodes: store bake item names on disk
Bake items are generally identified by their (generated) identifier.
This allows changing the name and reordering sockets without breaking
baked data.

In the future we want to have some kind of Import Bake node that
ideally automatically creates its output sockets and names them correctly.
For that to work, the baked data has to contain the user-defined names
for each socket. Those names are not used yet.
2024-02-02 10:02:25 +01:00
Hans Goudey
dccf0e8699 Cleanup: Move GPU_material.h to C++ 2024-02-01 10:40:30 -05:00
Jacques Lucke
153caeff4d Geometry Nodes: simplify default label in zone nodes
This removes the "Input" and "Output" part of the default label in the
simulation and repeat zone. The outline already makes it very obvious
which one is the input and which one the output. Simplifying the label
makes the zone look prettier. It might also simplify naming other zones
(like for-each zone) in the future, because the name is shorter.

Pull Request: https://projects.blender.org/blender/blender/pulls/117724
2024-02-01 15:20:05 +01:00
Hans Goudey
f4867c0d70 Geometry Nodes: Add Rotate Rotation node
This is meant as a replacement for the Rotate Euler node. Overall it
should be more performant, and the clarity given by the separate socket
type should help distinguish its purpose.

The Rotate Euler node is removed from search and the add menu by this
commit. In the future it can be versioned away. That isn't done now to
avoid a breaking API change and to make this commit less risky.

Pull Request: https://projects.blender.org/blender/blender/pulls/116106
2024-02-01 14:29:30 +01:00
Jacques Lucke
dbe2c2707c Geometry Nodes: extract separate geometry code to separate file 2024-02-01 13:33:06 +01:00
Jacques Lucke
fcc17780a8 Geometry Nodes: extract geometry transform functions to separate file 2024-02-01 13:18:39 +01:00
Jacques Lucke
7042db684f Cleanup: move some geometry field inputs to more correct header 2024-02-01 12:43:39 +01:00
Jacques Lucke
70465387cd Cleanup: merge simulation input and output nodes and extract mix geometries function
The simulation input and output node are closely related and also share some code.
That's easier to handle if they are in the same file.

I also extracted out the code to mix geometries.

Pull Request: https://projects.blender.org/blender/blender/pulls/117713
2024-02-01 11:16:29 +01:00
Jacques Lucke
61c3dbc297 Cleanup: Geometry Nodes: merge repeat zone node files
This nodes belong quite closely together.
2024-02-01 10:50:29 +01:00
Jacques Lucke
2d2b087fcf Geometry Nodes: support baking data block references
With this patch, materials are kept intact in simulation zones and bake nodes
without any additional user action.

This implements the design proposed in #108410 to support referencing
data-blocks (only materials for now) in the baked data. The task also describes
why this is not a trivial issue. A previous attempt was implemented in #109703
but it didn't work well-enough.

The solution is to have an explicit `name (+ library name) -> data-block`
mapping that is stored in the modifier for each bake node and simulation zone.
The `library name` is necessary for it to be unique within a .blend file. Note
that this refers to the name of the `Library` data-block and not a file path.
The baked data only contains the names of the used data-blocks. When the baked
data is loaded, the correct material data-block is looked up from the mapping.

### Automatic Mapping Generation

The most tricky aspect of this approach is to make it feel mostly automatic.
From the user point-of-view, it should just work. Therefore, we don't want the
user to have to create the mapping manually in the majority of cases. Creating
the mapping automatically is difficult because the data-blocks that should
become part of the mapping are only known during depsgraph evaluation. So we
somehow have to gather the missing data blocks during evaluation and then write
the new mappings back to the original data.

While writing back to original data is something we do in some cases already,
the situation here is different, because we are actually creating new relations
between data-blocks. This also means that we'll have to do user-counting. Since
user counts in data-blocks are *not* atomic, we can't do that from multiple
threads at the same time. Also, under some circumstances, it may be necessary to
trigger depsgraph evaluation again after the write-back because it actually
affects the result.

To solve this, a small new API is added in `DEG_depsgraph_writeback_sync.hh`. It
allows gathering tasks which write back to original data in a synchronous way
which may also require a reevaluation.

### Accessing the Mapping

A new `BakeDataBlockMap` is passed to geometry nodes evaluation by the modifier.
This map allows getting the `ID` pointer that should be used for a specific
data-block name that is stored in baked data. It's also used to gather all the
missing data mappings during evaluation.

### Weak ID References

The baked/cached geometries may have references to other data-blocks (currently
only materials, but in the future also e.g. instanced objects/collections).
However, the pointers of these data-blocks are not stable over time. That is
especially true when storing/loading the data from disk, but also just when
playing back the animation. Therefore, the used data-blocks have to referenced
in a different way at run-time.

This is solved by adding `std::unique_ptr<bake::BakeMaterialsList>` to the
run-time data of various geometry data-blocks. If the data-block is cached over
a longer period of time (such that material pointers can't be used directly), it
stores the material name (+ library name) used by each material slot. When the
geometry is used again, the material pointers are restored using these weak name
references and the `BakeDataBlockMap`.

### Manual Mapping Management

There is a new `Data-Blocks` panel in the bake settings in the node editor
sidebar that allows inspecting and modifying the data-blocks that are used when
baking. The user can change what data-block a specific name is mapped to.

Pull Request: https://projects.blender.org/blender/blender/pulls/117043
2024-02-01 09:21:55 +01:00
Jacques Lucke
8ec4f2ada9 Geometry Nodes: add two default items to the Menu Switch node
This is similar to the other Switch nodes and makes the node more
useful by default.
2024-01-31 12:50:08 +01:00
Omar Emara
316f14b834 Compositor: Unify behavior of Z Combine node across CPU and GPU
The GPU implementation of the Use Alpha option of the Z Combine node
only worked if the first image is closer, since it sampled the alpha
channel from it and used it for mixing. Instead, the mix factor should
depend on the closer pixel, like the CPU implementation.
2024-01-30 18:48:58 +02:00
Hans Goudey
6aaa74cda9 Geometry Nodes: Improve extrude node vertex group performance
Add separate functions that deal with the vertex domain and copy vertex
groups without using the attribute API which has a large overhead when
abstracting the access of many vertex groups.

In a 1m vertex mesh with 20 vertex groups, I observed an improvement
in the node's runtime from 399 ms to 64 ms.

Also resolves #117553. That was an error when adding weight data to a
mesh without any weight data would invalidate custom data layers. That
is solved more simply now by just doing nothing in that case.
2024-01-29 21:57:55 -05:00
Omar Emara
6fe2bbd51c Realtime Compositor: Anti-alias morphological threshold
This patch anti-aliases the output of the morphological threshold
operation in the Dilate/Erode node. This is done to match the CPU
implementation.
2024-01-29 20:13:04 +02:00
Miguel Pozo
f185a284f0 Fix: EEVEE-Next: Hair material flags
Add missing tags so the deferred pass can work correctly.
Fixes principled hair render tests.
2024-01-29 17:03:39 +01:00
Lukas Tönne
7163873420 Geometry Nodes: Fix memory leak when using empty menu switch nodes.
Connecting an empty menu to the node group inputs causes a memory leak.
The `id_property_int_update_enum_items` function was always allocating
a new `enum_items` list, but then discarding it if there are no enum
items.
2024-01-29 15:36:42 +01:00
Jacques Lucke
4ad9d8ac59 Geometry Nodes: disable bake settings on linked object 2024-01-29 13:20:06 +01:00
Campbell Barton
be7f89a9f5 Cleanup: spelling in comments 2024-01-29 11:47:42 +11:00
Iliya Katueshenock
25f32a2191 Cleanup: Geometry Nodes: Unused function
Pull Request: https://projects.blender.org/blender/blender/pulls/117591
2024-01-28 15:26:05 +01:00
Lukas Tönne
5ad49f4142 Geometry Nodes: Menu Switch Node
This patch adds support for _Menu Switch_ nodes and enum definitions in
node trees more generally. The design is based on the outcome of the
[2022 Nodes Workshop](https://code.blender.org/2022/11/geometry-nodes-workshop-2022/#menu-switch).

The _Menu Switch_ node is an advanced version of the _Switch_ node which
has a customizable **menu input socket** instead of a simple boolean.
The _items_ of this menu are owned by the node itself. Each item has a
name and description and unique identifier that is used internally. A
menu _socket_ represents a concrete value out of the list of items.

To enable selection of an enum value for unconnected sockets the menu is
presented as a dropdown list like built-in enums. When the socket is
connected a shared pointer to the enum definition is propagated along
links and stored in socket default values. This allows node groups to
expose a menu from an internal menu switch as a parameter. The enum
definition is a runtime copy of the enum items in DNA that allows
sharing.

A menu socket can have multiple connections, which can lead to
ambiguity. If two or more different menu source nodes are connected to a
socket it gets marked as _undefined_. Any connection to an undefined
menu socket is invalid as a hint to users that there is a problem. A
warning/error is also shown on nodes with undefined menu sockets.

At runtime the value of a menu socket is the simple integer identifier.
This can also be a field in geometry nodes. The identifier is unique
within each enum definition, and it is persistent even when items are
added, removed, or changed. Changing the name of an item does not affect
the internal identifier, so users can rename enum items without breaking
existing input values. This also persists if, for example, a linked node
group is temporarily unavailable.

Pull Request: https://projects.blender.org/blender/blender/pulls/113445
2024-01-26 12:40:01 +01:00
Jacques Lucke
932b2d1727 Cleanup: simplify naming of get_default_hash 2024-01-26 11:45:56 +01:00
Hans Goudey
02582213de Cleanup: Move BKE_layer.hh to C++ 2024-01-24 10:55:16 -05:00
Sergey Sharybin
52a31ce31b Fix blur processing in keyign node in GPU compositor
Align the blur filter with the CPU compositor, which uses box filter.
The pre filter was already using box filter, while the post filter was
using gaussian filter.

Additionally, GPU compositor was doing twice amount of blur due to the
mismatch between radius and size semantic: node setting is in size,
while the separable blur expects radius.

Pull Request: https://projects.blender.org/blender/blender/pulls/117454
2024-01-24 09:55:51 +01:00
Hans Goudey
99f9084bee Cleanup: Replace some CLAMP macros with C++ functions
Pull Request: https://projects.blender.org/blender/blender/pulls/117460
2024-01-23 21:10:33 +01:00
Campbell Barton
6cc8ac7cb3 Cleanup: rename ImBuf anim & anim_index structs
Rename: anim -> ImBufAnim
Rename: anim_index -> ImBufAnimIndex

There were cases where removing redundant "struct" qualifier caused
a warning since the name of the struct member was also anim.

Use uppercase type name to conform with other types names.

Ref !117394
2024-01-23 20:26:55 +11:00
Jacques Lucke
c7e674d40f Cleanup: extract low level dna array utilities to separate file
This simplifies reusing those functions outside of the context of node sockets.

Pull Request: https://projects.blender.org/blender/blender/pulls/117418
2024-01-22 21:07:28 +01:00
Iliya Katueshenock
801e24379e Fix: Geometry Nodes: Wrong hash of Shortest Edge Path field
This could cause too many comparisons when deduplicating
field inputs for evaluation.

Pull Request: https://projects.blender.org/blender/blender/pulls/117391
2024-01-22 14:00:03 +01:00
Jacques Lucke
b92443e1d9 Geometry Nodes: optimize single value access in NodeSocketValue
The goal is to get rid of some constant overhead to avoid the small regression mentioned in https://projects.blender.org/blender/blender/pulls/116231#issuecomment-1086124.

Now it is possible to get more direct access to single values stored in `NodeSocketValue`.

Benchmark using the `many_math_nodes` file:
```
version          3.3      3.6      4.0      patch    main
many_math_nodes  0.5352s  0.0606s  0.0293s  0.0292s  0.0304s
```

Pull Request: https://projects.blender.org/blender/blender/pulls/117309
2024-01-21 13:22:16 +01:00
Aras Pranckevicius
a705259b4b Cleanup: move imbuf .h files to .hh 2024-01-19 20:29:38 +01:00
Sergey Sharybin
f8c283d2b7 Fix: Assert in geometry nodes in specific files
Possibly also fixes write past array boundaries.

Happens with the mikassa-shading.blend file, by simply opening
the file in debug mode. The fix is suggested by Jacques.

Pull Request: https://projects.blender.org/blender/blender/pulls/117331
2024-01-19 14:52:43 +01:00
Martijn Versteegh
a3b7674c6e Compositor: Add a Nearest sampling to Map UV node
When using the MapUV node for certain NPR workflows (for example palette
based remapping of colors) it can be useful to not use the default
anisotropic filtering.

In preparation of potentially adding more filter modes at a later stage
and to keep things consistent with the 'transform' node we use the full
set of interpolation modes in the enum, but expose only the implemented
ones in RNA..
2024-01-19 13:24:22 +01:00
Omar Emara
56f3cef4c1 Fix: Cryptomatte fails with multi-layer images
The GPU Cryptomatte node fails when the source is a multi-layer image.
This is because the check that compares the Cryptomatte Type Name with
the layer name was reversed.
2024-01-19 14:07:00 +02:00
Omar Emara
20932608ea Fix #117318: Empty Defocus output when max blur is less than 1
The Defocus node produces an empty output when the max blur is less than
1. This patch fixes that by passing the image through in that case,
since it is identity in this case.
2024-01-19 13:08:19 +02:00
Omar Emara
91f7216eb1 Compositor: Optimize Pixelate node for unit pixel size
Pass the input image through for unit pixel sizes.
2024-01-19 13:03:28 +02:00
Omar Emara
538ace5750 Fix: GPU Directional Blur distorts input
The GPU Directional Blur node distorts the inputs if the resolution is
not square. This is because rotation is performed on normalized
coordinates. This patch performs the normalization at the texture
evaluation.
2024-01-18 16:19:44 +02:00
Hans Goudey
83b7b729a1 Fix #114657: Store default color attribute on store if none set yet
When there is no default color attribute yet, when creating a new color
attribute with the store named attribute node, set the default. Though
we generally try to avoid this more magical behavior, there's little
downside in this case, and it's probably what users expect.

Don't set the active attribute though, since that's UI data that generally
shouldn't be changed procedurally. It's okay if there's no active color
attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/117249
2024-01-18 14:02:27 +01:00
Omar Emara
feb2d02709 Realtime Compositor: Rewrite Pixelate node
This patch rewrites the pixelate node to average a window of a certain
pixel size, following the new CPU implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/117243
2024-01-18 11:52:20 +01:00
Omar Emara
5309d1c574 Fix: Crash in Defocus node when no camera exist
The Defocus node crashes when no camera exist in the scene. We fix this
by defaulting to a focus distance of 10 when a camera doesn't exist.
2024-01-18 12:34:55 +02:00
Sergey Sharybin
baab14ca38 Compositor: Re-write Pixelate node for CPU compositor
The old implementation was a simple rounding operation and was not
implemented for full-frame compositor.

The issue with the old implementation is that it will not give
satisfactory results for images with high frequency details,
including cases when is used for a preview on Cycles render with
low number of samples. Additionally, when applied on animated
footage it produces very noisy result.

The new algorithm uses an explicit pixel size setting, which allows
the node to be used on its own, without need to have scale-down and
scale-up nodes. It also uses neighbour averaging, which produces
better looking result during animation and noisy input images.

The old tiled compositor setup will render without changes with
this change. This commit does not include modifications in the GPU
compositor implementation.

Ref #88150

Pull Request: https://projects.blender.org/blender/blender/pulls/117223
2024-01-18 11:30:55 +01:00
Omar Emara
e4a93d7b8c Compositor: Add High Precision option to Kuwahara
For high radii Kuwahara, we use a Summed Area Table (SAT) implementation
to accelerate the classic variant of the algorithm. The problem is that
due to limited floating point precision, the SAT can produce artifacts
in its output.

An attempt to fix this was implemented in #114191, and while that patch
improved precision by 10x, the artifacts still existed, albeit less
noticeable. But since the improved precision also meant a performance
penalty, it was decided that the improvement is not worth it.

Since the artifacts are only noticeable for scenes with very high
values, this patch adds a High Precision option that defaults to false
and can be enabled by the user upon noticing any artifacts. The option
simply uses direction convolution instead of SAT in this case. The
downside, of course, is that it can be orders of magnitude slower.

An alternative to using this option is for the user to clamp the input
or downsample the image. Both methods should be documented in the
documentation.

Fixes: #113578.

Pull Request: https://projects.blender.org/blender/blender/pulls/115763
2024-01-17 14:30:29 +01:00
Jacques Lucke
f811e9c6d6 Fix: crash when adding repeat zone from search
The issue was that some code expected the "extend" sockets
to always exist. This was already always true from the user
point of view, but not internally.

There are different possible fixes, but this patch makes sure
that the extend socket will be available as expected. This is
achieved by making them part of the static node declaration.
We want to extend the static declaration of such dynamic
nodes anyway, to improve reflection capabilities without
having to instantiate nodes.
2024-01-17 12:45:06 +01:00
Hans Goudey
3e76a1a6c2 Cleanup: Move BKE_lib_id.h to C++ 2024-01-15 12:44:14 -05:00
Iliya Katueshenock
4effcd33a3 Fix: Sort Elements node breaks curves sculpt
Since the node effectively changes the topology of the curves,
the deformed positions from before the node must be saved.

Pull Request: https://projects.blender.org/blender/blender/pulls/117109
2024-01-14 21:33:09 +01:00
Iliya Katushenock
37b2c12cfa Geometry Nodes: Sort Elements node
Implements the design in #109983

Pull Request: https://projects.blender.org/blender/blender/pulls/114194
2024-01-12 14:30:34 +01:00
Damien Picard
3bd41cf9bc I18n: Go over TIP_ and IFACE_ usages, change to RPT_ when relevant
The previous commit introduced a new `RPT_()` macro to translate
strings which are not tooltips or regular interface elements, but
longer reports or statuses.

This commit uses the new macro to translate many strings all over the
UI.

Most of it is a simple replace from `TIP_()` or `IFACE_()` to
`RPT_()`, but there are some additional changes:
- A few translations inside `BKE_report()` are removed altogether
  because they are already handled by the translation system.
- Messages inside `UI_but_disable()` are no longer translated
  manually, but they are handled by a new regex in the translation
  system.

Pull Request: https://projects.blender.org/blender/blender/pulls/116804

Pull Request: https://projects.blender.org/blender/blender/pulls/116804
2024-01-12 13:37:32 +01:00
Omar Emara
e84dc990b1 Realtime Compositor: Implement Vector Blur node
This patch implements the Vector Blur node for the Realtime Compositor.
The implementation is a direct and mostly identical port of the EEVEE
motion blur implementation with the necessary adjustments to make it
work with the compositor.

The exposed parameters in the node does not match those exposed in
EEVEE, so only the parameters shared between both are currently
implemented. In the future, we should make a decision to either unify
both, or just consider them independent implementations, with the
possibility of sharing the full or part of the code.

Further, it would also make sense to port the implementation to the CPU
compositor, since the new implementation is higher in quality while also
being faster.

The default value of the node shutter setting was changed to 0.25 to
approximately match the default settings of EEVEE and Cycles, since in
their default settings, they evaluate the previous and next frames at
plus and minus 0.25.

Pull Request: https://projects.blender.org/blender/blender/pulls/116977
2024-01-12 12:12:01 +01:00
Jacques Lucke
a94146b82c Cleanup: move BKE_pointcloud.h to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/116990
2024-01-11 10:54:47 +01:00
Brecht Van Lommel
eb747c5d20 Fix: invalid memory access in Hydra world and material export 2024-01-10 20:54:40 +01:00