Commit Graph

4589 Commits

Author SHA1 Message Date
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
Brecht Van Lommel 7271f303fe Cleanup: make format 2024-01-10 20:34:30 +01:00
Dyvine57 eca14d5b40 Nodes: add int and bool to shader nodegroups
These are handled as floats by Cycles and EEVEE.

Pull Request: https://projects.blender.org/blender/blender/pulls/115026
2024-01-10 20:09:37 +01:00
Hans Goudey ba4d7fc2d9 Cleanup: Continue loop to corner rename in some mesh code
Change mesh normals code and mesh topology map functions.
2024-01-10 13:12:22 -05:00
Hans Goudey 66dc0ebf2e Fix #104926: Object Info node doesn't give negative scale
The previous behavior was giving a completely negated scale
if any of the object's original scale values was negative. Restore that
behavior here.

Pull Request: https://projects.blender.org/blender/blender/pulls/116989
2024-01-10 17:35:53 +01:00
Jacques Lucke 522f9c9834 Volumes: improve tree access token api
There was one functional issue with the previous API which was its
use in `VolumeGrid<T>::grid_for_write(tree_token)`. The issue was
that the tree token had to be received before the grid is accessed.
However, this `grid_for_write` method might create a copy of the
`VolumeGridData` internally and if it does, the passed in `tree_token`
corresponds to the wrong tree.

The solution is to output the token as part of the method. This has two
additional benefits:
* The API is more safe, because one can't pass an r-value into the methods
  anymore. This generally shouldn't be done, because the token should
  live at least as long as the OpenVDB tree is used and shouldn't be freed
  immediatly.
* The API is a bit simpler, because it's not necessary to call the
  `VolumeGrid.tree_access_token()` method anymore.
2024-01-10 15:20:29 +01:00
Jacques Lucke 2be41131fa Fix: memory leak
Previously, the `ZoneBuildInfo` values were never destructed. That worked, because
it rarely contained any allocations. This changed in b6f8e1396b.
2024-01-09 22:10:11 +01:00
Iliya Katueshenock b6f8e1396b Geometry Nodes: refactor indices for zone socket mapping
This simplifies the code that creates the zone socket mappings at the cost of
slightly more memory per zone, which is not significant.

Previously, `IndexRange` was used where it now uses `Vector<int>`.

Pull Request: https://projects.blender.org/blender/blender/pulls/116939
2024-01-09 18:16:43 +01:00
Clément Foucault ea989ebf94 EEVEE/EEVEE-Next: Split Diffuse and Subsurface closure
Even if related, they don't have the same performance
impact.

To avoid any performance hit, we replace the Diffuse
by a Subsurface Closure for legacy EEVEE and
use the subsurface closure only where needed for
EEVEE-Next leveraging the random sampling.

This increases the compatibility with cycles that
doesn't modulate the radius of the subsurface anymore.
This change is only present in EEVEE-Next.

This commit changes the principled BSDF code so that
it is easier to follow the flow of data.

For legacy EEVEE, the SSS switch is moved to a
`radius == -1` check.
2024-01-09 16:39:17 +13:00
Hans Goudey 29d6648550 Fix #116885: Index Switch node assert fails when removing all items
`set_default_remaining_node_outputs` didn't work because the mapping
between the original node group sockets and the lazy function outputs
wasn't set up during the construction of the node type, as done by the
bake node and others.
2024-01-08 14:04:31 -05:00
Omar Emara 08130211b1 Fix: GPU Directional Blur node does not match CPU
The GPU Directional Blur node does not match CPU. This is because GPU
accumulates the scale, while the CPU increments it. This patch
incremenets the scale for the GPU to make them match.
2024-01-08 13:42:32 +02:00
Campbell Barton 617f7b76df Cleanup: comment block formatting 2024-01-08 11:31:43 +11:00
Campbell Barton 0ba83fde1f Cleanup: spelling in comments 2024-01-08 11:24:37 +11:00
Hans Goudey 09063a3632 Cleanup: Remove some indirect includes in common headers
The idea is to avoid mistakenly depending on indirect includes,
and avoid compile time overhead from unnecessary header parsing.

Pull Request: https://projects.blender.org/blender/blender/pulls/116664
2024-01-06 01:47:39 +01:00
Bastien Montagne 95b30b3516 Build: Ninja: Move 'Unity builds' to heavy pooljobs.
This commit adds a new helper to define expected properties when a
target needs to use the unity build feature.

That new helper does what was already done for existing cases, and in
addition add the target to the Ninja 'heavy' pooljobs if relevant.

Pull Request: https://projects.blender.org/blender/blender/pulls/116791
2024-01-05 18:35:48 +01:00
Omar Emara 9f076edf5d Fix: Filtering does not work in GPU compositor
Texture filtering does not work in the GPU compositor. That's because
filtering is set after textures are bound. It works in the viewport
compositor because the textures come pre filtered from the DRW texture
pool.
2024-01-05 17:38:10 +02:00
Omar Emara 581f2d3c7d Realtime Compositor: Aspect correct mask inputs
This patch implements aspect ratio correction for mask inputs if the
size mode is set to Render Size.
2024-01-05 14:02:19 +02:00
Hans Goudey d6cfd7d1f4 Cleanup: Remove unnecessary keywords from C++ headers
- Remove unnecessary `struct`
- Use `using` instead of `typedef`
- Remove `void` from `(void)` as function arguments
2024-01-04 15:07:48 -05:00
Omar Emara 41ba876d78 Fix: Compositor Texture node ignores Z component
The compositor Texture node ignores the Z component. Fix that by
defaulting to zero Z and considering the offset and scale in the node.
2024-01-04 17:05:58 +02:00
Omar Emara d096927139 Compositor: Fallback to render size for viewing values
Fallback to the render size when a single value is connected to the
viewer node. Giving the user the ability to easily view values.
2024-01-04 11:12:45 +02:00
Brecht Van Lommel d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01:00
Iliya Katueshenock c428b5871c Fix #116614: Empty Point Cloud crash Points to Curves
Offset accumulation cause crash for empty domain. Simple fix as early return for is empty curve offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/116640
2023-12-30 01:20:00 +01:00
Hans Goudey 06eda2a484 Cleanup: Remove most indirect includes of BKE_customdata.hh
Some common headers were including this. Separating the includes
will ideally lead to better conceptual separation between CustomData
and the attribute API too. Mostly the change is adding the file to
places where it was included indirectly before. But some code is
shuffled around to hopefully better places as well.
2023-12-26 23:59:44 -05:00
Miguel Pozo a90fdd5246 Fix #115226: Shader Nodes: Don't execute the same node twice
Allow to share nodes between the main shader and multiple AOVs,
since they are executed in the same function.
2023-12-22 17:32:25 +01:00
Omar Emara 7a8e349b73 Compositor: Support viewer offset in GPU compositor
This patch adds support for viewer offsets in the experimental GPU
compositor.
2023-12-22 13:12:17 +02:00
Hans Goudey da6867ca3b Cleanup: Use dynamic declaration for sample curve node
Change the attribute "value" sockets to use dynamic declarations, but
not the others. See 8149678d5e, f7383cfe9b.
2023-12-21 10:34:55 -05:00
Omar Emara e055db6605 Realtime Compositor: Implement Defocus node
This patch implements the defocus node for the Realtime Compositor. The
implementation does not match the CPU compositor implementation, but
uses a new formulation that is more physically accurate and consistent
with Blender's render engines.

The existing CPU implementation is questionable starting from its circle
of confusion calculation, to the morphological operations applied on the
CoC radius, to ignoring the maximum CoC radius in the search kernel, and
ending with the threshold parameter used to reduce artifacts. Therefore,
it should be reimplemented along with this same implementation using a
more consistent methodology.

EEVEE and Workbench already have a GPU defocus method, which can be
ported to the compositor and used as the preview defocus algorithm.
While this implementation will be updated to be a more accurate method
that produces the same structure as the ported EEVEE implementation.

The new formulation ignores the threshold parameter for now, as well as
the preview parameter.

Pull Request: https://projects.blender.org/blender/blender/pulls/116391
2023-12-21 12:20:38 +01:00
Aras Pranckevicius fec8461365 Cleanup: move BKE_colorband.h and BKE_colorcools.h to .hh
Also remove includes of those where not needed

Pull Request: https://projects.blender.org/blender/blender/pulls/116416
2023-12-21 10:10:53 +01:00
Jeroen Bakker 3261508e82 Cleanup: Make format 2023-12-21 09:03:53 +01:00
Hans Goudey f63a7c1ee9 Curves: Add basic custom normals support
Add a new normal mode called "Custom" which directly interpolates
a "custom_normal" attribute to the evaluated points for the final
normal. Extend the "Set Curve Normal" node with this mode and
give it the ability to set the custom normal value.

This is intentionally a very basic implementation of custom normals.
In particular, the storage is not rotation invariant. So the normals
are expected to be set procedurally at the end of the modifier stack.
On the other hand, it is very easy to understand and explain.

Pull Request: https://projects.blender.org/blender/blender/pulls/116066
2023-12-21 03:29:18 +01:00
Hans Goudey b9b47088bc Cleanup: Remove unnecessary DNA_meshdata_types.h includes
Except for vertex groups and a few older color types, these
are generally replaced by newer generic attribute types.
Also remove some includes of DNA_mesh_types.h, since it's
included indirectly by BKE_mesh.hh currently.
2023-12-20 20:58:38 -05:00
Hans Goudey 2c43a9eed9 Cleanup: Move BKE_mesh_calc_edges to bke namespace
Also use reference for mesh argument, and move edges calculation
from legacy faces to "legacy" file.
2023-12-20 20:47:10 -05:00
Lukas Tönne e470edf3e1 Geometry Nodes: initial Volume Grid socket support
This is the initial implementation for the volume grid sockets that has been
discussed during the November 2023 geometry nodes workshop.

It adds initial support for passing volume grids around in sockets. Furthermore,
it adds two new nodes. Both are initially hidden under the "New Volume Nodes"
experimental option until we have a few mode nodes.
* **Get Named Grid**: Gets or extracts a volume grid from a volume geometry
  based on the grid's name.
* **Store Named Grid**: Puts a volume grid back into a volume with a name.

`SocketValueVariant` is extended to support grids besides single values and fields.

Next steps:
* Implement grid socket shape and inferencing (currently, they just look like
  single values).
* Add implicit conversions between grid types.
* Implement nodes that operate on the grids (#116021).
* Improved spreadsheet and viewer support.

Links:
* https://devtalk.blender.org/t/volumes-in-geometry-nodes-proposal/31917
* https://devtalk.blender.org/t/2023-11-06-geometry-nodes-workshop-notes/32007#volumes-3

Co-authored-by: Jacques Lucke <jacques@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/115270
2023-12-20 22:33:17 +01:00
Hans Goudey 19b46e0816 Cleanup: Make format 2023-12-20 14:54:50 -05:00
Hans Goudey edf8a776ac Cleanup: Use forward declarations to replace includes of BKE_attribute.hh
Remove most includes of this header inside other headers, to remove unnecessary
indirect includes which can have a impact on compile times. In the future we may
want more dedicated "_fwd.hh" headers, but until then, this sticks with the
solution in existing code.

Unfortunately it isn't yet possible to remove the include from `BKE_geometry_set.hh`.
2023-12-20 13:25:28 -05:00
Hans Goudey 19001c9e6c Cleanup: Move attribute domain enum to C++ header, use enum class
Each value is now out of the global namespace, so they can be shorter
and easier to read. Most of this commit just adds the necessary casting
and namespace specification. `enum class` can be forward declared since
it has a specified size. We will make use of that in the next commit.
2023-12-20 13:25:28 -05:00
Jacques Lucke 70a53a815e Cleanup: avoid openvdb include in general in common header 2023-12-20 15:59:44 +01:00
Jacques Lucke 59c84ee95b Cleanup: extract function to show missing openvdb error message 2023-12-20 15:58:56 +01:00
Jacques Lucke a72e7a220d Volumes: refactor volume grid storage
This refactors how volume grids are stored with the following new goals in mind:
* Get a **stand-alone volume grid** data structure that can be used by geometry nodes.
  Previously, the `VolumeGrid` data structure was tightly coupled with the `Volume` data block.
* Support **implicit sharing of grids and trees**. Previously, it was possible to share data
  when multiple `Volume` data blocks loaded grids from the same `.vdb` files but this was
  not flexible enough.
* Get a safe API for **lazy-loading and unloading** of grids without requiring explicit calls
  to some "load" function all the time.
* Get a safe API for **caching grids from files** that is not coupled to the `Volume` data block.
* Get a **tiered API** for different levels of `openvdb` involvement:
  * No `OpenVDB`: Since `WITH_OPENVDB` is optional, it's helpful to have parts of the API that
    still work in this case. This makes it possible to write high level code for volumes that does
    not require `#ifdef WITH_OPENVDB` checks everywhere. This is in `BKE_volume_grid_fwd.hh`.
  * Shallow `OpenVDB`: Code using this API requires `WITH_OPENVDB` checks. However, care
  is taken to not include the expensive parts of `OpenVDB` and to use forward declarations as
  much as possible. This is in `BKE_volume_grid.hh` and uses `openvdb_fwd.hh`.
  * "Full" `OpenVDB`: This API requires more heavy `OpenVDB` includes. Fortunately, it turned
  out to be not necessary for the common API. So this is only used for task specific APIs.

At the core of the new API is the `VolumeGridData` type. It's a wrapper around an
`openvdb::Grid` and adds some features on top like implicit sharing, lazy-loading and unloading.
Then there are `GVolumeGrid` and `VolumeGrid` which are containers for a volume grid.
Semantically, each `VolumeGrid` has its own independent grid, but this is cheap due to implicit
sharing. At highest level we currently have the `Volume` data-block which contains a list of
`VolumeGrid`.

```mermaid
flowchart LR
  Volume --> VolumeGrid --> VolumeGridData --> openvdb::Grid
```

The loading of `.vdb` files is abstracted away behind the volume file cache API. This API makes
it easy to load and reuse entire files and individual grids from disk. It also supports caching
simplify levels for grids on disk.

An important new concept are the "tree access tokens". Whenever some code wants to work
with an openvdb tree, it has to retrieve an access token from the corresponding `VolumeGridData`.
This access token has to be kept alive for as long as the code works with the grid data. The same
token is valid for read and write access. The purpose of these access tokens is to make it possible
to detect when some code is currently working with the openvdb tree. This allows freeing it if it's
possible to reload it later on (e.g. from disk). It's possible to free a tree that is referenced by
multiple owners, but only no one is actively working with. In some sense, this is similar to the
existing `ImageUser` concept.

The most important new files to read are `BKE_volume_grid.hh` and `BKE_volume_grid_file_cache.hh`.
Most other changes are updates to existing code to use the new API.

Pull Request: https://projects.blender.org/blender/blender/pulls/116315
2023-12-20 15:32:52 +01:00
Hans Goudey 8dd8f932e2 Cleanup: Rename Mesh loop_data to corner_data
Related to #110434, efbee2d606, 7c69c8827b
2023-12-19 20:39:05 -05:00
Hans Goudey efbee2d606 Mesh: Rename totvert, totedge, and totloop fields
Use the standard "elements_num" naming, and use the "corner" name rather
than the old "loop" name: `verts_num`, `edges_num`, and `corners_num`.
This matches the existing `faces_num` field which was already renamed.

Pull Request: https://projects.blender.org/blender/blender/pulls/116350
2023-12-20 02:21:48 +01:00
Damien Picard faefaa4447 I18n: extract and disambiguate a few messages
Extract:
- Compositor error messages.
- `bUnitDef`s were broken after cleanup commit 2b77cd726d. Since each
  unit's "display name" is now preceded by a consistent "name_display"
  comment, the regex which extracts the unit is greatly simplified.
  It now relies on the presence of the comment instead of the struct
  order.
- "Preset" menu and "Apply Preset" button from the curveprofile
  template.
- Operator labels from the catalog context menu.

Disambiguate:
- "Bake Data": can mean "Which data to bake" (verb), or "The data that
  were baked" (noun).
- "Cache" in the Simulation Nodes panel is a verb, not a noun.
- "Mix" in the snapping menu is a noun, not a verb.
- "Top" and "Bottom" can mean the upper part of an object or the
  highest point or element of something like a menu or list.

Pull Request: https://projects.blender.org/blender/blender/pulls/115963
2023-12-19 18:41:09 +01:00
Jacques Lucke 5d610ad43a Fix #116308: muted nodes don't do type conversion correctly
A similar issue was fixed in the commit below for inserting implicit
conversions for links, but it wasn't corrected for conversions in
muted nodes.

Caused by e1d0d70911
2023-12-19 15:50:10 +01:00
Hans Goudey 7c69c8827b Mesh: Rename MLoopTri variable names, and functions
Make the naming consistent with the recent change from "loop" to
"corner". Avoid the need for a special type for these triangles by
conveying the semantics in the naming instead.

- `looptris` -> `corner_tris`
- `lt` -> `tri` (or `corner_tri` when there is less context)
- `looptri_index` -> `tri_index` (or `corner_tri_index`)
- `lt->tri[0]` -> `tri[0]`
- `Span<MLoopTri>` -> `Span<int3>`
- `looptri_faces` -> `tri_faces` (or `corner_tri_faces`)

If we followed the naming pattern of "corner_verts" and "edge_verts"
exactly, we'd probably use "tri_corners" instead. But that sounds much
worse and less intuitive to me.

I've found that by using standard vector types for this sort of data,
the commonalities with other areas become much clearer, and code ends
up being naturally more data oriented. Besides that, the consistency
is nice, and we get to mostly remove use of `DNA_meshdata_types.h`.

Pull Request: https://projects.blender.org/blender/blender/pulls/116238
2023-12-19 14:57:49 +01:00
Jacques Lucke e0aa05996f Fix: normalize option not shown in noise texture node
Caused by f7e8021b2a.
2023-12-19 12:56:37 +01:00
Campbell Barton 482ba7806d Cleanup: spelling correction: "adjacent" & spelling in comments 2023-12-19 09:54:53 +11:00
Iliya Katueshenock c106066900 Geometry Nodes: Improve Shortest Edge Paths node performance
Speedup of node Shortest Edge Paths node by creating an array for
other_edge_vert's and computing them in parallel separate loop.
This also provides better CPU cache by avoiding reading edges in main
loop to find other vertex (which happen multiple time for each vertex).

For cuboid with `700`x`700`x`700` points and `0.066667%` random
selection of `Edge Vertex` this will change `1012.4 ms` -> `618.9 ms`
the in `shortest_paths` function.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114707
2023-12-18 20:32:14 +01:00
Hans Goudey 5de57e7001 Refactor: Move evaluate on domain field input to be reusable
This is used in #116066 to find the curve selection on the point
domain without having a user-visible difference in behavior.
2023-12-18 10:06:38 -05:00
Jacques Lucke 00eaddbd51 Geometry Nodes: new Bake node
This adds a new `Bake` node which allows saving and loading intermediate geometries.
Typical use cases we want address with this currently are:
* Bake some data for use with a render engine.
* Bake parts of the node tree explicitly for better performance.

For now, the format that is written to disk is not considered to be an import/export format.
It's not guaranteed that data written with one Blender version can be read by another
Blender version. For that it's better to use proper interchange formats. Better support for
those will be added eventually as well. We also plan an `Import Bake` node that allows
reading the blender-specific baked data independent of the Bake node and at different frames.

The baking works very similar to the baking in the simulation zone (UI and implementation
wise). Major differences are:
* The Bake node has a `Bake Still` and `Bake Animation` mode.
* The Bake node doesn't do automatic caching.

Implementation details:
* Refactored how we create the Python operators for moving socket items so that it also
  makes sense for non-zones.
* The `ModifierCache` stores an independent map of `SimulationNodeCache` and
  `BakeNodeCache`, but both share a common data structure for the actually baked data.
* For baking, the `Bake` node is added as a side-effect-node in the modifier. This will make
  sure that the node is baked even if it's currently not connected to the output.
* Had to add a new `DEG_id_tag_update_for_side_effect_request` function that is used
  during baking. It's necessary because I want to evaluate the object again even though none
  of its inputs changed. The reevaluation is necessary to create the baked data. Using
  `DEG_id_tag_update` technically works as well, but has the problem that it also uses the
  `DEG_UPDATE_SOURCE_USER_EDIT` flag which (rightly) invalidates simulation caches
  which shouldn't happen here.
* Slightly refactored the timeline drawing so that it can also show the baked ranges of
  Bake nodes. It does not show anything for baked nodes with a in Still mode though.
* The bake operator is refactored to bake a list of `NodeBakeRequest` which makes the
  code easier to follow compared to the previous nested
  `ObjectBakeData > ModifierBakeData > NodeBakeData` data structure.
* The bake operators are disabled when the .blend file is not yet saved. This is technically
  only necessary when the bake path depends on the .blend file path but seems ok to force
  the user anyway (otherwise the bake path may be lost as well if it's set explicitly).
* The same operators are used to bake and delete single bakes in `Bake` nodes and
  `Simulation Zones`. On top of that, there are separate operators of baking and deleting all
  simulation bakes (those ignore bake nodes).
* The `Bake` node remembers which inputs have been fields and thus may be baked as attributes.
  For that it uses an `Is Attribute` flag on the socket item. This is needed because the baked data
  may still contain attribute data, even if the inputs to the bake node are disconnected.
* Similar to simulation zones, the behavior of `Bake` nodes is passed into the geometry nodes
  evaluation from the outside (from the modifier only currently). This is done by providing the
  new `GeoNodesBakeParams` in `GeoNodesCallData` when executing geometry nodes.

Next Steps (mostly because they also involve simulations):
* Visualize nodes that have not been evaluated in the last evaluation.
* Fix issue with seemingly loosing baked data after undo.
* Improve error handling when baked data is not found.
* Show bake node in link drag search.
* Higher level tools for managing bakes.

Pull Request: https://projects.blender.org/blender/blender/pulls/115466
2023-12-18 13:01:06 +01:00
Jacques Lucke 2189a34312 Fix: crash when there is no tree logger in geometry nodes 2023-12-18 12:19:13 +01:00
Hoshinova f7e8021b2a Fix #116256: Unintentional override of node type property in API
Rename new noise node type to avoid conflict with node type.

Pull Request: https://projects.blender.org/blender/blender/pulls/116278
2023-12-18 10:35:20 +01:00
Jacques Lucke e1d0d70911 Geometry Nodes: refactor storage for socket values
This refactors `SocketValueVariant` with the following goals in mind:
* Support type erasure so that not all users of `SocketValueVariant` have
  to know about all the types sockets can have.
* Move towards supporting "rainbow sockets" which are sockets whoose
  type is only known at run-time.
* Reduce complexity when dealing with socket values in general. Previously,
  one had to use `SocketValueVariantCPPType` a lot to manage uninitialized
  memory. This is better abstracted away now.

One related change that I had to do that I didn't see coming at first was that
I had to refactor `set_default_remaining_outputs` because now the default value
of a `SocketValueVariant` would not contain any value. Previously, it was
initialized the zero-value of the template parameter. Similarly, I had to change
how implicit conversions are created, because comparing the `CPPType` of linked
sockets was not enough anymore to determine if a conversion is necessary.

We could potentially use `SocketValueVariant` for the remaining socket types in the
future as well. Not entirely sure if that helps yet. `SocketValueVariant` can easily be
adapted to make that work though. That would also justify the name
"SocketValueVariant" better.

Pull Request: https://projects.blender.org/blender/blender/pulls/116231
2023-12-17 14:00:07 +01:00
Hans Goudey 34bf1f6c0c Cleanup: Slightly simplify delaunay triangulation input gathering
Separate allocation of input arrays and assignment to input class.
The main purpose is to simplify #111061.
2023-12-14 12:40:46 -05:00
Miguel Pozo 9bf942dcc9 Cleanup: Conver macros into functions
Avoids macro redefinition warnings in unity builds.
2023-12-14 18:34:20 +01:00
Iliya Katueshenock 999c0f6878 Cleanup: Fix compiler warning in face group boundaries node
Fix error of wrong parameter for `compare_exchange_weak`. Second
one parameter is used for write new value, but a mistake occurred and
the wrong parameter (for read) was used. Default param is enough for
this, so just delete last one.

Pull Request: https://projects.blender.org/blender/blender/pulls/116010
2023-12-14 18:32:21 +01:00
Hans Goudey 451aa56d9c Cleanup: Move BLI_delaunay_2d.hh to C++ 2023-12-14 10:05:35 -05:00
Omar Emara a8e13994b8 Realtime Compositor: Implement Cryptomatte node
This patch implements the Cryptomatte node for the Realtime Compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/115884
2023-12-14 08:49:41 +01:00
Campbell Barton 944e0483a6 Cleanup: clarify naming for MLoopTri
The term `looptri` was used ambiguously for both single & arrays.
The term `tri` was also used, causing `tri->tri`.

Use terms:

- `looptris` for an array or when dealing with multiple items.
- `looptri` is used when dealing with a single item.
- `lt` for a single MLoopTri variables & arguments.

This was already a convention but not followed closely.
2023-12-14 12:32:11 +11:00
Campbell Barton a4af406b81 Clenaup: spelling in comments 2023-12-14 11:14:50 +11:00
Miguel Pozo 8e9ce4d03d Fix: EEEVEE-Next: Volume lighting
Fix socket_not_white and socket_not_black logic.
(Volume lighting would be disabled if any scatter channel was 0)
Remove unnecesary clamps.
2023-12-13 19:49:31 +01:00
Jacques Lucke f7383cfe9b Geometry Nodes: use dynamic declaration for switch node
Follow up for 8149678d5e. Significantly reduce boilerplate
required for each type in the switch node.Forward compatibility in 4.0
provided by 0ea193bdb3.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/113413
2023-12-13 17:33:25 +01:00
Hans Goudey e657aa2360 Cleanup: Move two mesh functions to C++ header 2023-12-13 09:50:47 -05:00
Hans Goudey 6a1009c9f8 Cleanup: Remove const for Span and by-value types in headers 2023-12-13 09:39:03 -05:00
Jacques Lucke 3370228ae8 Geometry Nodes: rename ValueOrField to SocketValueVariant
Doing this in preparation for also supporting volume
grids in the same type (#115270).

At some point we could also actually use an `std::variant` in this
type, but that would change behavior without futher changes.
2023-12-13 13:40:40 +01:00
Omar Emara 123da3412b Cleanup: Move Cryptomatte node defines into enums 2023-12-13 12:40:34 +02:00
Omar Emara 931c188ce5 Compositor: Refactor File Output node
This patches refactors the compositor File Output mechanism and
implements the file output node for the Realtime Compositor. The
refactor was done for the following reasons:

1. The existing file output mechanism relied on a global EXR image
   resource where the result of each compositor execution for each
   view was accumulated and stored in the global resource, until the
   last view is executed, when the EXR is finally saved. Aside from
   relying on global resources, this can cause effective memory leaks
   since the compositor can be interrupted before the EXR is written and
   closed.
2. We need common code to share between all compositors since we now
   have multiple compositor implementations.
3. We needed to take the opportunity to fix some of the issues with the
   existing implementation, like lossy compression of data passes,
   and inability to save single values passes.

The refactor first introduced a new structure called the Compositor
Render Context. This context stores compositor information related to
the render pipeline and is persistent across all compositor executions
of all views. Its extended lifetime relative to a single compositor
execution lends itself well to store data that is accumulated across
views. The context currently has a map of File Output objects. Those
objects wrap a Render Result structure and can be used to construct
multi-view images which can then be saved after all views are executed
using the existing BKE_image_render_write function.

Minor adjustments were made to the BKE and RE modules to allow saving
using the BKE_image_render_write function. Namely, the function now
allows the use of a source image format for saving as well as the
ability to not save the render result as a render by introducing two new
default arguments. Further, for multi-layer EXR saving, the existent of
a single unnamed render layer will omit the layer name from the EXR
channel full name, and only the pass, view, and channel ID will remain.
Finally, the Render Result to Image Buffer conversion now take he number
of channels into account, instead of always assuming color channels.

The patch implements the File Output node in the Realtime Compositor
using the aforementioned mechanisms, replaces the implementation of the
CPU compositor using the same Realtime Compositor implementation, and
setup the necessary logic in the render pipeline code.

Pull Request: https://projects.blender.org/blender/blender/pulls/113982
2023-12-13 11:08:03 +01:00
Kenzie 3f485c8bf3 Geometry Nodes: add support for blackbody shader node
This adds the existing Blackbody shader node to geometry nodes, with the
same functionality.

Pull Request: https://projects.blender.org/blender/blender/pulls/114768
2023-12-13 10:10:06 +01:00
Omar Emara 356480fabb Realtime Compositor: Add static cached images
The Realtime compositor currently relies on the GPU cache in image IDs.
That cache only supports single layer images, so multi-layer images will
be acquired without a cache, introducing significant IO bottlenecks for
the GPU compositor.

This patch ignores the image GPU cache and stores the images in the
static cache manager of the compositor. Draw data was introduced to the
image ID for proper cache invalidation, like other IDs such as masks.

The downside is that the cache will no longer be shared between EEVEE
and the compositor. But realistically, images are not typically shared
between materials and compositors.

This is just a temporary solution until we have proper GPU storage
support for image buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/115511
2023-12-13 09:50:42 +01:00
Clément Foucault ac11ccd2bd EEVEE-Next: Add Translucent BSDF support
This adds support for Translucent BSDF.

This also fixes a bug to allow correct
shadowing.

The input normal had to be set back to
non-inverted in the node function to allow
for correct interpretation of the Normal
by Screen Space Reflections.

This add the necessary optimization
and code deduplication to hybrid deferred
and forward pipeline.

Pull Request: https://projects.blender.org/blender/blender/pulls/116070
2023-12-13 02:19:19 +01:00
Campbell Barton 7ad2c71a0a Cleanup: remove redundant clamp with BLI_str_utf8_offset_from_index 2023-12-13 12:14:47 +11:00
Hans Goudey c53e220aef Cleanup: Use C++ attribute API instead of CustomData API
This gives better asserts in debug builds through use of Span, more
safety when name convention attributes happen to have different types
or domains, and simpler code in some cases. But the main reasoning is to
avoid relying on the specifics of CustomData more to allow us to replace
it in the future.
2023-12-12 18:23:59 -05:00
Hans Goudey 1d0179adbb Cleanup: Move mesh update tags to DNA struct
This is similar to other update tags and update tags for other geometry types.
2023-12-12 18:23:59 -05:00
Douglas Paul 75f160ee96 Geometry Nodes: Add Active Camera input node
This adds a new "Active Camera" input geometry node, per #105761.

The node outputs the the scene's current active camera. It is available
from Input > Scene > Active Camera in the geometry nodes Add menu.

Typical usage would be to connect this node to an Object Info node to
obtain its transform. This works as expected when the camera's
transform is animated, and also when there are markers on the timeline
that change the active camera.

In order to support the aforementioned changes in the active camera,
this implementation adds depsgraph relations for all cameras referenced
by timeline markers. This eliminates the complexity of updating the
depsgraph whenever the scene switches to a different active camera,
but of course it comes at the cost of including more objects than
strictly necessary in the depsgraph for scenes that switch cameras.
Dynamically updating the depsgraph upon camera changes could be a
future improvement if there proves to be sufficient need for it.

Pull Request: https://projects.blender.org/blender/blender/pulls/113431
2023-12-12 19:11:06 +01:00
Hans Goudey a6838c8a12 Geometry Nodes: Change Instance Rotation node to use rotation socket
See #92967. Since the versioning is idempotent, I just moved it to the
latest subversion bump again.
2023-12-12 12:46:27 -05:00
Hans Goudey d8497e48e1 Cleanup: Use `is_empty()` instead of `size() == 0` 2023-12-11 15:47:11 -05:00
Omar Emara bcea221021 Realtime Compositor: Cache bokeh kernel image
This patch creates a static cached resource from bokeh kernel images,
for better performance and reusability, since it will be used by the
Defocus node as well.
2023-12-11 19:43:03 +02:00
Damien Picard 6d70e9b05f UI: fix and improve a few messages
- "Frame Step" -> "Number of frames to skip forward while baking each
  frame": expand description which was just copying the prop name.
- "b-bone" -> "B-Bone": title case.
- "Volumes Lighting" -> "Volume Lighting": typo.
- "Volumes Shadows" -> "Volume Shadows": typo.
- "Insert Blank Keyframe (All Layer)" -> "(All Layers)": typo.
- "the an" -> "an", typo.
- "Inverse" -> "Invert": use verb instead of noun for an action.
- "Desination" -> "Destination": typo.
- "Hides all other F-Curves other than the ones being framed": remove
  extra "other".
- "Remove Bone from Bone collections" -> "Collection", singular because
  the operator is only applied to the active collection. Also title
  case on "Collection".
- "Change Stroke material with selected material" -> "Assign the
  active material slot to the selected strokes": rephrase by reusing
  the message from the non-Grease Pencil materials.
- "VisAction", "VisArea" -> "Visibility Action", "Visibility Area":
  expand abbreviation. This is not exposed in the UI right now but
  will show up in the API docs.
- "Stop Mode Right / Global Down" -> "Stop Move" (typo).
- "... for node input  %s": remove extra space.
- "Move along their normal" -> "Move shadows along their normal":
  rephrase unclear sentence.
- "Stat Vis" -> "Mesh Analysis": stands for "Statistical
  visualization"? Unclear and not shown anywhere. Reuse the label
  specified in the UI code instead.
- " Output data...": remove leading space.
- "Attribute domain for the selection and group id inputs": title case
  on "Selection" and "Group ID" as that is how they appear in the UI.
- "Ior" -> "IOR": uppercase acronym, for consistency.

Pull Request: https://projects.blender.org/blender/blender/pulls/115964
2023-12-11 00:23:03 +01:00
Campbell Barton ff47eb3e37 Cleanup: minor style tweaks, surround ELEM by parenthesis 2023-12-10 17:12:53 +11:00
Campbell Barton 21fbd9dbd7 Cleanup: add missing header, sort files 2023-12-10 16:38:15 +11:00
Jeroen Bakker 65e58fe574 CMake: Fix Compiling Shader Builder on macOS
Due to changes in the build environment shader_builder wasn't able to
compile on macOs. This patch reverts several recent changes to CMake files.

* dbb2844ed9
* 94817f64b9
* 1b6cd937ff

The idea is that in the near future shader_builder will run on the buildbot as
part of any regular build to ensure that changes to the CMake doesn't break
shader_builder and we only detect it after a few days.

Pull Request: https://projects.blender.org/blender/blender/pulls/115929
2023-12-08 15:47:14 +01:00
Hans Goudey 466dca07d5 Cleanup: Move mesh visibility and selection flushing to C++ namespace
Also rename the functions and move a sculpt function that depended on
the mesh functions to a more proper place. And also use references and
nicer variable names for meshes.
2023-12-06 23:33:46 -05:00
Brecht Van Lommel e06561a27a Build: replace Blender specific DEBUG by standard NDEBUG
NDEBUG is part of the C standard and disables asserts. Only this will
now be used to decide if asserts are enabled.

DEBUG was a Blender specific define, that has now been removed.

_DEBUG is a Visual Studio define for builds in Debug configuration.
Blender defines this for all platforms. This is still used in a few
places in the draw code, and in external libraries Bullet and Mantaflow.

Pull Request: https://projects.blender.org/blender/blender/pulls/115774
2023-12-06 16:05:14 +01:00
Hans Goudey 2609f16fc8 Cleanup: Resolve inconsistent struct vs. class declaration warning
Also add a missing include in a header
2023-12-06 10:00:25 -05:00
Hans Goudey 7a96c4672c Cleanup: Move BMesh headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/115817
2023-12-05 23:01:12 +01:00
Jacques Lucke a23bd3d7f3 Nodes: add node callback for extra info that is drawn above node
This allows nodes to show some extra information next to the node. This can be
useful for debugging and will likely also be used for the new Bake node (#115466).

Pull Request: https://projects.blender.org/blender/blender/pulls/115805
2023-12-05 15:57:40 +01:00
Iliya Katueshenock 5429e006c8 Geometry Nodes: Face Group Boundaries node speedup
The multithreaded algorithm works by atomically assigning each face's
group ID to the surrounding edges. If the ID for the edge is different
than one set previously, the edge becomes a boundary.

Using the edge to face topology map was also tested, but it wasn't
faster, and given the large memory usage of the map, the increased
complexity of this algorithm was considered worthwhile.

Speed improvement for attached example file is listed in table:
| Cube resolution | Main | PR |
| -- | -- | -- |
| 20x20x20 | `71920 ns` | `97400 ns` |
| 100x100x100 | `1.27 ms` | `1.17 ms` |
| 500x500x500 | `79.37 ms` | `23.16 ms` |
| 1000x1000x1000 | `520.31 ms` | `142.21 ms` |

Pull Request: https://projects.blender.org/blender/blender/pulls/115138
2023-12-05 14:45:03 +01:00
Bastien Montagne fa25a286d8 Refactor: BKE: Move `BKE_library` header to full CPP. 2023-12-05 11:53:55 +01:00
Campbell Barton 86f1fd5d8b BLI_idprop: simplify string creation logic, support unterminated strings
- Support passing in unterminated C-strings when clamped by the size
  argument.
- Pair string and it's size arguments together in IDP_NewStringMaxSize.
- Remove redundant size check which made it seem as if the string
  might not be null terminated.
- Replace clamping the result of strlen(..) with BLI_strnlen,
  to avoid calculating the length past the size checked.
- Add doc-string for unclamped string creation.
2023-12-05 17:11:03 +11:00
Brecht Van Lommel a1804f35f7 Shaders: change default IOR from 1.45 to 1.5
To match OpenPBR and Standard Surface. Most IOR real values are in a range
of 1.3 to 1.6, might as well use the more round and common number.

Pull Request: https://projects.blender.org/blender/blender/pulls/115770
2023-12-04 21:12:29 +01:00
Habib Gahbiche 153f14be2b Compositor: Make split viewer a regular split node
Changes:
- Renamed Split Viewer Node to Split Node
- Split Node is now under `Utilities` (similar to Switch node)
- Versioning: split viewer from 4.0 and before is replaced with the new split node connected to a new viewer node.

Pull Request: https://projects.blender.org/blender/blender/pulls/114245
2023-12-03 23:20:44 +01:00
Bastien Montagne 3acb64e7ac BKE_main: move header to be a fully CPP one.
Pull Request: https://projects.blender.org/blender/blender/pulls/115681
2023-12-01 20:38:54 +01:00
Jacques Lucke 5de86fc4f8 Cleanup: make name more specific for simulations
This is necessary for the bake node (#115466).
2023-12-01 17:13:31 +01:00
Jacques Lucke b7a476ef03 Geometry Nodes: make function for mixing baked data more reusable
The bake node will need this as well (#115466).
2023-12-01 17:13:31 +01:00
Omar Emara 07e051d7cd Realtime Compositor: Implement zero cost external images
This patch implements a new mechanism for compositor results to wrap
external images, such as those cached in the static cache manager.
Thereby enabling zero cost use of those resources, which previously
needed a copy at each evaluation.

Pull Request: https://projects.blender.org/blender/blender/pulls/115574
2023-11-30 09:10:41 +01:00
Campbell Barton 3b5031f1cb Cleanup: use 'r_' prefix for output arguments, order last
Also clarify some naming.
2023-11-30 10:42:18 +11:00
Lukas Tönne 5bc82b5b7c Geometry Nodes: Remove experimental volume nodes
The new grid socket (#115270) will make these nodes obsolete and
provide more elegant ways of implementing the features. Removing
these nodes now to clean up and make future changes simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/115567
2023-11-29 16:02:06 +01:00
Jacques Lucke 7c1a0e57ca Cleanup: remove unused code 2023-11-29 14:35:04 +01:00
Jacques Lucke 7a7b7196f9 Geometry Nodes: extract global data passed to a geometry nodes invocation to separate struct
This avoids some duplication between the modifier and operator evaluation
contexts and also makes it easier to make independent from a specific
evaluation context (so e.g. the simulation nodes code shouldn't care whether
it's used from a modifier or operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/115512
2023-11-29 13:22:20 +01:00
Hans Goudey 7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Hans Goudey 21a2390f4c BLI: Add utility to reverse index mask
This utility was already duplicated in two places and planned to be used
more. While we should usually avoid creating arrays the size of the
indexed array (rather than the size of the mask), sometimes it does seem
to be the best option, and we're helped by the fact that most memory
stays unintialized for a small mask (allocating but not writing to memory
pages at all generally isn't too expensive).

Pull Request: https://projects.blender.org/blender/blender/pulls/115491
2023-11-28 17:32:17 +01:00
Ray molenkamp dbb2844ed9 Cleanup: CMake: Modernize bf_functions dependencies
Pretty straightforward

- Remove any bf_functions paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115427
2023-11-28 01:14:15 +01:00
Hans Goudey f1c0bce651 Cleanup: Use optional for original indices in extrude node
This is simpler than checking if spans are empty in separate lines.
2023-11-27 12:09:06 -05:00
Hans Goudey c31718649d Geometry Nodes: Rewrite parts of extrude mesh node
The node is still a bit non-standard in that it resizes an existing
mesh rather than creating a new one, but this commit makes the extrude
node a bit more similar to other mesh operations and makes other
miscellaneous improvements, including:
- Less use of intermediate states (compared to initial or final)
- Topology map building is no longer reimplemented for the node
- Attribute interpolation happens in a more familiar way
- Some topology maps can be skipped if a domain is empty
- More use of `IndexMask` instead of an array of indices
- Logarithmic cost index mask lookup is avoided
- Build index maps instead of implementing attribute propagation
  separately for every type

Overall these changes might improve performance in a few cases, and
they reduce Blender's binary size by 58 KB. Edge indices are different
in some cases of the edge mode, so the test files are updated.
2023-11-27 10:57:06 -05:00
Lukas Tönne 227a4eae77 Make ImplicitSharingPtr constructor from data pointer explicit
The ImplicitSharingPtr has an implicit constructor for raw pointers.
This has unintended effects when comparing an ImplicitSharingPtr to a
raw pointer: The raw pointer is implicitly converted to the shared
pointer (without change in refcount) and when going out of scope will
decrement user count, eventually freeing the data.

Conversion from raw pointer to shared pointer should not happen
implicitly. The constructor is made explicit now. This requires a little
more boilerplate when constructing a sharing pointer. A special
constructor for the nullptr is added so comparison with nullptr can
still happen without writing out a constructor.

Pull Request: https://projects.blender.org/blender/blender/pulls/115476
2023-11-27 15:53:29 +01:00
Jacques Lucke d34618e6b4 Geometry Nodes: muting zone input and output nodes is not allowed 2023-11-27 10:23:40 +01:00
Habib Gahbiche 46131a6813 Cleanup: silence warning inconsistent-missing-override
Silence warning `'call' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]`

Pull Request: https://projects.blender.org/blender/blender/pulls/115440
2023-11-27 08:01:12 +01:00
Campbell Barton 1eff48a838 Cleanup: spelling in code 2023-11-27 10:55:39 +11:00
Campbell Barton 27c660707d Cleanup: spelling in comments, variables 2023-11-27 09:54:36 +11:00
Ray Molenkamp 1b6cd937ff Cleanup: CMake: Modernize bf_imbuf dependencies
Pretty straightforward

- Remove any bf_imbuf paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115425
2023-11-25 23:37:24 +01:00
Ray Molenkamp 6b70c04724 Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any bf_depsgraph paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115422
2023-11-25 22:51:59 +01:00
Ray Molenkamp b683bcc46c Cleanup: CMake: Modernize bf_intern_clog dependencies
Pretty straightforward

- Remove any bf_intern_clog paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115323
2023-11-24 17:12:24 +01:00
Jacques Lucke cbe0cf0bb0 Geometry Nodes: add two inputs in Index Switch by default
Having this node with only a single input is not useful.
2023-11-24 09:57:38 +01:00
Jacques Lucke 8eaf89cc41 Geometry Nodes: set soft min/max in Index Switch node 2023-11-24 09:54:12 +01:00
Hans Goudey 9a28852494 Cleanup: Generalize some attribute propagation functions
Add a function that copies selected values to groups of values in the
result array. Add a runtime-typed version and a version for affecting
all attributes. Also make the "gather_group_to_group" follow the
same pattern.
2023-11-22 15:48:42 -05:00
Clément Foucault 44fa9f37eb GPUMaterial: Add volume shader flags
This allows for some optimization when we know
some effects are not present. Also this is needed
to detect the case when world contains absorption
in order to disable distant lighting.

Related #114062
2023-11-22 21:18:19 +01:00
Hans Goudey 8d5aa6eed4 Geometry Nodes: Index switch node
Add an "Index Switch" node which is meant as a simpler version of
the "Menu Switch" from #113445 that doesn't allow naming items
or displaying them in a dropdown, but still allows choosing between
an arbitrary number of items, unlike the regular "Switch" node.
Even when the Menu Switch is included (which should be in the
same release as this), it may still be helpful to have explicit mapping
of indices, and a fair amount of the internals can be shared anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/115250
2023-11-22 16:11:32 +01:00
Jacques Lucke e50a601a95 Fix: crash when getting node tree logger
It's expected that something is emplaced into `tree_logger_`
by this function in all cases, even if it's just null.
2023-11-22 14:48:51 +01:00
Hans Goudey 49087a84d0 Geometry Nodes: Use rotation socket for the object info node
See 600a133521 and #92967.
2023-11-22 08:25:32 -05:00
Omar Emara 48d7d60c96 Realtime Compositor: Rewrite inpaint node
This patch rewrites the Inpaint node in the Realtime Compositor. The old
method suffered from discontinuities and singularities in the inpainting
regions. Furthermore, it ignored semi-transparent areas.

The new method is inspired by a two pass method described by the paper:

  Rosner, Jakub, et al. "Fast GPU-based image warping and inpainting for
  frame interpolation." International Conferences on Computer Graphics,
  Vision and Mathematics. 2010.

In particular, we first fill the inpainting region using jump flooding,
then we apply a variable size blur pass whose size is proportional to
the distance to the inpainting boundary. The smoothed region is then
mixed with the input using its alpha.

The new method is much closer to the Bertalmio-style diffusion-based
inpainting methods, and thus can more accurately close holes than
existing methods.

The aforementioned method requires variable size blur, which is quite
expensive for this use case, so a new implementation was added that
approximates the method using a separable implementation, which provides
a visually pleasing result assuming a sufficiently smooth radius field,
which is true for our case since the field is an SDF.

Fixes: #114422

Pull Request: https://projects.blender.org/blender/blender/pulls/114849
2023-11-22 13:23:02 +01:00
Iliya Katueshenock 274b2dbe5e Geometry Nodes: Parallel Edges to Face Groups
This loop might be 7x faster (not whole node).
All other code is already parallel, not sure why this was disabled.
Potentially, this was missed after some cleanup.

Pull Request: https://projects.blender.org/blender/blender/pulls/115246
2023-11-21 23:40:14 +01:00
Iliya Katueshenock 33442e0992 Geometry Nodes: Edges to Face Groups speedup
Remove unnecessary N^2\n complexity. Disjoint set will join all
elements in list, even without fully-related joins. Usually cost is
small (10%~ for this specific function), but some certain files might
be 10000x slower. But that is very corner case.

Pull Request: https://projects.blender.org/blender/blender/pulls/115245
2023-11-21 23:36:41 +01:00
Iliya Katueshenock b70d387f2a Fix: Geometry Nodes: wrong field inferencing in Shortest Edge Paths node
Pull Request: https://projects.blender.org/blender/blender/pulls/115139
2023-11-21 14:52:43 +01:00
Hans Goudey 6ba9ee88c8 Geometry Nodes: Node tools: Support warnings
Warnings created during evaluation of the node group are passed as
warnings to the operator. This is done using the existing logging
system, which we could also use to get socket inspection working
in the future.

See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/115237
2023-11-21 14:27:21 +01:00
Jacques Lucke 96b3afe065 Cleanup: rename node group to group node context
`GroupNodeComputeContext` is the more correct name because it's
specifically about a group node that invokes another node tree.
The old name makes it sound like it should be used because a node group
is invoked but does not tell anything about what invoked it.
For example, the current context in a node group can also be a
`ModifierComputeContext` if that's what invoked it.
2023-11-21 14:12:23 +01:00
Hans Goudey ef3897f6a4 Fix #115202: Set Selection node crash in object mode
The geomery output wasn't set.
2023-11-20 18:17:54 -05:00
Hans Goudey f2bcd73bd2 Mesh: Move sculpt mask to a generic attribute
Store paint masks as generic float attributes, with the name
`".sculpt_mask"`. This is similar to 060a534141, which made
the same change for face sets. The benefits are general
consistency, nicer code, and more support in newer areas
that deal with attributes like geometry nodes.

The RNA API is replaced with one created in Python. The new
API only presents a single layer as an attribute class, so it
should be simpler to use in general:
- Before: `object.data.vertex_paint_masks[0].data[0].value`
- After: `object.data.vertex_paint_mask.data[0].value`

Pull Request: https://projects.blender.org/blender/blender/pulls/115119
2023-11-20 17:42:01 +01:00
Jacques Lucke a976cf4876 Cleanup: reduce boilerplate for equality operators for structs
Pull Request: https://projects.blender.org/blender/blender/pulls/115088
2023-11-20 09:39:13 +01:00
Hans Goudey 41f9f2753a Refactor: Mesh: Include wrapper positions in bounds result
Avoid the need to call the separate `BKE_mesh_wrapper_minmax` function
that dealt with the edit mesh wrapper. This makes the API inconsistent,
since other mesh functions don't implicitly deal with the wrapper.
But the bounds are a bit of a special case anyway in regard
to the GPU subdivision wrapper already, and this is much more
convenient in the rest of the refactors for #96968.
2023-11-19 18:36:19 -05:00
Hans Goudey 62b4555d01 Cleanup: Return Bounds type directly in mesh to volume code 2023-11-19 16:57:13 -05:00
Iliya Katueshenock 31abb2b3af Geometry Nodes: Edge Paths to Selection node speedup
Parallelize vertex and edge selection loops.
In a test file, the node runtime changed from 5.08 to 0.83 ms.

Pull Request: https://projects.blender.org/blender/blender/pulls/115131
2023-11-19 15:32:01 +01:00
Lukas Tönne c845233d1c Nodes: Move ValueOrField struct into blenkernel
This struct is currently defined in the `functions` module but not actually used there. It's only used by the geometry nodes module, with an indirect dependency from blenkernel via simulation zone baking. This scope is problematic when adding grids as socket data, which should not be part of the functions module.

The `ValueOrField` struct is now moved to blenkernel, so it can be more easily extended to other kinds of data that might be passed around by geometry nodes sockets in future. No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/115087
2023-11-18 13:11:39 +01:00
Hoshinova 0b11c591ec Nodes: Merge Musgrave node into Noise node
This path merges the Musgrave and Noise Texture nodes into a single
combined Noise Texture node. The reasoning is that both nodes
intrinsically do the same thing, which is the layering of Perlin noise
derivatives to produce fractal noise. So the patch de-duplicates code
and unifies the use of fractal noise for the end use.

Since the Noise node had a Distortion input and a Color output, while
the Musgrave node did not, those are now available to the Musgrave types
as new functionalities.

The Dimension input of the Musgrave node is analogous to the Roughness
input of the Noise node, so both inputs were unified to follow the same
behavior of the Roughness input, which is arguable more intuitive to
control. Similarly, the Detail input was slightly different across both
nodes, since the Noise node evaluated one extra layer of noise. This was
also unified to follow the behavior of the Noise node.

The patch, coincidentally fixes an unreported bug causing repeated
output for certain noise types and another floating precision bug
#112180.

The versioning code implemented with this patch ensures backward
compatibility for both the Musgrave and Noise Texture nodes. When
opening older Blender files in Blender 4.1 the output of both nodes are
guaranteed to always be exactly identical to that of Blender files
created before the nodes were merged in all cases.

Forward compatibility with Blender 4.0 is implemented by #114236.
Forward compatibility with Blender 3.6 LTS is implemented by #115015.

Pull Request: #111187
2023-11-18 09:40:44 +01:00
Iliya Katueshenock 8149678d5e Geometry Nodes: use dynamic declaration for some nodes
This changes a bunch of nodes that have a data type drop-down to using a dynamic
node declaration that changes based on the selected data type instead of always having
all sockets. This greatly simplifies the code and is less weird than having suffixes on
socket identifiers.

Backward compatibility and forward compatibility remain due to #113497 and #113984.

One user-visible change is that changing the data type in these nodes does not break
the link anymore.

It may be necessary to bring back some functionality from link-drag-search afterwards.

Pull Request: https://projects.blender.org/blender/blender/pulls/113553
2023-11-17 16:23:34 +01:00
Iliya Katueshenock 6e2fc77e7f Fix #114993: wrong entry in Split to Instances domain dropdown
Pull Request: https://projects.blender.org/blender/blender/pulls/115005
2023-11-16 18:29:34 +01:00
Hans Goudey 3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Hans Goudey 600a133521 Geometry Nodes: Convert four nodes to use rotation socket
Convert the vector socket from four nodes to a rotation socket, adding
versioning to insert the conversion nodes and change the default values
where necessary.
- Distribute Points on Faces
- Instance on Points
- Rotate Instances
- Transform Geometry

Implicit conversions from vectors and floats, and to vectors have been
added, though using rotation sockets directly can be faster, since converting
to and from Euler rotations is slow. Conversion nodes are not inserted
by versioning if the implicit conversions can be used.

This change is not forward compatible with 3.6, and socket values
are lost when opening 4.1 files in 4.0. The correct socket types are
added back in old versions, though newly added conversion nodes
may have to be removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/111482
2023-11-15 18:56:00 +01:00
Harley Acheson 97d1233bad Cleanup: Make format
Formatting changes resulting from running Make Format
2023-11-15 09:38:01 -08:00
Hans Goudey 3fcd9c9425 Geometry Nodes: Support node tools in object mode
Extend node tools to display tool assets in object mode as well
as edit and sculpt modes. For consistency with existing Blender
design, selection cannot be set and is just "true" in object mode
because it can't be visualized. The visibility of tools can be
customized per object type in object mode as well.

See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/114819
2023-11-15 17:01:18 +01:00
Hans Goudey 9785f2631e Mesh: Add flag to store presence of overlapping topology
For improving performance in the triangulate node (#112264), it's
helpful to know whether the mesh has edges or faces that overlap
each other. If that is known to be false, the node can skip edge de-
duplication.This might apply to the future "Replace Faces" node too.

This information is stored as a flag on the mesh and set in various
places that create "clean" new meshes. It isn't calculated lazily unlike
other other areas, because the point is to improve performance, and
the calculation probably isn't faster than the duplication check it's
meant to replace.

Pull Request: https://projects.blender.org/blender/blender/pulls/113205
2023-11-15 14:02:48 +01:00
Amine Bensalem 7010a2ee0e Geometry Nodes: Consistent name for points node geometry output
Fixed geometry node socket output name  for issue #113340 to "Points".

Pull Request: https://projects.blender.org/blender/blender/pulls/113353
2023-11-15 11:31:28 +01:00
Douglas Paul 90de0368cd Geometry Nodes: Add a Group ID input to the Fill Curve node
This adds a "Group ID" input to the Fill Curve node, per #102285.

The curve filling operation is performed separately for each group,
so curves associated with different Group IDs do not intersect.

This implementation also supports Grease Pencil 3 curves.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114048
2023-11-14 11:23:19 +01:00
Hans Goudey 0c1bb82fc4 Cleanup: Remove unnecessary struct and typedef keywords from C++ headers 2023-11-14 09:51:41 +01:00
Hans Goudey 7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +01:00
Iliya Katueshenock a1a31659ea Mesh: Make edge_other_vert function branchless
This function shouldn't return invalid index. Instead assertion in used.
While the branchless code path may not be observably faster in current
code, it should work better with instruction level parallelism in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/114682
2023-11-13 18:46:04 +01:00
georgiy.m.markelov@gmail.com 08bd7e29df MaterialX: add clamp, steps, smooth step for Map Range node
Co-authored-by: Bogdan Nagirniak <bodyan@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/114635
2023-11-13 14:27:44 +01:00
Iliya Katueshenock 5c52d42350 Cleanup: Geometry Nodes: Early returns in Shortest Edge Paths node
Pull Request: https://projects.blender.org/blender/blender/pulls/114684
2023-11-11 23:50:58 +01:00
Hans Goudey 583bd9662e Cleanup: Remove C header from C++ math header
Remove some redundancy between headers, more fully
separate the C++ headers from the older C headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/114705
2023-11-11 21:09:54 +01:00
Campbell Barton 8b4c9b294a Cleanup: quiet warning building WITH_GMP=OFF 2023-11-11 19:53:46 +11:00
Iliya Katueshenock 8618547dfe Cleanup: Geometry Nodes: General topology map creation in Shortest Edge Paths
Use general util to build mesh topology map instead of array of vectors.
This util can be optimized in future by better multithreading and new
algorithms with better CPU catch heuristics. For now this will provide
better usage of memory without a lot of small allocations.

Pull Request: https://projects.blender.org/blender/blender/pulls/114683
2023-11-10 15:20:56 +01:00
Hans Goudey d0ce1ca173 Merge branch 'blender-v4.0-release' 2023-11-09 11:58:29 +01:00
Hans Goudey 16553c2a44 Geometry Nodes: Support top-level instance meshes in boolean node
During the 2.93 to 3.0 transition, instance handling was made more
explicit in general. However, we forgot to change the boolean node,
which still implicitly gathered all the instanced meshes and fed them
to the boolean algorithm separately. We waited for the next breaking
release, 4.0 to "correct" this, and did it in fc06a471f1.
However, in that commit it was assumed that the "Self Intersection"
mode would be able to address the use case. The idea was also to push
some complexity outside of the boolean code, which is already one of
the more complex areas in Blender. Though it's possible to have a
"Group ID" or "Shape ID" input in the future as well, it's also
reasonable to expect some instances to be processed by the node,
even though it isn't quite consistent.

This commit makes a compromise by processing meshes contained by
top-level instances. We do it at this stage of the release to avoid the
breaking change.

Pull Request: https://projects.blender.org/blender/blender/pulls/114632
2023-11-09 11:54:41 +01:00
Werner, Stefan b414187efb Build: Update OpenImageDenoise to 2.1.0
Major new feature in v2 is GPU support. This is not enabled yet,
this commit only changes the library version without enabling new
functionality.

Pull Request: https://projects.blender.org/blender/blender/pulls/112143
2023-11-08 10:12:05 +01:00
Omar Emara 474b6fa070 Realtime Compositor: Support full precision compositing
This patch adds support for full precision compositing for the Realtime
Compositor. A new precision option was added to the compositor to change
between half and full precision compositing, where the Auto option uses
half for the viewport compositor and the interactive render compositor,
while full is used for final renders.

The compositor context now need to implement the get_precision() method
to indicate its preferred precision. Intermediate results will be stored
using the context's precision, with a number of exceptions that can use
a different precision regardless of the context's precision. For
instance, summed area tables are always stored in full float results
even if the context specified half float. Conversely, jump flooding
tables are always stored in half integer results even if the context
specified full. The former requires full float while the latter has no
use for it.

Since shaders are created for a specific precision, we need two variants
of each compositor shader to account for the context's possible
precision. However, to avoid doubling the shader info count and reduce
boilerplate code and development time, an automated mechanism was
employed. A single shader info of whatever precision needs to be added,
then, at runtime, the shader info can be adjusted to change the
precision of the outputs. That shader variant is then cached in the
static cache manager for future processing-free shader retrieval.
Therefore, the shader manager was removed in favor of a cached shader
container in the static cache manager.

A number of utilities were added to make the creation of results as well as
the retrieval of shader with the target precision easier. Further, a
number of precision-specific shaders were removed in favor of more
generic ones that utilizes the aforementioned shader retrieval
mechanism.

Pull Request: https://projects.blender.org/blender/blender/pulls/113476
2023-11-08 08:32:00 +01:00
Brecht Van Lommel fd60a0be38 Merge branch 'blender-v4.0-release' into main 2023-11-07 21:15:42 +01:00
Brecht Van Lommel 13b1d8d5e1 Fix build failure when WITH_USD=OFF and WITH_MATERIALX=ON 2023-11-07 20:57:35 +01:00
Brecht Van Lommel 7618d4a0ac Merge branch 'blender-v4.0-release' into main 2023-11-07 20:32:33 +01:00
Omar Emara ae739a6173 Fix #114530: Cryptomatte node not link drag searchable
The Cryptomatte node is not searchable in the link drag search operator.
That's because it still uses socket templates, which are no longer
supported for search since f5e6d4e4b0.

This patch fixes that by using the declare method instead of socket
templates.

Pull Request: https://projects.blender.org/blender/blender/pulls/114537
2023-11-07 18:44:56 +01:00