Commit Graph

119472 Commits

Author SHA1 Message Date
Sergey Sharybin
bbfc97ad6f Move tests/data and assets to the main repository
This change moves the tests data files and publish folder of assets
repository to the main blender.git repository as LFS files.

The goal of this change is to eliminate toil of modifying tests,
cherry-picking changes to LFS branches, adding tests as part of a
PR which brings new features or fixes.

More detailed explanation and conversation can be found in the
design task.

Ref #137215

Pull Request: https://projects.blender.org/blender/blender/pulls/137219
2025-05-05 15:10:22 +02:00
Omar Emara
1f51172692 Compositor: Turn Alpha Over options to inputs
This patch turns the options of the Alpha Over node into inputs.

In the process, Convert Premultiplied option was renamed to Straight
Alpha.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138441
2025-05-05 14:16:27 +02:00
YimingWu
787f7272ae Fix #138439: Annotation: Correct immVertex when drawing stabilizer
the float/int version of `immVertex` can not be mixed in one
`immBegin/End` block. This fix corrects the usage and prevent invalid
int values from passing into the batch.

Pull Request: https://projects.blender.org/blender/blender/pulls/138442
2025-05-05 13:45:36 +02:00
Clément Foucault
7aef8c2917 GPU: Shader Preprocess: Add utility to search for references
This utility will only match `&` character inside a
reference declaration. This is needed for speeding up the
regex matches.
2025-05-05 13:42:42 +02:00
Clément Foucault
74e6d2c575 GPU: Shader: Add support for basic loop unrolling through preprocessor
This adds basic unrolling support for 2 syntax:
- `[[gpu::unroll]]` which does full loop unrolling
- `[[gpu::unroll(x)]]` which unrolls `x` iteration

Nesting is supported.

This change is motivated by the added cost in compilation
and execution time that some loops have even if they have
compile time defined iteration counts.

The syntax is inspired by `GL_EXT_control_flow_attributes`.
However, we might want to have our own prefix to show it is
a blender specific feature and that it differs from the standard.
I propose `[[gpu::unroll]]`.

In the future, we could extend this to support more directives that
can be expanded to backend specific extension / syntax. This would
avoid readability issue an error prone copy paste of large amount
of preprocessor directives.

Currently, given that GL's GLSL flavor doesn't support
any of these attributes, the preprocessor does some copy-pasting
that does the unrolling at the source level. Note that the added
`#line` allow for correct error logging.

For the `[[gpu::unroll]]` syntax, the `for` declaration
needs to follow a specific syntax to deduce the number
of loop iteration.
This variant removes the continue condition between iteration,
so all iterations are evaluated. This could be modified
using a special keyword.

For the `[[gpu::unroll(n)]]` syntax, the usercode needs
to make sure that `n` is large enough to cover all iterations
as the loop is completely removed.
We could add shader `assert` to make sure that there is
never a remaining iteration.
This behavior is usually different from what you see in other
implementation as we do not keep a loop at all. Usually, compilers
still keep the loop if it is not unrolled fully. But given we don't
have IR, this is the best we can do.

`break` and `continue` statement are forbidden at the unrolled loop
scope level. Nested loop and switch can contain these keywords.
This is accounted for by checks in the pre-processor.

Only `for` loops are supported for now. There are no real
incentive to add support for `while` given how rare it is
in the shader codebase.

Rel #137446

Pull Request: https://projects.blender.org/blender/blender/pulls/137444
2025-05-05 13:37:51 +02:00
Jacques Lucke
c271c3b291 Fix: ID code not should not be passed as part of name
Found in #138383.
2025-05-05 11:47:42 +02:00
YimingWu
e441095edb Fix #137918: LineArt: Prevent invalidating the wrong cache
When baking multiple line art modifiers at once, line art can pick the
wrong cache data and free it before all modifiers have finished baking.
This fix corrected that logic so that when baking all line art, it will
always use/create/free the correct cache data.

Pull Request: https://projects.blender.org/blender/blender/pulls/138114
2025-05-05 11:03:58 +02:00
Clément Foucault
a14fa6bfe5 GPU: Shader Preprocess: Add string utilities
Allow faster and more robust parsing / mutation.
2025-05-05 11:03:36 +02:00
Omar Emara
ebe67e5ca0 Compositor: Remove Premultiplied option from Alpha Over node
This patch removes the Premultiplied option from the Alpha Over node.
The reasoning is as follows:

- The option mixed between alpha being straight and premultiplied, a
  state which doesn't happen in practice.
- The option conflicts with the Convert Premultiplied option, if it is
  not zero, then Convert Premultiplied does nothing.
- The option is implemented in a lossy way. It premultiplies the alpha
  assuming it is straight, then converts the result to straight again,
  then mixed between both results. This is as opposed to mixing the
  original straight input with the premultiplied input. The successive
  alpha conversion causes data loss in transparent regions.

Pull Request: https://projects.blender.org/blender/blender/pulls/138428
2025-05-05 10:51:34 +02:00
Falk David
a7d2b7850e Grease Pencil: Add initial support for Node Tools
This adds inital Grease Pencil support for node tools.

Node tools work in `Object Mode`, `Edit Mode`,`Sculpt Mode`,
and `Draw Mode`.

While Grease Pencil has many editing tools, including editing
multiple frames at the same time, for now, node tools only
allow editing the current frame.

Currently, the idea is that node tools can do arbitrary changes
to the drawings, but cannot do changes to the existing layer tree, e.g.
changing the order of layers, removing a layer or groups, etc.

All the node tool specific nodes like `Selection` and `Set Selection`
are adapted to work with Grease Pencil. In `Draw Mode`, we currently
interpret everything as selected.
The `Active Element` node has a `Layer` mode that provides the
index of the active layer (if there is one).

When `Auto-Key` is used, a new keyframe is created on the
current frame.
Locked/invisible layers cannot be edited with node tools.

Pull Request: https://projects.blender.org/blender/blender/pulls/136624
2025-05-05 10:41:21 +02:00
Clément Foucault
8dee08996e GPU: Shader: Add wrapper to stage agnostic function
This avoid having to guards functions that are
only available in fragment shader stage.

Calling the function inside another stage is still
invalid and will yield a compile error on Metal.

The vulkan and opengl glsl patch need to be modified
per stage to allow the fragment specific function
to be defined.

This is not yet widely used, but a good example is
the change in `film_display_depth_amend`.

Rel #137261

Pull Request: https://projects.blender.org/blender/blender/pulls/138280
2025-05-05 09:59:00 +02:00
Omar Emara
92ac9f3b25 Compositor: Remove Premultiplied option from Brightness node
This patch removes the Convert Premultiplied option from the Brightness
and Contrast node. The reasoning is that it is the only node that has
the option to operate on straight alpha, while not being particularly
different. Adding alpha conversion nodes around it is also very easy.
Furthermore, alpha conversion is a lossy operation, so the option looses
data in emissive pixels, and since it is enabled by default, users not
familiar with the exact mechanism of the option wouldn't know how to fix
this.

Pull Request: https://projects.blender.org/blender/blender/pulls/138318
2025-05-05 08:33:29 +02:00
Daniel Salazar
a36c9adfe4 Fix: Description error in uv_layers.remove()
Description for uv_layers.remove() is wrong, copy paste error.

Pull Request: https://projects.blender.org/blender/blender/pulls/124940
2025-05-05 08:28:21 +02:00
Sean Kim
bf0018d75b Cleanup: Add comment for tilt_sensitivity constant
Derived from discussions on D8893

Pull Request: https://projects.blender.org/blender/blender/pulls/138417
2025-05-05 04:45:48 +02:00
Hans Goudey
91c340a1a5 Cleanup: Remove redundant break after return in switch 2025-05-04 22:07:23 -04:00
Hans Goudey
beadd08fb7 Fix: A few small issues with spreadsheet row filters
- int2 and short2 filters were completely disfunctional
- Don't use threshold for integer comparisons; it's not in the UI
- Filter with geometry set name for instance "Name" column
2025-05-04 22:07:23 -04:00
Nicola
33bef53c3e Sculpt: Use box test to select BVH nodes affected by Clay Strips
Implements a box test to select nodes affected by Clay Strips. The ratio
of nodes selected compared to the sphere test depends heavily on the
mesh, but is generally between 50% and 70%. This results in better
performance and reduces memory usage.

Pull Request: https://projects.blender.org/blender/blender/pulls/138170
2025-05-05 04:01:01 +02:00
Clément Foucault
c0f191f580 GPU: Make polylines vertex shader use C++ shader compilation
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/138411
2025-05-05 00:44:34 +02:00
Mattias Fredriksson
8d06479d24 Fix #137057: Sample Single Point Curves
Fixes behavior for #137057 when sampling single point curves.
Previous behavior just checked the evaluated length cache size and
called fill_invalid(), it will now fill using the point value and terminate.

Pull Request: https://projects.blender.org/blender/blender/pulls/138153
2025-05-04 16:31:58 +02:00
илья _
aa2ca33da2 Fix #137064: Nodes: Some nodes have a blank header when no datablock is selected
Similar to Mix node in #135535, some nodes did not properly implement a
callback to provide a UI node name.

Pull Request: https://projects.blender.org/blender/blender/pulls/137065
2025-05-04 11:37:07 +02:00
Jacques Lucke
5dd37abfbf Fix: Nodes: new empty frame node is always at origin
Now, when a new frame node is added while no node is selected,
it will be added at the cursor.
2025-05-04 09:40:22 +02:00
YimingWu
884ef238c0 Fix #136397: Line Art: Skip dupli objects with include_objects
Previously to handle unevaluated objects in line art "load all"
iteration, a `include_objects` variable is added in depsgraph
iteration settings, and this was only processed by object iterator
but not for any of the dupli objects. Now `make_duplis_collection`
will also handle `include_objects`

The only case where this border case can lead to crash is that a
line art grease pencil object is inside one of the dupli collection,
which isn't a valid use in the first place. But this fix makes it
more robust.

Pull Request: https://projects.blender.org/blender/blender/pulls/137323
2025-05-04 08:20:06 +02:00
Jacques Lucke
327ac569b2 Geometry Nodes: show node timings for import nodes 2025-05-04 05:44:52 +02:00
Sean Kim
6ec5ad88b9 Fix: Making a brush local doesn't set user count correctly
When copying a brush from a linked library to the current main, the fake
user flag is set, but the user count is set to 0. This later means that
saving such a file does not persist the brush datablock, and the
associated invariants are violated.

Related to / Found in #138105

Pull Request: https://projects.blender.org/blender/blender/pulls/138243
2025-05-04 01:25:05 +02:00
Hans Goudey
71ac8eee68 Cleanup: Use const arguments for realize instances function
OrderedAttributes was passed by value unnecessarily.
2025-05-03 15:25:24 -04:00
Guillermo Venegas
9e5151d294 Refactor: UI: Replace uiLayoutSplit with class method uiLayout::split
This converts the public `uiLayoutSplit` function to an object oriented
API (`uiLayout::split`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

`uiLayout::split` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138361
2025-05-03 20:51:42 +02:00
Mukhesh
5055a4e5a3 FIX: Select operators in Sequencer Preview
Behavior of select all operator invoked by shortcut was inconsistent
with menu. This was, because operator context was not set.

Also the selection in timeline is cleared when running this operator
as not doing it may cause unexpected behavior for users.
Selection invert also follows the same behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/137713
2025-05-03 02:20:56 +02:00
Campbell Barton
7d97ba4c5f Cleanup: use float2, int2 types for cursor drawing callbacks
Ref !138172
2025-05-02 23:01:29 +00:00
Hans Goudey
ae2c601a0c Fix: Curves split/separate points operators lose vertex group status
The fix is only clearly correct if `copy_data_to_geometry` returns by value.
2025-05-02 14:39:20 -04:00
Guillermo Venegas
5dc86dacda Refactor: UI: Replace uiLayoutBox with class method uiLayout::box
This converts the public `uiLayoutBox` function to an object oriented
API (`uiLayout::box`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

`uiLayout::box` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138334
2025-05-02 19:46:26 +02:00
Bastien Montagne
b1fd91c2c0 Fix #138329: Workbench Material color type broken for meshes with no material.
Regression from 368c737fe7. Forgot to fully move to using
`BKE_id_new_nomain` at some point for default materials, instead
of doing more low-level set of 'alloc liblock, initialize it with
default values'.
2025-05-02 18:58:15 +02:00
Miguel Pozo
f24ad7a470 Build: Add WITH_OPTIMIZED_BUILD_TOOLS
Enable optimizations on Debug builds for executables used for the build
process (datatoc and glsl_preprocess) and enable unity builds for
shader preprocessing targets.

Debug: From 28.9s to 5.7s
Release: From 4.9s to 3.5s

Pull Request: https://projects.blender.org/blender/blender/pulls/138274
2025-05-02 18:33:44 +02:00
Hans Goudey
37dcdb2b6a Depsgraph: Avoid quadratic overhead when building collection relations
Checking whether relations already existed was a bottleneck when building
collection -> object hierarchy relations. The duplicate checking would be
unnecessary since an object can only be in a collection once, but this function
to build relations can be called multiple times for the same collection.

To avoid the need to check for duplicates, only run the relation creation
once for each collection. The `BuilderMap` gives a simple way to do that.
Note that because a collection might be built separately as a non-layer
collection, there may still be duplicate hierarchy relations.

Building a Depsgraph for 60k simple objects became 1.86x faster, from 2.39
to 1.29 seconds.

Pull Request: https://projects.blender.org/blender/blender/pulls/137737
2025-05-02 17:51:10 +02:00
Brecht Van Lommel
321e9e049e Fix: USD material reader uses fixed colorspace names
For other OpenColorIO configurations these may not exist or have a
different meaning.
2025-05-02 17:39:56 +02:00
Brecht Van Lommel
af4a7efaed Fix #138262: Movie file colorspace can't be changed
Regression from recent ccd7bc2078, restore previous logic and add
comments.
2025-05-02 17:39:56 +02:00
Laurynas Duburas
45a2634917 Fix: Curves: "Separate" in point selection mode loses boundary segments
The current code doesn't include selection boundary points in non-
selected curves after separation, causing some segments to be lost.
Legacy curves do include those points. The second issue is with cyclic
curves. The current version leaves the separated part cyclic, though
the more intuitive behavior would be cut off the result. This is also
different from legacy curves. This commit fixes both issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/135035
2025-05-02 17:30:02 +02:00
Sergey Sharybin
5b29ba488f Color management: Implement shader to convert to scene linear
Previous conversion to scene linear was done in the display transform
shader. Having a separate shader to convert texture to scene linear
allows drawing input textures with different color spaces into a
viewport and apply display transform on all of them.

Currently unused, but is required for !138094. It could also be used
in the future to avoid host-side linearization in the image engine.

Internally it uses a lot of the same logic for shader caching and
binding, but the code is refactored a bit to make it easier to have
a stronger separation in the future if needed.

Ref #138094

Pull Request: https://projects.blender.org/blender/blender/pulls/138308
2025-05-02 16:51:46 +02:00
Sergey Sharybin
a26ed85adf Fix: Wrong ID type used to create Lookdev world
Fixes incorrect render of lookdev on macOS.
There might have been some other issues caused by the mistake, hard to say,
seems to be hitting some platform-specific behavior and such.
2025-05-02 16:30:44 +02:00
Falk David
a1b92f91b7 Fix #137990: Grease Pencil: Crash when creating library override
There were two issues:
* Some rna properties to access members in the layer tree were missing
  `PROPOVERRIDE_NO_COMPARISON`.
* In `rna_Attributes_noncolor_layer_skip` the wrong `AttributeOwner`
  was created.

Pull Request: https://projects.blender.org/blender/blender/pulls/138324
2025-05-02 16:15:34 +02:00
Hans Goudey
ed68c0a635 Cleanup: Clarify instances almost unique IDs cache
Use the safer VArraySpan instead of get_internal_span(). And remove
the size check for the output data. If the callback inside `ensure` is
called it means that recomputing the data is necessary, regardless of
the array's current size.
2025-05-02 10:11:29 -04:00
Sergey Sharybin
b1c8f90b32 Math: Use lvalue ref-qualifier for compound assignment operators
The goal is to make issues like the ones fixed in #138310 become visible
much earlier in the development cycle.

This PR covers the most obvious places where it could be applied. There
are probably more places, but they can be covered later.

Pull Request: https://projects.blender.org/blender/blender/pulls/138315
2025-05-02 15:25:32 +02:00
Jacques Lucke
e8d1491e62 Refactor: Depsgraph: simplify query API further
* Remove `DEG_get_evaluated_object` in favor of `DEG_get_evaluated`.
* Remove `DEG_is_original_object` in favor of `DEG_is_original`.
* Remove `DEG_is_evaluated_object` in favor of `DEG_is_evaluated`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138317
2025-05-02 15:08:29 +02:00
Campbell Barton
f59cd876ad Cleanup: ensure logically correct sort callback (id_order_compare)
Ref: !138299
2025-05-02 22:39:41 +10:00
Bastien Montagne
276fac2294 Harden blendfile reading against fully corrupted input data.
'Fixes' the "curveprofile" case of #137870, by immediately crashing
on nullptr access instead of allowing readfile code to further access
memory detected as invalid (which would most likely lead to a crash
later anyway).

I don't think we can expect readfile code to gracefully abort at such a
low-level error detection, not without using some form of exception
handling at least? Otherwise the whole readfile code would have to
constantly check for invalid flag in the Mains.

Pull Request: https://projects.blender.org/blender/blender/pulls/138145
2025-05-02 14:29:11 +02:00
Bastien Montagne
368c737fe7 Core: Fix/refactor invalid logic around handling of 'default materials'.
These were handled mostly completely outside of IDManagement code, yet
(ab)using the same ID management system in some cases, adding hacks to
address some issues, etc.

Also address a similar issue in the eevee lookdev `LookdevWorld` code.

Since initializing pre-allocated (or static) buffers as valid IDs is not
currently supported, and these use-cases do not seem common enough to be
worth supporting it currently, instead switch to storing allocated IDs
into static pointers.

This allows to use proper 'out-of-main' ID creation code API.

NOTE: There are still some remaining issues, especially in the GP
material BKE api. These are noted in comments for now, as it would be
out of scope to address them in this commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/138263
2025-05-02 14:09:53 +02:00
Julian Eisel
58247efc69 Refactor: Assets: Use weak reference comparison to lookup assets
Comparing paths is tricky, especially when different operating systems
are involved, with different slashes, encodings, etc. So often a string
comparison is not good enough. Use asset weak reference comparison for
this case, which performs more careful path comparisons.

Not sure if this makes a difference in practice. But it might solve some subtle
issues, and it makes some more sense semantically. So I think it's worth
trying. Originally I was hoping this would fix #123508, but apparently didn't

Pull Request: https://projects.blender.org/blender/blender/pulls/127685
2025-05-02 13:35:34 +02:00
Jeroen Bakker
098990b172 Fix: Vulkan: Revisited samplers
Implemented the VKSamplers based on the documentation in GPU_texture.hh.
They used to be reversed engineered from the OpenGL backend, however
Vulkan has better control over mipmap filtering and OpenGL needed to
combine some flexibility inside the min/mag filtering.

Changes:
- Mipmap filtering was always on, not only when `GPU_SAMPLER_FILTERING_MIPMAP`
  is used.
- Mipmap filter mode is always set to linear. This is not according to the
  documentation, but matches OpenGL and the render tests.

Fixes #136439, #138111
Partial fix #137436 - seam isn't there, inf can still be part of the
texture.

Pull Request: https://projects.blender.org/blender/blender/pulls/138313
2025-05-02 13:24:06 +02:00
Omar Emara
4cb69dafb0 Compositor: Remove Use Alpha option from Composite and Viewer node
This patch removes the Use Alpha option from Composite and Viewer nodes.
The reasoning for the removal is as follows:

- It has an unintuitive complicated design at the moment.
  - If the Alpha Input is unlinked, the output alpha is not adjusted
    even if Use Alpha is enabled, leaving users wondering why their
    adjustments have no effect.
  - Disabled Use Alpha means output an opaque image, that is, it
    actually means Ignore Alpha. Which is confusing because users might
    think that it controls alpha adjustments based on input.
- It always does alpha replacement without premultiplication, which is
  not clear to the user and is not what the user wants in most cases.
- Adding a Set Alpha node before the output is pretty easy and clear, so
  the option seems redundant considering the above.

Pull Request: https://projects.blender.org/blender/blender/pulls/138309
2025-05-02 12:50:58 +02:00
Jeroen Bakker
d77fb1fb0e Fix #138149: Vulkan: Update descriptor pool sizes
Update descriptor pool sizes to be better for smaller scenes. Creating,
resetting and destroying pools are expensive operations. In smaller
scenes this can lead to lower performance.

The  improvements may differ per platforms or not be visible.

Pull Request: https://projects.blender.org/blender/blender/pulls/138300
2025-05-02 12:42:20 +02:00
Lukas Tönne
deddc6f18c Fix #137913: Grease Pencil: Fallback for looking up material index attribute
The "material_index" attribute is expected to exist by many operations,
but that is not always the case. Using a fallback value prevents crashing
in case the attribute has been removed. A default material is already
supported when the index is not in range of the actual material slots on
an object or grease pencil data block respectively.

Pull Request: https://projects.blender.org/blender/blender/pulls/138303
2025-05-02 12:34:49 +02:00