Commit Graph

118774 Commits

Author SHA1 Message Date
Brecht Van Lommel
ea13b19738 Cleanup: Compiler warning about initialization order 2025-04-07 16:29:13 +02:00
Brecht Van Lommel
10b49cd6c6 Cleanup: Compiler warnings with GCC
This showed: argument 1 range [18446744071562067968, 18446744073709551615]
exceeds maximum object size 9223372036854775807.

It seems to think signed integers might lead to this kind of overflow,
but it's unclear why these two cases are causing warnings specifically.
Refactor the code to sidestep it.
2025-04-07 16:29:13 +02:00
Clément Foucault
13bf095c18 Fix #137022: EEVEE: Shadows on reflection planes render incorrectly
This was caused by the cross product changing
sign in view space during planar lightprobe capture.

This can be avoided by making sure the view matrix
doesn't change handedness.

Pull Request: https://projects.blender.org/blender/blender/pulls/137092
2025-04-07 16:27:31 +02:00
Sybren A. Stüvel
9b1a34e83e Fix #136947: Duplicate Action Slot doesn't duplicate animation data
The "new/duplicate" button in the Action Slot selector did not actually
duplicate, and always acted as a "new" button.

This introduces the RNA function `ActionSlot.duplicate()`, which takes
care of duplicating all the animation data associated with the slot as
well. The semantics of this function should remain valid in the
future, when Actions support multiple layers & strips. Note that this
new function does not assign the slot, it just duplicates it and its
data. The assignment of this duplicated slot is done in Python,
through the already-existing API for this.

Pull Request: https://projects.blender.org/blender/blender/pulls/137087
2025-04-07 16:14:49 +02:00
Miguel Pozo
a5ed5dc4bf GPU: Support deferred compilation in ShaderCompilerGeneric
Update the `ShaderCompilerGeneric` to support deferred compilation
using the batch compilation API, so we can get rid of
`drw_manager_shader`.
This approach also allows supporting non-blocking compilation
for static shaders.

This shouldn't cause any behavior changes at the moment, since batch
compilation is not yet used when parallel compilation is disabled.

This adds a `GPUWorker` and a `GPUSecondaryContext` as an easy to use
wrapper for managing secondary GPU contexts.

(Part of #133674)
Pull Request: https://projects.blender.org/blender/blender/pulls/136518
2025-04-07 15:26:25 +02:00
Omar Emara
47471ca2b0 Fix: Crash when sampling Float2 images
Blender crashes when using math interpolation functions to sample Float2
images. That's because 3 components is intentionally left out of various
switch case. To fix this, we handle 3 components and assert for expected
components count.

Pull Request: https://projects.blender.org/blender/blender/pulls/137094
2025-04-07 15:25:15 +02:00
Habib Gahbiche
84fb437355 Fix: Cage2d gizmo rotation handle stretches with rotation
The gizmo is drawn in the transformed space of the gizmo (see `GPU_matrix_mul(matrix_final)` in `gizmo_cage2d_draw_intern()`). This causes initial stretching of the drawn circle. However, this initial stretching is already being compensated by drawing an ellipse, which axes are computed based on the gizmo size (see variable `margin`).

Therefore, computing the size of the gizmo (`scale_xy`) based on render dimensions (`dims`) seems to be overcompensating and introduces another stretching. This patch removes the redundant compensation.

Pull Request: https://projects.blender.org/blender/blender/pulls/137079
2025-04-07 15:02:02 +02:00
Lukas Tönne
10e95bebca Fix #136615: Disallow writeback callbacks that are not cleared
Adding "writeback" callbacks to the depsgraph should be temporary, since these
callbacks can bind pointers that become invalid. In this case: the evaluated
nodes modifier bound by a bake node callback. These callbacks are cleared after
being added in the `deg_flush_updates_and_refresh` function, but there are other
cases where depsgraph updates are executed which don't support writeback
callbacks (`object_force_modifier_update_for_bind` run by the smooth modifier
"bind" function).

To prevent dangling invalid pointers in outdated callbacks, disallow adding
callbacks in any case other than the `deg_flush_updates_and_refresh` function.
Since callbacks can be added from any depsgraph update, the safest way to
prevent adding them is in the depsgraph itself. If the `use_writeback_callbacks`
flag is not set, any callback is simply discarded.

Pull Request: https://projects.blender.org/blender/blender/pulls/137083
2025-04-07 13:30:35 +02:00
Omar Emara
f49fd3fc92 Fix: Compositor does compute preview once enabled
The compositor does not compute node previews even after the user
enables previews using the eye operator in the node header. That's
because the operator does not tag the node for update. To fix this, tag
the node for a property update and submit relevant WM notifiers.

Pull Request: https://projects.blender.org/blender/blender/pulls/136985
2025-04-07 13:08:07 +02:00
Clément Foucault
9d06508837 Fix #137052: GPU: Crash on startup caused by legacy pyGPU API
The removed legacy API was still in used by the pyGPU API.
Add a deprecation warning instead.

This partially reverts commit 3179cb0069.
2025-04-07 12:27:48 +02:00
Habib Gahbiche
24faa4d856 Compositor: gizmo for box mask
A box mask can now be manipulated using a (rotated) rectangle gizmo.

Changes:
- Implementation is based on crop gizmo. Some functionalities were generalized for both crop and box mask (later should be used for ellipse mask as well)
- Support offset caused by transform nodes in compositor
- Support rotation for 2d gizmos

Note: a known issue about stretched rotation handle will be handled in a separate patch, see https://projects.blender.org/blender/blender/pulls/137079

Pull Request: https://projects.blender.org/blender/blender/pulls/122693
2025-04-07 12:18:40 +02:00
Pratik Borhade
ed59418d2d Cleanup: Grease Pencil: Remove v3 references
Remove v3 from tooltip, code comments

Pull Request: https://projects.blender.org/blender/blender/pulls/137078
2025-04-07 11:39:16 +02:00
Campbell Barton
c9c59cfa8e Cleanup: rename IMB_FTYPE_{IMAGIC=>IRIS} to confirm with other defines
Use the term IRIS to match the file naming for this format as well as
R_IMF_IMTYPE_IRIS.

Ref !137073
2025-04-07 09:23:49 +00:00
YimingWu
6977c15b51 Fix #134098: Grease Pencil: Use thinner lines for converting from Curves
Previously when converting from Curves to Grease Pencil, strokes will
take a default radius of 1.0f which is way too wide. Now assigned to
0.01f to be consistent with the radius when converting from legacy
curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/134109
2025-04-07 08:31:14 +02:00
Campbell Barton
6f09def038 Docs: correction to ".tx" description 2025-04-07 15:42:03 +10:00
Campbell Barton
15066403de Docs: cross reference imb_ext_image with known eImbFileType values
Justify inclusion of the extensions.
2025-04-07 08:09:44 +10:00
Campbell Barton
96181c5550 Revert "ImBuf: remove ".tx" extension from the list of supported images"
This reverts commit cf55a0acdc.

While this was added with the commit that added support for tile cache,
keep the extension check as Blender can load them.
2025-04-06 22:07:07 +00:00
Campbell Barton
1c702f9c94 Cleanup: assign the property flag to a variable 2025-04-06 10:48:36 +00:00
Campbell Barton
e85c18eb92 Cleanup: remove redundant casts 2025-04-06 20:39:39 +10:00
Philipp Oeser
1529710f44 Fix #136796: wm.radial_control with confirm on release missing update
`radial_control_modal` would only actually update the target property
(via `RNA_property_update`) for the "standard" ways of confirming
(`LEFTMOUSE`, `EVT_PADENTER`, `EVT_RETKEY`).

When using "release_confirm" however, that was skipped, so added the
`RNA_property_update` now.

Pull Request: https://projects.blender.org/blender/blender/pulls/136884
2025-04-06 11:48:16 +02:00
Campbell Barton
b43159088c Fix: use of non UTF8 string copy for thick wrapped strings in Python
Avoid potential incomplete UTF8 sequences in the Python RNA API.
2025-04-06 19:40:29 +10:00
Campbell Barton
cf55a0acdc ImBuf: remove ".tx" extension from the list of supported images
Likely an oversight in [0] which removed support for tile-cache.

[0]: 38573d515e
2025-04-06 12:57:11 +10:00
Hans Goudey
36130d5584 Fix #136837: Mesh incorrectly renders smooth with GPU subdivision in some cases
Caused by 9b70851d91.
That commit inadvertently switched the order of these definitions. Because the
vertex buffers created by GPU subdivision still have a different format than regular
mesh drawing (the position buffer also includes vertex normals), the order of these
VBOs in the batch matters, since "lnor" attribute can override another.

Pull Request: https://projects.blender.org/blender/blender/pulls/137000
2025-04-05 15:21:48 +02:00
Falk David
8a01c9b8ec Geometry Nodes: Add Set Grease Pencil Color node
Adds a new `Set Grease Pencil Color` node.
It was already possible to write to the color and opacity attributes using the
`Store Named Attribute` node, but this required the user to know the names
of the "built in" attributes.

Similar to how we can set other built-in attributes (e.g. the curve radius) this
adds a node to write to the following Grease Pencil attributes:
* `vertex_color` (point domain): The color of a point (the alpha value is used
    as a mix factor with the base material color).
* `opacity` (point domain): The opacity of a point.
* `fill_color` (curve domain): The fill color of a stroke (the alpha value is used
    as a mix factor with the base material color).
* `fill_opacity` (curve domain): The fill opacity of a stroke.

For consistency with other nodes, there is a mode to switch between writing
to the points (`Stroke` mode) and the fills (`Fill` mode).

Pull Request: https://projects.blender.org/blender/blender/pulls/136260
2025-04-05 12:11:26 +02:00
Campbell Barton
f48b4e3abf Cleanup: wrap long lines for CMake 2025-04-05 20:30:37 +11:00
Campbell Barton
69e0de3baa Cleanup: format 2025-04-05 20:04:59 +11:00
Campbell Barton
af1110fb3c Render: support pixel density in the render pipeline
Add a "Pixel Density" sub-panel to render output settings which
can be used to set the density (as pixels per inch for example).

This is then written to images that support pixel density.

Details:

- The scene has two values a PPM factor and a and base unit.
- The base unit defaults to pixels per inch as this is the most
  common unit used.
- Unit presets for pixels per inch/centimeter/meter are included.
- The pixel density is stored in the render result & EXR cache.
- For non 1:1 aspect renders, the density increases on the axis
  which looks "stretched", so the PPM will print the correct
  aspect with non-square pixels.

Ref !127831
2025-04-05 08:49:22 +00:00
Campbell Barton
e7c9ea3b27 Cleanup: correct typo in variable name & comments 2025-04-05 08:49:20 +00:00
Campbell Barton
a6da9e3ae7 Cleanup: quiet unused variable warning 2025-04-05 08:37:07 +00:00
Sean Kim
d99435403e Cleanup: Reorganize sculpt_intern.hh
* Remove unnecessary doxygen sections
* Group related functions together

Pull Request: https://projects.blender.org/blender/blender/pulls/137017
2025-04-05 04:00:39 +02:00
Jesse Yurkovich
40cbc09d56 Cleanup: correct typos
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/137009
2025-04-04 22:58:10 +02:00
Harley Acheson
68198e09f2 UI: Use Icon for Panel Header Grip
On panel headers, use SVG Icon for the drag gripper.

Pull Request: https://projects.blender.org/blender/blender/pulls/134471
2025-04-04 22:34:42 +02:00
Sean Kim
ba29593a17 Fix: Clay Strips brush plane inconsistently calculated & used
This commit changes the behavior of the Clay Strips brush so that
it aligns more with expectations.

* Tilt is applied consistently to the sculpt plane instead of only being
  applied if the brush is both using the calculated Sculpt plane and not
  using the original normal.

* The sampled normal is used for the subsequent brush plane check
  instead of being incorrect when alternate sculpt planes are used.

Pull Request: https://projects.blender.org/blender/blender/pulls/136965
2025-04-04 21:42:53 +02:00
T0MIS0N
24d08e0bae Overlay: Allow drawing UVs in Image Editor in any mode
**Problem**
When using Texture Paint mode, the Image Editor will show a UV Wireframe
to display the active object's UVs. In every other mode, this wireframe
is absent. This is currently a big problem for Sculpt Mode since the
Experimental Texture Paint system is a part of that mode, meaning that
the user can't see their UVs while they paint in Sculpt Mode. This is
also troublesome for users that would like to quickly view an object's
UVs without using Texture Paint Mode.

**Solution**
Since it's useful to be able to view an object's UVs at all times, the
Image Editor should display UV Wireframes in all Object Modes regardless
of the Image Editor's mode. This is the best solution since it means
that future Blender features, that would benefit from having a preview
of an object's UV Wireframes, will automatically have that option since
UV Wireframes are supported in all modes. Also, if a user doesn't want
to see UV Wireframes for any reason, it can be disabled with an Overlay
option.

Additionally, when multiple objects are selected, each object should
have its UV Wireframe drawn in the Image Editor. The selected objects
that aren't active should have less opaque wireframes to indicate which
wireframe belongs to the active object. This is the best approach for
having multiple objects selected since it allows the user to quickly
view the UV layout for all selected objects to troubleshoot UV problems,
like texture mapping. This is especially helpful when using a material
for multiple different objects.

An alternative solution would be to only show the UV Wireframe for the
active object, but this would be undesirable because it would make
troubleshooting UV positions tedious when working with multiple objects
since the user would need to select objects individually.

Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/135102
2025-04-04 21:30:05 +02:00
Jesse Yurkovich
f60c528c48 Cleanup: Fix one-definition-rule violations for various structs
This fixes most "One Definition Rule" violations inside blender proper
resulting from duplicate structures of the same name. The fixes were
made similar to that of !135491. See also #120444 for how this has come
up in the past.

These were found by using the following compile options:
-flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Note: There are still various ODR issues remaining that require
more / different fixes than what was done here.

Pull Request: https://projects.blender.org/blender/blender/pulls/136371
2025-04-04 21:05:16 +02:00
наб
6935ec2fa7 OpenGL: Some legacy AMD drivers not detected
My version "4.6.14760 Core Profile Context 21.2.3 27.20.14535.3005"
was not caught by the spot-check. This change replaces the check with
a parser and range check.

Pull Request: https://projects.blender.org/blender/blender/pulls/136803
2025-04-04 20:13:52 +02:00
Pratik Borhade
7215da9390 Fix #136314: Outline flicker when resizing editor
When resizing area, outline flickering is caught occassionally. Border edge
is not identified sometimes which doesn't set `active_area` to null.
This eventually draws outline with `TH_EDITOR_OUTLINE_ACTIVE` color.
When moving editors, always set `active_area` ptr as null to eliminate
jumping between two theme colors.

Pull Request: https://projects.blender.org/blender/blender/pulls/136487
2025-04-04 19:18:01 +02:00
Hans Goudey
d3f84449ad Mesh: Add "free" custom normals
Add a "dumb vector" storage option for custom normals, with the
"custom_normal" attribute. Adjust the mesh normals caching to
provide this attribute if it's available, and add a geometry node to
store custom normals.

## Free Normals
They're called "free" in the sense that they're just direction vectors
in the object's local space, rather than the existing "smooth corner
fan space" storage. They're also "free" in that they make further
normals calculation very inexpensive, since we just use the custom
normals instead. That's a big improvement from the existing custom
normals storage, which usually significantly decreases
viewport performance. For example, in a simple test file just storing
the vertex normals on a UV sphere, using free normals gives 25 times
better playback performance and 10% lower memory usage.

Free normals are adjusted when applying a transformation to the entire
mesh or when realizing instances, but in general they're not updated for
vertex deformations.

## Set Mesh Normal Node
The new geometry node allows storing free custom normals as well as
the existing corner fan space normals. When free normals are chosen,
free normals can be stored on vertices, faces, or face corners. Using
the face corner domain is necessary to bake existing mixed sharp and
smooth edges into the custom normal vectors.

The node also has a mode for storing edge and mesh sharpness, meant
as a "soft" replacement to the "Set Shade Smooth" node that's a bit
more convenient.

## Normal Input Node
The normal node outputs free custom normals mixed to whatever domain is
requested. A "true normal" output that ignores custom normals and
sharpness is added as well.

Across Blender, custom normals are generally accessed via face and
vertex normals, when "true normals" are not requested explicitly.
In many cases that means they are mixed from the face corner domain.

## Future Work
1. There are many places where propagation of free normals could be
   improved. They should probably be normalized after mixing, and it
   may be useful to not just use 0 vectors for new elements. To keep
   the scope of this change smaller, that sort of thing generally isn't
   handled here. Searching `CD_NORMAL` gives a hint of where better
   propagation could be useful.
2. Free normals are displayed properly in edit mode, but the existing
   custom normal editing operators don't work with free normals yet.
   This will hopefully be fairly straightforward since custom normals
   are usually converted to `float3` for editing anyway. Edit mode
   changes aren't included here because they're unnecessary for the
   procedural custom normals use cases.
3. Most importers can probably switch to using free normals instead,
   or at least provide an option for it. That will give a significant
   import performance improvement, and an improvement of Blender's
   FPS for imported scenes too.

Pull Request: https://projects.blender.org/blender/blender/pulls/132583
2025-04-04 19:16:51 +02:00
Clément Foucault
6727675757 Fix: DRW: Shader printf not working inside draw context
The draw context was missing `GPU_render_begin/end`
calls which is where the printf buffer are created and
flushed.
2025-04-04 18:42:05 +02:00
Germano Cavalcante
3ab65cff04 Windows: show popup after crash
Implements a crash dialog for Windows.

The crash popup provides the following actions:
- Restart: reopen Blender from the last saved or auto-saved time
- Report a Bug: forward to Blender bug tracker
- View Crash Log: open the .txt file with the crash log
- Close: Closes without any further action

Pull Request: https://projects.blender.org/blender/blender/pulls/129974
2025-04-04 18:38:53 +02:00
Clément Foucault
3179cb0069 Cleanup: GPU: Remove unused legacy_resource_location 2025-04-04 18:21:52 +02:00
Jeroen Bakker
a46643af0f Vulkan/OpenXR: Add support for VK_KHR_external_memory_fd
Current implementation uses a CPU roundtrip to transfer render result
to the Xr Swapchain. This PR adds support for sharing the render result
on Linux systems by using file descriptors.

To extend this solution to win32 or dx handles can be done by extending
the data transfer modes, register the correct extensions. When not
using the same GPU between Blender and OpenXR the CPU roundtrip
will still be used.

Solution has been validated with monado simulator and seems to be as
fast as OpenGL.

Performance can be improved by using GPU based synchronization.
Current API is limited as we cannot chain the different renders and
swapchains.

Pull Request: https://projects.blender.org/blender/blender/pulls/136933
2025-04-04 16:01:06 +02:00
илья _
2a092a623b Fix: #136269: Geometry Nodes: crash due to missing collection in depsgraph
When the collection is disabled and was only referenced by a node tree, it was
missing from the depsgraph. The Geometry Nodes modifier tried to add a relation
to it, but it couldn't because the collection was not in the depsgraph in the first place.

Now, the collection is always added to the depsgraph when it's referenced by a
node tree that's in the depsgraph too. This makes the existing code that adds the
relation from the collection to the Geometry Nodes modifier work.

Pull Request: https://projects.blender.org/blender/blender/pulls/136328
2025-04-04 15:55:07 +02:00
Clément Foucault
3562433ae7 pyGPU: Deprecate Shader.program getter
This is getting in the way of making the
GPUShader API more threadsafe.

This getter already doesn't work for vulkan
and Metal, and has very limited usage.

Keeping the python function to avoid errors
and display a deprecation warning.

Pull Request: https://projects.blender.org/blender/blender/pulls/136983
2025-04-04 14:23:09 +02:00
Omar Emara
cc21dcb436 Fix #136866: Voronoi 1D crashes GPU compositor
The GPU compositor crashes if 1D Voronoi is used. That's because the
vector input is unavailable in that mode, but the GPU material compiler
considers all inputs, even unavailable ones. So we need to link those
sockets to some arbitrary constant value.
2025-04-04 14:04:05 +02:00
Omar Emara
cc84830abc Cleanup: No previous declaration warning 2025-04-04 12:47:29 +02:00
Sybren A. Stüvel
a9f4f211d4 Fix #136967: Crash on Merge Animation when Slot has no Channelbag
The Merge Animation operator assumed that when a keyframe strip exists,
it always has a channelbag for the to-be-moved slot. This isn't
necessarily the case, so now it only moves the channelbag if it exists.

Pull Request: https://projects.blender.org/blender/blender/pulls/136978
2025-04-04 12:22:47 +02:00
YimingWu
b54d629401 Fix: Line Art: Prevent loading empty meshes
In `lineart_geometry_check_visible` it could recieve a valid mesh
without any vertices, this causes `bounds` below to be invalid.
Now return early if encountered such situation.

Pull Request: https://projects.blender.org/blender/blender/pulls/136819
2025-04-04 12:04:20 +02:00
Omar Emara
9725fa0c84 Fix: Node are duplicated in link add search menu
Some nodes like the Math and Mix Color node are duplicated when looking
at the link add search menu. That's because all nodes are considered in
that operation, even ones that are not listed in the menu. To fix this,
just disable the functionality for those legacy nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/136979
2025-04-04 12:00:39 +02:00
Omar Emara
12ba9770db Fix #136699: Denoise node crash in viewport compositor
The Denoise node crashes if used in the viewport compositor. That's
because OIDN uses the compositor context in a different thread, which
does not have access to the DRW context. To fix this, we assign relevant
context data to the compositor context from the DRW context before
running the evaluator, then make the compositor context return those
data instead of accessing the DRW context.
2025-04-04 11:59:23 +02:00