Commit Graph

120436 Commits

Author SHA1 Message Date
Jeroen Bakker
744904b0dd Merge branch 'blender-v4.5-release' 2025-06-10 10:24:44 +02:00
Jeroen Bakker
a14a844a99 Fix: #140028: Vulkan: Incorrect move of resources
Previous implementation allows to move VKBuffers, but didn't do a
proper std::move. On second thought it is a bad idea to be able to move
GPU resources. This PR removes the ability to move the buffer and
replace the usages with a unique ptr.

Pull Request: https://projects.blender.org/blender/blender/pulls/140103
2025-06-10 10:24:04 +02:00
Jeroen Bakker
cffafda2ff Fix #139898: Vulkan: Read out of bounds with color picking
The color picking reads 3 channels from a 4 channel texture. In the
common case the data conversion is required. Data conversion happens on
all 4 channels, but the backed memory only has 3 channels.

This is a workaround as the actual solution needs to work in many
different situations. Previous solution had to many issues that we
reverted the solution. This PR adds a local workaround specific to color
picking.

In Blender 5.0 we want to add test cases for all situations and
implement a solution that works better.

Pull Request: https://projects.blender.org/blender/blender/pulls/140101
2025-06-10 10:22:50 +02:00
Jacques Lucke
f62fde234f Merge branch 'blender-v4.5-release' 2025-06-10 09:51:51 +02:00
Jacques Lucke
3eab86588c Core: add id_cast function as more type-safe reinterpret_cast alternative
Currently, we are forced to use `reinterpret_cast` (or c-style-casts) when
converting between `ID` and the actual data-block types like `Object` and
`Mesh`. While `reinterpret_cast` does preserve constness, it does nothing to
make sure that a cast is actually valid. This patch adds `blender::id_cast`
which can be used as a drop-in replacement of `reinterpret_cast` in supported
cases.

It supports a couple of cases (using `Object` as example for all data-block
types):
* Convert `ID *` to `Object *`. This asserts that the conversion is valid at
  run-time if the pointer is not null.
* Convert `ID &` to `Object &`. This always asserts that the conversion is valid
  at run-time.
* Convert `Object *` to `ID *`. This is preferred over `&object->id` even if the
  result is the same because the latter results in ASAN warnings if `object` is
  null.
* Convert `Object &` to `ID &`. Added for good measure. There isn't really much
  of a benefit of this over using `object.id` except for maybe in generic code
  where the source type can be an `Object &` or `ID &`.
* Identity cast identical id types (e.g. `Object *` to `Object *`). Not really
  necessary to add a cast in such a case but may be useful in generic code where
  the input can be an `Object *` or `ID *`.

Some additional notes:
* Const-correctness is preserved with this cast.
* When attempting to do a non-id-cast, the function triggers a `static_assert`.
* The data-block types must not be just forward declarations because the actual
  type information is necessary.
* Casting to and from `void *` is not supported because that can't provide any
  additional type-safety over `static_cast`.
* Casting between different data-block types like `Object` and `Mesh` is not
  allowed.
* It does not support casting double-pointer types currently  (e.g. `ID **` to
  `Object **`).

The new cast is added in `DNA_ID.h`. As part of this patch, I also sprinkled in
a couple of `id_cast` in various places for testing (it's surprisingly tricky to
have the type checks working for all the different combinations of
pointer/referenced/constness/etc.). Replacing more existing `reinterpret_cast`
can be done separately afterwards.

It's nice that `blender::id_cast` has exactly the same length as
`reinterpret_cast`. So formatting should never change when using it in global
scope. Using just `id_cast` when inside of the `blender::` namespace is
preferable of course.

Pull Request: https://projects.blender.org/blender/blender/pulls/139820
2025-06-10 09:49:43 +02:00
Omar Emara
82ccbe7a97 Merge branch 'blender-v4.5-release' 2025-06-10 09:48:10 +03:00
Omar Emara
a48e599bea Fix #139856: Ellipse/Box mask size is clamped
The Ellipse/Box Mask nodes recently got their size clamped by their soft
limit, which was not previously the case, breaking compatibility and
limiting the node's use in some setups. The same goes for their
position. We fix this by allowing any size and position.
2025-06-10 09:45:30 +03:00
Benjamin Beilharz
3cdd38da67 Compositor: Expose EWA sampling in interpolation enum
- Adds Anisotropic (EWA) sampling to the compositor's interpolation
  enum.
- Any compositor nodes using EWA sampling are refactored and depend
  now on the interpolation enum.
- More refactoring in the RNA properties and DNA nodes to unify usage.

Pull Request: https://projects.blender.org/blender/blender/pulls/139833
2025-06-10 08:36:29 +02:00
Mohamed Hassan
3883a88d4e Compositor: Maintain alpha in Lens Distortion node
The alpha channel value was previously hard codded to one in the lens
distortion node. This patch solves that by integrating the alpha as well
in the radial distortion mode and taking the average alpha in the
horizontal case.

This breaks backward compatibility, but is what users what in most
cases, so it is acceptable.

Fixes #134658.

Pull Request: https://projects.blender.org/blender/blender/pulls/137994
2025-06-10 07:42:35 +02:00
Campbell Barton
8cdccb0154 Refactor: improve error handling for the animation player
- Pass the exit code back from WM_main_playanim instead of calling exit.
- Errors are printed to the stderr.
- Resolve some leaks on exit.

Note that this addresses noisy leaks reported by ASAN which were
flooding the output, but doesn't attempt to address all leaks.
2025-06-10 13:49:41 +10:00
Campbell Barton
1021dbf5cb Build: unbreak building with GCC 15 2025-06-10 11:18:52 +10:00
Sean Kim
2580ea8511 Merge branch 'blender-v4.5-release' 2025-06-09 18:08:48 -07:00
Sean Kim
ddcd314df4 Fix: Silence warning in BKE_brush_calc_curve_factors
Introduced in 23951e1b12

Pull Request: https://projects.blender.org/blender/blender/pulls/139977
2025-06-10 03:07:36 +02:00
Sean Kim
a1306e8b12 Merge branch 'blender-v4.5-release' 2025-06-09 16:49:06 -07:00
Sean Kim
12f4e17044 Sculpt: Assert when applying a translation that contains NaN
There have been a number of commits that have introduced regressions
in Sculpt mode where NaN begins to be propagated. While it is visually
very obvious that this is happening, this commit adds an assert so that
any automated testing with asserts on will also catch this issue.

Related to 23951e1b12

Pull Request: https://projects.blender.org/blender/blender/pulls/133992
2025-06-10 01:48:21 +02:00
Sean Kim
480adcf847 Merge branch 'blender-v4.5-release' 2025-06-09 16:47:24 -07:00
Sean Kim
44bfeb2214 Fix #140078: Sculpt Paint brushes can apply NaN
Introduced with 23951e1b12

The paint brush uses either absolute or local distance values, mapping
this distance to a brush strength requires using different values for
`BKE_brush_calc_curve_factors` and cannot just use
`calc_brush_strength_factors`. To fix this, use the more generic method
instead to allow passing the correct radius.

Pull Request: https://projects.blender.org/blender/blender/pulls/140084
2025-06-10 01:46:09 +02:00
Sean Kim
c22ce4674b Merge branch 'blender-v4.5-release' 2025-06-09 13:11:20 -07:00
Sean Kim
1131254644 Fix #139969: Clay Strips brush can corrupt mesh
Introduced with 23951e1b12.

When using brushes that use a cube distance, some distances are set to
be float::max(). This breaks assumptions made inside the previously
linked commit, as the operations inside `BKE_brush_calc_curve_factors`
can easily cause this distance value to become infinity, which when
multiplied with the factor value of 0 results in NaN propagation in the
mesh.

To fix this, set the max distance in `calc_cube_distance` to 1.0f.

Pull Request: https://projects.blender.org/blender/blender/pulls/139965
2025-06-09 22:06:23 +02:00
Hans Goudey
fa03c53d4a Point Cloud: Use AttributeStorage instead of CustomData
This moves `PointCloud` to use the recently added `AttributeStorage`
at runtime. Mainly this involves implementing the higher level attribute
API on top, and implementing the RNA API as well. The attribute RNA type
is now backed by either CustomDataLayer or bke::Attribute. For now the
new code is specific to point clouds but next steps can reuse it for
Grease Pencil layer attributes, curves, and eventually meshes.

Point cloud attributes no longer have a name length limit.

Internally, the `AttributeStorage` API is extended with a few additions:
- The data structs have static constructors for convenience.
- A few functions give index-based access to attributes
- A "rename" function is added.

The `Attribute` RNA type now exposes a `storage_type` property.
For now the "single value" option is still unused at runtime, and
accessing the single value data isn't implemented yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/139165
2025-06-09 21:53:20 +02:00
Miguel Pozo
2acb65a7d5 Draw: Remove direct use of duplis from engine code
Required for grouping multiple `Object`s into a single `ObjectRef`.
Part of https://projects.blender.org/blender/blender/issues/130291#issuecomment-1586807

Pull Request: https://projects.blender.org/blender/blender/pulls/139855
2025-06-09 19:10:12 +02:00
Harley Acheson
9f85d1ae69 Merge branch 'blender-v4.5-release' 2025-06-09 09:01:41 -07:00
Harley Acheson
7c013f9ea8 Fix #134599: Win32 Automatically Detect Language for Chinese Variations
On the Windows platform if you select "Automatic" for language, it
won't actually select correctly for the Chinese languages. This is
because our Windows code returns a locale like ""zh_CN" or "zh_TW",
not the "zh_HANS" and "zh_HANT" expected. This PR checks for language
code "zh" and will then will append "_HANT" if your 2-letter region
is TW (Taiwan), HK (Hong Kong), or MO (Macau), and "_HANS" for other
regions (like China, Malaysia, Singapore, etc).

Pull Request: https://projects.blender.org/blender/blender/pulls/140027
2025-06-09 18:00:16 +02:00
Bastien Montagne
bcc57c1d5c Merge branch 'blender-v4.5-release' 2025-06-09 17:12:23 +02:00
Bastien Montagne
675438d331 Fix: Append: Error message when appending liboverrides.
Depending on things like order or processing etc., appending
liboverrides data could generate error message in the console regarding
invalid override hierarchy data.

While this could probably be solved, it feels fairly brittle and risky
to directly make linked liboverride hierarchies locale anyway, so just
alsways make local copies of these on append.
2025-06-09 17:11:50 +02:00
Jacques Lucke
d9138d6689 Fix #133738: missing update when input of zone without link changes
Some zones implicitly pass inputs through to the output, even if there is no
actual link from the zone input to the zone output node.

Pull Request: https://projects.blender.org/blender/blender/pulls/140055
2025-06-09 16:39:31 +02:00
Jacques Lucke
af3f9ac66e Fix #138085: Nodes: allow panel toggles in panels with outputs
Currently, there is the general rule that outputs must be above inputs in any
given panel. Since internally a panel toggle input is part of the panel that it
toggles and has to be the first item in a panel, it was not possible to have a
panel toggle for a panel with outputs.

This patch relaxes the rule for ordering of inputs and outputs for the special
case of panel toggles.

Pull Request: https://projects.blender.org/blender/blender/pulls/140054
2025-06-09 16:09:27 +02:00
Falk David
f7a0003452 Grease Pencil: Motion Blur support
This adds motion blur support for Grease Pencil.

We follow the same principle form EEVEE and use the existing
`antialiasing_accumulate` (SSAA) function to accumulate the
frames in range of the motion blur over time.

There is a new `motion_blur_steps` setting in the Grease
Pencil render settings to control the accuracy of the motion
blur. This will increase the render time.

Limitations:
* When Grease Pencil is composited into the scene, we only do
  it for one the current frame and don't take the motion blur into
  account. This will lead to hard edges currently.
* There is no viewport motion blur. This would need an entirely
  new technique that can be computed in real-time.

Pull Request: https://projects.blender.org/blender/blender/pulls/139840
2025-06-09 15:44:53 +02:00
Clément Foucault
24ee70553a Fix: Overlay: Shader compilation warnings
This is because we now use enums instead of defines.

Pull Request: https://projects.blender.org/blender/blender/pulls/140044
2025-06-09 15:33:13 +02:00
Jacques Lucke
1e39da6e98 Fix #139752: missing update when changing camera parameters
Not only depend on the camera position but also on the other camera parameters.
This is important because otherwise Geometry Nodes won't be updated when e.g.
the focal length changes which is important when implementing e.g. camera
culling.

This already works when depending on a specific camera directly, but not when
depending on the active camera.

Pull Request: https://projects.blender.org/blender/blender/pulls/140046
2025-06-09 15:17:58 +02:00
Jacques Lucke
9a56d1a13f Fix #138654: reset menu socket to default value does not work
To make this work, I had to add a new rna callback to get the default value for
an enum property at run-time. The same exists for other property types like
float and bool already.

Pull Request: https://projects.blender.org/blender/blender/pulls/140050
2025-06-09 15:17:11 +02:00
Pratik Borhade
7aa0981da4 Fix #139705: Generate undo step after cancelling node.join_named
In macro operator `NODE_OT_join_named`, panel is called to name the
frame after execution of `node.join`. This panel returns
`OPERATOR_INTERFACE` to `wm_macro_invoke_internal/wm_operator_invoke`.
This prevents from generating an undo step for node.join because retval
is not `OPERATOR_FINISHED`. Hence, `wm_operator_finished` is not
called which actually calls the function to create undo step. To fix
this, adjust condition in `wm_macro_end` so that retval is "FINISHED"
when first operation is executed successfully while later is in
`OPERATOR_INTERFACE` state

Pull Request: https://projects.blender.org/blender/blender/pulls/139712
2025-06-09 14:42:38 +02:00
Falk David
d4c143957f Merge branch 'blender-v4.5-release' 2025-06-09 14:16:12 +02:00
casey-bianco-davis
672d8cfc6f Fix #130597: Grease Pencil: Brush cursor radius not working in perspective projection.
This fix make it so that the brush cursor is always the same size as
the drawn strokes.

The code logic is modified from `pixel_radius_to_world_space_radius`
in `grease_pencil_utils.cc`

Co-authored-by: Falk David <falk@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/139964
2025-06-09 14:14:31 +02:00
Weizhen Huang
ee578cc738 Fix #139753: Discontinuity in mesh tangent without UV map
when there is no uv, we call the function `map_to_sphere()` to create
temporary uv for computing the tangent. It could happen that a triangle
has vertices with the u coordinates going across the line where u wraps
from 1 to 0. In this case, just computing the difference of the u
coordinates results in the wrong triangle area.

To fix this problem, we compute distance in toroidal (wrap around)
space.

This is safe for coordinates generated by `map_to_sphere()` function,
because it is not supposed to map the positions of a triangle to u
coordinates that span larger than 0.5.

Pull Request: https://projects.blender.org/blender/blender/pulls/139880
2025-06-09 13:52:00 +02:00
Clément Foucault
1c47e31367 GPU: Enable GL multithreaded compilation by default
This allows to reduce the waiting time caused by
shader compilation on some GPU-driver combo.

A new settings in the User Preferences make it
possible to override the default amount of worker
threads and optionally use subprocesses.

We still use only one worker thread in cases where
there is no benefit with adding more workers
(like AMD pro driver and Intel windows).

It doesn't scale as much as subprocesses for material
shader compilation but that is for other reasons
explained in #139818.

Add some heuristic to avoid too much memory usage
and / or too many stalls.

Also add some heuristic to the default number of subprocess for
the platform that shows scalling.

Historically, multithreaded compilation was prevented by the
need of context per thread inside `DRWShader` module.
Also there was no good scaling at that time. But
nowadays numbers shows different results with
good scaling with reasonable amount of threads on many
platforms.

Even if we are going for vulkan in the next release
most of the legacy hardware will still use OpenGL for
a few other releases. So it is relevant to make this
easy improvement.

See pull request for measurements.

Pull Request: https://projects.blender.org/blender/blender/pulls/139821
2025-06-09 12:36:06 +02:00
Jacques Lucke
b58c5f6e77 Fix #139172: group outputs show up in link-drag-search incorrectly 2025-06-09 12:15:15 +02:00
Jacques Lucke
9efc23bb69 Fix #140018: no warning when using bake node or simulation in zone
Baking and storing simulation state within loops or closures is not supported.
Previously, attempting to use the bake node or simulation zone in such a zone
would just silently fail. Now there is an error on the node and the bake
settings are grayed out.

Pull Request: https://projects.blender.org/blender/blender/pulls/140041
2025-06-09 12:08:24 +02:00
Aras Pranckevicius
f685f23434 ImBuf: Remove pre-2.80 Texture mipmaps/filters
Removes various image filtering/mipmapping leftovers from
pre-2.80 days.

Code: removes all mipmap handling from ImBuf (which is about half of
ImBuf struct size), removes now unused "sample procedural texture
with mipmaps" code, now-unused FELINE filter, etc. The osatex
parameter to various CPU texture sampling functions is never
actually used, which means none of the mipmap code was ever executing.

User visible part: there were settings on the legacy Texture data
block (as used by Brushes etc.), under Sampling section: "MIP Map",
"Gaussian Filter", "Filter Type", "Eccentricity", "Minimum Size" --
they had no effect anywhere, so they are gone, and what remains is
only "Interpolation" and "Size".

RNA / Python API part: removes the ImageTexture RNA properties
corresponding to the above: filter_type, use_mipmap, use_mipmap_gauss,
filter_lightprobes, filter_eccentricity, use_filter_size_min.

Pull Request: https://projects.blender.org/blender/blender/pulls/139978
2025-06-09 11:35:19 +02:00
Jacques Lucke
3ee94825ce Merge branch 'blender-v4.5-release' 2025-06-09 10:04:31 +02:00
Jacques Lucke
a8e461f2de Fix #139985: refit column width when data type changes 2025-06-09 10:03:16 +02:00
Jacques Lucke
60411de509 Merge branch 'blender-v4.5-release' 2025-06-09 09:10:37 +02:00
Jacques Lucke
3ce212b9ac Fix #139981: volume transform crash with bad matrix 2025-06-09 09:09:18 +02:00
Jeroen Bakker
1ad6749a85 Revert "Fix #139898: Vulkan: Asan issue during color picking"
Fix introduces many issues. We should fix the asan issue locally

This reverts commit c5317faec4.
2025-06-09 08:56:28 +02:00
Jacques Lucke
b5cb9a2e56 Merge branch 'blender-v4.5-release' 2025-06-09 08:51:08 +02:00
Jacques Lucke
cd789b2c49 Fix #140014: enforce minimum width when creating group from reroute node
Also unifies the min/default/max width of all group nodes. The minimum width
has been increased from 40 to 60 for Geometry Nodes because there was is
an assert when the node was that thin already. The other group nodes already
used 60 as min width.
2025-06-09 08:50:46 +02:00
Jacques Lucke
37388aaabf Merge branch 'blender-v4.5-release' 2025-06-09 08:31:09 +02:00
Jacques Lucke
101b94fe92 Fix #140017: creating a node group from Bake node crashes
Extension sockets were not handled correctly. Those are not
exposed in the group.
2025-06-09 08:30:03 +02:00
Jacques Lucke
fd2be0026a Fix #137236: performance regression with nonsensical face material indices
From what I know, we don't really have a good way to detect whether a material
index is non-sensical in the right places. That's because the same material
index on a mesh may not make sense on one object but can still make sense on
another. This is the issue we fixed in the first place when the regression was
introduced.

What we can do though is to check which exact material indices a mesh is
actually using (not just the maximum). This allows us to skip a lot of work for
unused material indices. This doesn't help when a mesh has thousands of unique
non-sensical material indices, but it should be an improvement in the majority
of cases.

This patch adds a cache of used material indices to `Mesh`. The drawing code
requests that cache if the maximum material index is above some threshold (16
currently). We don't want to compute it all the time, because it requires
iterating over the mesh (at least once, then it is cached). So it's only worth
the extra cost of the there is at least one large material index. The threshold
also ensure that the large majority of scenes is not affected by this patch
performance wise.

Pull Request: https://projects.blender.org/blender/blender/pulls/139781
2025-06-09 08:10:48 +02:00
Richard Antalik
2d401abc10 Merge branch 'blender-v4.5-release' 2025-06-09 03:23:26 +02:00