Commit Graph

150077 Commits

Author SHA1 Message Date
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
Campbell Barton
0ff9a162c1 Fix: memory leak on Wayland with IME
For practical purposes this only leaks on exit,
unless seats are change at run-time.
2025-04-07 11:24:02 +00: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
Aras Pranckevicius
5649b1c7f7 CMake: put test executables under folders in visual studio solution
Majority of projects within generated VS IDE solution are put under
their respective source folders, except the test executables. Majority
of which are various libmv tests. Use the same cmake macro to arrange
them in folders as what is used for regular libraries.

Pull Request: https://projects.blender.org/blender/blender/pulls/137028
2025-04-05 22:01:55 +02: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
Alaska
975d61daf3 Cycles: Disable MNEE on RDNA4 GPUs
At the moment MNEE locks up Cycles, or has rendering artifacts on
RDNA4 GPUs on WIndows.

This commit disables MNEE on that configuration until a fix
is avaliable.

Pull Request: https://projects.blender.org/blender/blender/pulls/136980
2025-04-05 14:06:40 +02:00
Campbell Barton
e544f543a0 CMake: pass a mode argument to message
While omitting the mode is supported it's generally better to clarify
the purpose of a message.
2025-04-05 21:42:16 +11: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
8e5c0aedec Cleanup: use type hints for trailing_space_clean.py utility 2025-04-05 20:06:34 +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
Jesse Yurkovich
17e6d1901b Fix #136994: Node Wrangler: Add ShaderNodeTexGabor to "textures" list
Add ShaderNodeTexGabor to the list of nodes that Node Wrangler considers
as a "texture".

Pull Request: https://projects.blender.org/blender/blender/pulls/137005
2025-04-04 22:12:03 +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
Miguel Pozo
2d75688259 GHOST: Add GHOST_GetActiveGPUContext()
Track the (per-thread) active `GHOST_Context`.
This is required to restore the active context after creating a new one
if the current context is unknown.
(Required for creating GPU contexts in the GPU module without depending
on the WM module)

Pull Request: https://projects.blender.org/blender/blender/pulls/136992
2025-04-04 18:14:13 +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
Weizhen Huang
0dc46773e0 Fix: Cycles Render Scheduler not respecting sample limit per update
Delay the clamping until later

Pull Request: https://projects.blender.org/blender/blender/pulls/136984
2025-04-04 14:17:08 +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