Commit Graph

150077 Commits

Author SHA1 Message Date
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
204050d1a3 Fix #115714: Change OpenColorIO abort to CLOG_ERROR
OpenColorIO exceptions would abort when WITH_ASSERT_ABORT is enabled.
But these do not generally indicate a bug in Blender. They may just be a
blend file using an unknown color space, or an error loading the
configuration file, which we can handle gracefully.
2025-05-02 17:39:56 +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
Julien Duroure
0fa57b7774 glTF Exporter: Restore animation hook after slots management 2025-05-02 16:19:59 +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
Julien Duroure
c52b5387ba glTF exporter: Add mapping parameter in gather_image_hook
This is a breaking change for this hook in 4.5
2025-05-02 16:03:22 +02:00
Sybren A. Stüvel
f6167aab31 Anim: name new action slots after the last-used slot
When creating a new action slot for a data-block, via the '+ New' button
of the slot selector, use the name of the slot that was last used by
that data-block. Previously, it would always use the name of the
data-block, interfering with slot auto-selection when toggling between
Actions.

Pull Request: https://projects.blender.org/blender/blender/pulls/138326
2025-05-02 16:03:00 +02:00
Julien Duroure
a5834743f3 glTF exporter: Refactor image uri management
Now uri is precalculated, to be able to change it in a hook
2025-05-02 15:58:46 +02:00
Julien Duroure
eee3c96a8f Fix: glTF: Avoid crash when object is another scene is not in object mode 2025-05-02 15:56:15 +02:00
Julien Duroure
61e6c91c4e Fix: glTF: Fix regression - bone flat hierarchy export 2025-05-02 15:53:53 +02:00
Julien Duroure
743a6ae2a5 Fix: glTF: Fix active/inactive UI for ShapeKeys animation panel 2025-05-02 15:49:16 +02:00
Julien Duroure
bc8a39fba0 glTF: Better error handling when image is not found 2025-05-02 15:42:33 +02:00
Julien Duroure
f879c37a06 glTF: Cleanup function name 2025-05-02 15:40:58 +02:00
Julien Duroure
caaf148d50 Fix: glTF Exporter: Fix Track export when Apply Modifier 2025-05-02 15:38:29 +02:00
Julien Duroure
ee6e978d07 Fix: glTF exporter: Fix exporting Vertex Color for Unlit Materials 2025-05-02 15:35:32 +02:00
Julien Duroure
23e16f3371 Fix: glTF: Fix crash in animation pointer when no SpecularColorFactor can be found 2025-05-02 15:32:57 +02:00
Julien Duroure
3e8aabcd0b glTF importer: add option to import scenes as Collection(s) or Scene(s) 2025-05-02 15:30:18 +02:00
Julien Duroure
6e689ec59c glTF exporter: Clamp Normalized Vertex Color values 2025-05-02 15:27:43 +02: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
Julien Duroure
705ba465bb glTF importer: New option to import unused materials & images 2025-05-02 15:25:04 +02:00
Falk David
fb45d97ad4 Tests: Updated Grease Pencil render tests 2025-05-02 15:22:59 +02:00
Julien Duroure
dbb2b01ff9 glTF Exporter: AO color can now be used as BaseColor 2025-05-02 15:20:40 +02:00
Hans Goudey
99c87fbf18 Fix #137299: Exception with batch rename of nodes outside node editor
I'm not sure when this stopped working. The function in question is
quite confusing since it's called twice with two different purposes.
Fixing the exception is simple though. Just checking the data type
for "None" prevents changing the data type to one that's invalid given
the context. I didn't find a simple way to add an error message though.

Pull Request: https://projects.blender.org/blender/blender/pulls/138287
2025-05-02 15:17:23 +02:00
Julien Duroure
cc3a131947 glTF exporter: Cache Sampler Output
Results to lighter file size
2025-05-02 15:15:16 +02:00
Julien Duroure
c3ab321d2a glTF exporter: Export Viewport Material
New option to export Viexport Material instead of Node tree:
- Very Fast
- Custom Properties of the material can still be exported

Is exported:
- Base Color
- Roughness
- Metallic
2025-05-02 15:12:56 +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
Philipp Oeser
1a96c310d8 Fix #138272: Camera Ortho Scale adjustment wrong Background Image offset
Wrong since the Overlay Next implementation in ce28af7352

We cannot write to things like `.xy()`, these are for reading only.
Not aware of a version that is for writing, so for now, write to [0] and
[1] separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/138310
2025-05-02 12:05:40 +02:00
Pratik Borhade
68252ef77c Fix #138163: Autokey doesn't work when using trackpad to move locked camera
Navigating with mouse executes the respective modal function where it
handles autokeying the locked camera. But navigating with trackpad just
executes invoke function (for eg: see event_code in `viewrotate_invoke_impl`).
To fix this, Call `ED_view3d_camera_lock_autokey` inside invoke() to handle
autokeying.

Pull Request: https://projects.blender.org/blender/blender/pulls/138179
2025-05-02 11:56:24 +02:00
Pratik Borhade
3aea40b8cd Anim: Bone collection UI changes
Allow assign/select operators to execute when armature tab is pinned.
For assign operators, pinned armature should be active in 3D view
because we cannot assign bones of one armature to the bone collection of
different armature. Added extra condition in poll function to control
the above case.
For select operators, use `ED_armature_context` to obtain pinned Armature.
These operators are now hidden in object modes.

Pull Request: https://projects.blender.org/blender/blender/pulls/137587
2025-05-02 11:52:33 +02:00
Sietse Brouwer
67bec541fa Fix: Grease Pencil: Undo layer drag-and-drop
Reordering layers via drag-and-drop in the layer tree couldn't be
undone. With this patch an undo step is pushed when the layer order
changes via drag-and-drop, so the action can be undone.

Pull Request: https://projects.blender.org/blender/blender/pulls/138214
2025-05-02 11:32:07 +02:00
Sergey Sharybin
806a633609 GPU: Implement blending mode for piercing a hole in alpha
The use-case of this blend mode is to be able to make parts of an
viewport overlay transparent.

The future user of this blend mode is sequencer preview drawing
where frame will be drawn to an HDR render frame-buffer, and overlays
drawn on-top. In a way it is similar to the image engine, but without
need to have custom shader.

Ref #138094

Pull Request: https://projects.blender.org/blender/blender/pulls/138307
2025-05-02 10:40:23 +02:00
Sergey Sharybin
a345c3db64 GPU: Add API to access render frame buffer
Currently unused, but allows areas outside of DRW to render to the
color render and depth texture.

The primary user of this new API will be Sequencer preview to draw
HDR images.

Ref #138094

Pull Request: https://projects.blender.org/blender/blender/pulls/138306
2025-05-02 10:38:28 +02:00
Sergey Sharybin
180770fe3f Draw: Scale checkerboard with pixel size
Solves the problem of checkerboard in the sequencer have much smaller
grid than in the 3D viewport.

Ref #138094

Pull Request: https://projects.blender.org/blender/blender/pulls/138305
2025-05-02 10:36:59 +02:00
Campbell Barton
614f3957fe Cleanup: suppress null-dereference warning
Resolve a theoretical null pointer de-reference. In practice this is
unlikely as the result of `fd->file->read()` would need to fail to read
the requested data from memory.

Also use `UNLIKELY(...)` with checks that the expected amount of data
could be read.
2025-05-02 07:23:54 +00:00
Campbell Barton
f6e3635c1c Fix: potential null pointer de-reference in 2.8x UI versioning
Since it's not guaranteed specific region types exist,
null check before accessing.

Quiet null-dereference warning.
2025-05-02 07:03:12 +00:00