Commit Graph

123025 Commits

Author SHA1 Message Date
Jacques Lucke
c3f49cd24e Shader Nodes: add Python API for inlined shader nodes
This makes the shader node inlining from #141936 available to external renderers
which use the Python API. Existing external renderer add-ons need to be updated
to get the inlined node tree from a material like below instead of using the
original node tree of the material directly.

The main contribution are these three methods: `Material.inline_shader_nodes()`,
`Light.inline_shader_nodes()` and `World.inline_shader_nodes()`.

In theory, there could be an inlining API for node trees more generally, but
some aspects of the inlining are specific to shader nodes currently. For example
the detection of output nodes and implicit input handling. Furthermore, having
the method on e.g. `Material` instead of on the node tree might be more future
proof for the case when we want to store input properties of the material on the
`Material` which are then passed into the shader node tree.

Example from API docs:
```python
import bpy

# The materials should be retrieved from the evaluated object to make sure that
# e.g. edits of Geometry Nodes are applied.
depsgraph = bpy.context.view_layer.depsgraph
ob = bpy.context.active_object
ob_eval = depsgraph.id_eval_get(ob)
material_eval = ob_eval.material_slots[0].material

# Compute the inlined shader nodes.
# Important: Do not loose the reference to this object while accessing the inlined
#   node tree. Otherwise there will be a crash due to a dangling pointer.
inline_shader_nodes = material_eval.inline_shader_nodes()

# Get the actual inlined `bpy.types.NodeTree`.
tree = inline_shader_nodes.node_tree

for node in tree.nodes:
    print(node.name)
```

Pull Request: https://projects.blender.org/blender/blender/pulls/145811
2025-09-11 06:08:30 +02:00
Sean Kim
0b19cb35b6 Cleanup: Various organizational changes for brush.cc
* Reformats comment, moves it near related code
* Adds doxygen section
* Reorganizes function order

Pull Request: https://projects.blender.org/blender/blender/pulls/146050
2025-09-11 05:01:37 +02:00
Campbell Barton
1e7587f761 Cleanup: follow our API naming conventions
Minor changes to recently added undo API call.
2025-09-11 12:59:32 +10:00
Campbell Barton
77c76ccdb8 Cleanup: sort files 2025-09-11 12:41:33 +10:00
Campbell Barton
cf807a44bd Cleanup: use view2d prefix for consistency 2025-09-11 12:13:11 +10:00
Sean Kim
e9295fad65 Sculpt: Avoid setting vertex normal to the zero vector
It is possible for the simple vertex normal calculated during Paint
BVH normal updates to have a length of 0 if the connected faces cancel
each other out. This is a generally unlikely scenario, but will almost
always lead to further corruption of the mesh with the new normal.

If we detect this case, set the vertex normal to (0, 0, 1)

Pull Request: https://projects.blender.org/blender/blender/pulls/146004
2025-09-11 01:20:10 +02:00
Sean Kim
391377c804 Fix #145932: Relax Face Set brush can corrupt mesh
Caused by NaN propagation. If a face becomes 0 area, the resulting
normal becomes a zero vector. This normal cannot be used to calculate
the distance to a plane.

To fix this case more generally, we clamp the strength to 1.0 at most
to avoid introducing scenarios where a given vertex can have a zero
vector normal.

Pull Request: https://projects.blender.org/blender/blender/pulls/145952
2025-09-10 21:45:49 +02:00
John Kiril Swenson
8279e0e95c Fix: VSE: Memory leak with slip operator
An early exit when there were no strips to slip did not have a
corresponding `MEM_delete`.
2025-09-10 21:27:32 +02:00
Casey Bianco-Davis
163dfd7a9a Fix: Grease Pencil: Assert when converting to Catmull Rom or Poly
These `BLI_assert`s could be triggered by converting curves that were
already the desired type.

`curves.is_single_type` Checks if all of the curves are the desired
type, not if all of the selected curves are the type.
So the asserts can be triggered when only the destination type curves
are selected and other curve types exist.

Pull Request: https://projects.blender.org/blender/blender/pulls/145529
2025-09-10 21:01:03 +02:00
Clément Foucault
5561b97aa0 Cleanup: Metal: Avoid MSL warning in curves interpolation shader 2025-09-10 20:26:53 +02:00
Brecht Van Lommel
1439b11de9 Fix: Build error in lite build without USD and Alembic 2025-09-10 19:37:30 +02:00
Falk David
491a39b0c6 VSE: Strip Modifier Icons
Add missing icons to Video Sequencer modifiers:

- [x] Brightness/Contrast
- [x] Color Balance
- [x] Curves
- [x] Hue Correct
- [x] Mask (uses the existing `MOD_MASK`)
- [x] Tone Map
- [x] White Balance

Co-authored-by: Pablo Vazquez <pablo@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/145739
2025-09-10 19:27:43 +02:00
Falk David
02cd00dc75 VSE: Python: Add RNA type for mask modifier
The "Mask" modifier didn't have a corresponding
RNA type.

The mask settings are already stored as part of the
`StripModifierData` which is probably why the type
was never added.

Nevertheless, having an RNA type means we can define
a UI name, description, and icon.

Pull Request: https://projects.blender.org/blender/blender/pulls/146039
2025-09-10 18:40:43 +02:00
Bastien Montagne
d77cd0e8b5 Fix #145848: Crash when switching view layer after undoing ID deletion.
The root of the issue is that depsgraph relies on `ID::session_uid` to
identify and retrieve its own cached evaluation data for an ID,
including the memory for the evaluated ID data (e.g. used as keys to
retrieve IDInfo data stored in `DepsgraphNodeBuilder::id_info_hash_`).

This breaks in undo case, when a previously deleted ID is re-read from
the memfile, as it has not matching 'old' ID which address could be
reused. So while keeping its previous `session_uid`, it has a completely
new address, while the 'cow ID' retrieved from the depsgraph will still
have its `orig_id` point to the old address.

This commit fixes the issue by re-setting the `id_orig` pointer of the
`id_cow` evaluated data, when it already exists and is re-used.

This allows to keep the same `session_uid` for IDs on undo, even when
they are 're-created'. However, it is somewhat more risky than !146028.

Pull Request: https://projects.blender.org/blender/blender/pulls/146029
2025-09-10 17:33:42 +02:00
Sergey Sharybin
3ef2df3893 Cycles: Remove Use Tiling option
Always enforce tiling of some size, up to the 8k tile size.

Rendering very big images without tiles have a lot of challenges.
While solving those challenges is not impossible, it does not seem to
be a practical time investment.

The internals of the way how Cycles work, including Cycles Standalone
is not affected by this change.

A possible downside is that path guiding might not work exactly how one
would expect it to due to lack of information sharing across multiple
tiles. This is something that never worked nicely, and camera animation
and border render has the same issues, so it is not considered a stopper
for this change.

Fixes #145900

Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/146031
2025-09-10 17:15:07 +02:00
Hans Goudey
5afaa1c4bd Nodes: Move value to Combine XYZ from link-drag-search
Same as was implemented for some other cases in commits like
1a4c16a784

Pull Request: https://projects.blender.org/blender/blender/pulls/146033
2025-09-10 16:59:29 +02:00
Brecht Van Lommel
6d25aad41f Cycles: Remove Alembic procedural
This was added for a fairly specialezed use case and is no longer being used
as far as we know. A future replacement would be to add a USD/Hydra procedural,
for which most of the groundwork already exists.

Pull Request: https://projects.blender.org/blender/blender/pulls/146021
2025-09-10 16:39:01 +02:00
Clément Foucault
6148d50105 GPU: Shader: Remove section of code guarded by #if directives
These lines can be removed to avoid parsing them.
This allow to keep the same processing for shared host files.

Also removes a few lines of code to reduce the size of
shader sources.

This also contains a rewrite of the include parsing using
the shader parser.

Pull Request: https://projects.blender.org/blender/blender/pulls/146025
2025-09-10 16:35:41 +02:00
Jacques Lucke
f89b24ba8d Fix #146020: bad assert for supported socket types
The tree-type argument for the `supports_socket_type` type should be
allowed to be anything. There doesn't seem to be a great benefit in
restricting it. Always returning false when the tree type is not supported
makes sense.

In addition it would also be good to double-check that one can't add
the bundle and closure nodes in the compositor yet. From my basic tests,
that seems to work as expected.
2025-09-10 16:09:45 +02:00
Jacques Lucke
10353b3d69 BLI: reduce binary size for non-performance sensitive virtual arrays
This adds a `VArray::from_std_func` next to the existing `VArray::from_func`. It
does almost the same but inserts some type erasure by using `std::function`
which avoids the need to instantiate the full virtual array. This has is a bit
slower at run-time, but in practice there are some cases where it doesn't
matter. Currently, this patch reduces binary size by ~35kb. Not too much, but
still good or such a simple change.

Pull Request: https://projects.blender.org/blender/blender/pulls/146011
2025-09-10 15:45:56 +02:00
Habib Gahbiche
ac84e076db Nodes: Deactivate viewer if shortcut exists and viewer is active
Original right click select:
https://blender.community/c/rightclickselect/wRzz/

Pressing 1,2,3,... to activate a viewer with shortcut now toggles that
viewer instead of always activating it. See PR description for examples

The code is generic but the compositor requires one viewer to be active
so only geometry nodes viewers are supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/145509
2025-09-10 15:17:16 +02:00
Leon Schittek
c954d6cdfd Nodes: Add tools for "Mute Links" and "Add Reroute" operator
Expose the "Mute Links" add "Add Reroute" operator as active tools
in the node editor similar to the "Links Cut" tool.

This also works around #134153 by adding additional tools in the same
button group to the toolbar.

Pull Request: https://projects.blender.org/blender/blender/pulls/140429
2025-09-10 15:12:37 +02:00
Clément Foucault
19fb5652af Cleanup: GPU: Avoid warning in shader parser code 2025-09-10 12:48:31 +02:00
Clément Foucault
36b80971de Cleanup: EEVEE: Typo in interlieved_gradient_noise 2025-09-10 12:47:49 +02:00
Clément Foucault
455d749c52 Fix: GPU: Implicit cast from int to bool in assert()
These are not valid in GLSL.
2025-09-10 12:20:59 +02:00
Clément Foucault
f0806ac6b4 Fix #145743: EEVEE: Instance leak when Stereoscopy is enabled
The `eevee_render_to_image` can be called multiple time in the
case of multiview rendering.

To avoid the leak, free the previous instance before allocating
the new one. Reusing the instance doesn't seems to work here.

Another fix will follow this one to fix it more gracefuly.
This fix is kept simple for backporting purpose.

Pull Request: https://projects.blender.org/blender/blender/pulls/146015
2025-09-10 12:18:49 +02:00
Clément Foucault
b3dec6617a Fix: GPU: Avoid accessing GLContext after it is destroyed
This error showed up inside an ASAN build.

Candidate for backporting in 4.5 as this can happen when simply
rendering with EEVEE or Workbench.

Pull Request: https://projects.blender.org/blender/blender/pulls/146017
2025-09-10 12:17:43 +02:00
Clément Foucault
c302b7de7b Refactor: EEVEE: Simplify Gbuffer packing
Implementation of #145417

For more information see pull request.

Pull Request: https://projects.blender.org/blender/blender/pulls/145520
2025-09-10 12:17:21 +02:00
Pratik Borhade
42e70f10b5 Fix #146003: Autosave keeps re-saving even when file is already saved
If file is already saved, skip writing/overwritting auto-save file.

Pull Request: https://projects.blender.org/blender/blender/pulls/146005
2025-09-10 12:00:27 +02:00
Clément Foucault
805e037df3 GPU: Shader: Use parser for loop unrolling
This refactor the loop unrolling mechanism and
replaces the use of regex by the new parser.

Pull Request: https://projects.blender.org/blender/blender/pulls/145956
2025-09-10 11:59:52 +02:00
Jacques Lucke
0484738f8b Fix: Geometry Nodes: false warning when passing gizmo data through instance-only nodes
There was a `Realized data in input geometry is ignored` warning when passing
gizmo data through instance-only nodes. This was because the node thought that
this data is "realized data" (like a mesh, curves, etc). This patch removes the
warning by making the check for realized data more precise.

Pull Request: https://projects.blender.org/blender/blender/pulls/146014
2025-09-10 11:29:43 +02:00
luz paz
0c3005ca0c Cleanup: Fix typos in source/blender/draw
Fixes user-facing and non-user-facing typos.
Found via codespell

Pull Request: https://projects.blender.org/blender/blender/pulls/145972
2025-09-10 11:19:36 +02:00
luz paz
7ecf44a05c Cleanup: Fix typos in source/blender/depsgraph
A few typos in source/blender/depsgraph subdirectory.
Found via codespell

Pull Request: https://projects.blender.org/blender/blender/pulls/145973
2025-09-10 11:17:49 +02:00
Clément Foucault
91614ee5d6 Fix #145203: Switching armatures in pose mode fails when behind mesh
The code introduced in a08de337db
did not account for the special case of `SELECT_PICK_NEAREST`
where the depth data is actually bitshifted.

Pull Request: https://projects.blender.org/blender/blender/pulls/145924
2025-09-10 10:52:21 +02:00
Philipp Oeser
29d18c45e4 Fix #145890: Crash using playhead snapping in VSE in new scene
Code was not guarding against missing `Editing` (like we usually do for
these situations).

This also corrects usage of `CTX_data_scene` (use `CTX_data_sequencer_scene`
where needed instead) which should be needed since 1122a05cb6

Pull Request: https://projects.blender.org/blender/blender/pulls/145908
2025-09-10 09:22:04 +02:00
Jacques Lucke
ccdbcaa652 Fix: Nodes: inactive panel toggle is not grayed out
The panel label was grayed out, but not the panel toggle.

Pull Request: https://projects.blender.org/blender/blender/pulls/146006
2025-09-10 08:51:12 +02:00
Campbell Barton
c241ea1083 Cleanup: remove unused variable 2025-09-10 14:27:56 +10:00
John Kiril Swenson
3878748b2f Fix #145715: Right click select doesn't work with Blade Tool
Blade cursor patch #136749 cancelled select operations if the current
tool was the blade tool. This was to prevent LCS users from being able
to select handles when the blade tool would pass-through.  This however
resulted in an RCS regression.

Fix instead by cancelling split if the mode is `use_cursor_position`
and there is no valid split, preventing a pass-through.

In RCS this works nicely because users can just select using right-click
and bypass split logic. In LCS this makes it impossible to select with
the blade tool enabled, but this is expected behavior as the blade tool
does not need strips to be selected to work anyways, and tools should
ideally have different, non-overlapping purposes. For instance, the slip
tool also does not affect selection logic.
(Note: there is one small caveat to this principle, which is that the blade
tool can't currently split connected strips together unless theyre both
already selected. This issue should be fixed with a future blade tool
refactor).

This also fixes unrelated bugs:
- Blade cursor no longer shows on first/last frames, where split point
  fails
- You can no longer split in the gutters between channels

Pull Request: https://projects.blender.org/blender/blender/pulls/145938
2025-09-10 00:44:33 +02:00
Ramon Klauck
46ad17f351 Fix #145817: Crash while pasting audio strips
This happened because it was attempted to access or set the
non- existent pixelspace offset of these audio strips. It is fixed by
applying the "paste at mouse" behavior only for strips that would be
rendered, which excludes sound strips implicitly. This has also
benefit, that strips with effects would only change position of the
effect thus avoiding double transformation.

Pull Request: https://projects.blender.org/blender/blender/pulls/145819
2025-09-10 00:11:34 +02:00
Sybren A. Stüvel
0aa3a0dc0a Cleanup: fix unused parameter in release builds
Add `UNUSED_VARS_NDEBUG(ac);` to silence the 'unused parameter' warning
in non-debug builds.

No functional changes.
2025-09-09 17:57:27 +02:00
Richard Antalik
9882f35353 Fix #145629: Crash when pasting strip with driver
Original code assumed, that if there is action or drivers, action
datablock will be copied into `Main`, which is later freed. But drivers
are not part of action datablock.

Pull Request: https://projects.blender.org/blender/blender/pulls/145677
2025-09-09 17:24:20 +02:00
Habib Gahbiche
a7a07b4102 Fix #145675: Crash when opening file with undefined node
The crash happens in 5.0. The fix is for 4.2 mainly because 4.2 is a
currently maintained LTS so it's the oldest version that will
practically get the fix.

Pull Request: https://projects.blender.org/blender/blender/pulls/145726
2025-09-09 16:28:34 +02:00
Jacques Lucke
32c301e3cf Shader Nodes: support repeat zones, closures and bundles
This adds a function that can turn an existing `bNodeTree` into an inlined one.
The new node tree has all node groups, repeat zones, closures and bundles
inlined. So it's just a flat tree that ideally can be consumed easily by render
engines. As part of the process, it also does constant folding.

The goal is to support more advanced features from geometry nodes (repeat zones,
etc.) in shader nodes which the evaluator is more limited because it has to be
able to run on the GPU. Creating an inlined `bNodeTree` is likely the most
direct way to get but may also be limiting in the future. Since this is a fairly
local change, it's likely still worth it to support these features in all render
engines without having to make their evaluators significantly more complex.

Some limitations apply here that do not apply in Geometry Nodes. For example,
the iterations count in a repeat zone has to be a constant after constant
folding.

There is also a `Test Inlining Shader Nodes` operator that creates the inlined
tree and creates a group node for it. This is just for testing purposes.

#145811 will make this functionality available to the Python API as well so that
external renderers can use it too.
2025-09-09 16:15:43 +02:00
Sergey Sharybin
d5633cc7a8 Fix #145891: Crash scrubbing VSE using Shift-RMB in scene with no channels
Pull Request: https://projects.blender.org/blender/blender/pulls/145968
2025-09-09 15:48:01 +02:00
Ray Molenkamp
c5c9b97bec Fix: Build error with MSVC
node_geo_mesh_primitive_cube.cc uses M_PI_2 without including
BLI_math_constants.h. Unsure why this is a problem for me locally
but not for the bots but i'm guessing its a unity build difference.

Pull Request: https://projects.blender.org/blender/blender/pulls/145950
2025-09-09 15:45:55 +02:00
Sybren A. Stüvel
4132c7338a Cleanup: remove unnecessary code from dopesheet editor RNA
d1962be44c removed the call to
`BKE_view_layer_active_object_get()`. It did leave some "supporting
code" around, which was necessary to make that call possible but now is
no longer needed.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/145977
2025-09-09 14:52:30 +02:00
Sybren A. Stüvel
06b36bb441 Fix #145959: Hiding from the outliner triggers an assert
Call `BKE_view_layer_synced_ensure()` before
`BKE_view_layer_active_object_get()`.

Pull Request: https://projects.blender.org/blender/blender/pulls/145975
2025-09-09 14:51:54 +02:00
Clément Foucault
51b5ae24f5 Fix #145028: Regression: 3D cursor misaligned with axes
The port in 38ce310c17
missed that axes in 3D view are drawn using the perspective
projection matrix and not the 2D one.

Pull Request: https://projects.blender.org/blender/blender/pulls/145927
2025-09-09 14:45:37 +02:00
Clément Foucault
7761b8cfb2 Fix: Overlay: Outline of subpixel Curves produce high aliasing
Issue introduced by #143180. The code was there beforehand but
was not clear. It was left commented out.
Modify it so that it matches the new code.
2025-09-09 14:15:55 +02:00
Clément Foucault
79f3c5266a Fix: GL: Missing version parsing for Linux AMD Pro GL implementation
This avoid using the workaround on known working drivers.

Detected when investigating shader compilation performance.
These new drivers where forced to not use threaded compilation.

Candidate for backport to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/145969
2025-09-09 14:10:26 +02:00