Commit Graph

109995 Commits

Author SHA1 Message Date
Iliya Katushenock
cdcefa43e3 Fix #119703: Incorrect conversion of identity quaternion to axis angle
Fix of conversion identity quaternion to axis angle. Basically,
if the length of the imaginary part-vector is zero, it is
incorrect to normalize it. Simple identity should be returned.

Pull Request: https://projects.blender.org/blender/blender/pulls/119762
2024-06-06 19:26:40 +02:00
Raul Fernandez
a6cfc86469 Fix #86114: Multires Displacement Smear brush + Dyntopo Error
Fixed a crash when dynamic topology is active on multires displacement smear brush

Added a check for this case at the start of the brush stroke, with a user visible error message
and cancels the operator early so no topology is modified either.

Pull Request: https://projects.blender.org/blender/blender/pulls/122453
2024-06-06 16:56:02 +02:00
Miguel Pozo
a249e93ad1 GPU: Add missing virtual destructor to ShaderCompiler 2024-06-06 15:50:09 +02:00
Brecht Van Lommel
f7797a90f6 Core: Make BLENDER_SYSTEM_SCRIPTS always add paths
Originally this would replace scripts that come bundled with Blender,
but it's unclear how this is useful.

Searching for this online mainly leads to people asking how they can
use it to add scripts. For example in a studio environment you might
want to deploy add-ons and startup scripts for all users.

Even if you wanted to use it for replacement though, it wasn't really
doing that and inconsistent for different types of scripts:

* startup: ignored
* modules: replaces bundled scripts
* presets: adds to bundled scripts
* addons (in 4.1): ignored
* addons_core (in 4.2): ignored
* startup/bl_app_templates_system: replaces bundled scripts

This change makes it add scripts from this path for all. This is a
breaking change, though arguably this feature was just broken to
begin with and not used much in practice because of that.

The alternative would be add a new set of environment variables to
avoid breaking existing behavior. But that also means keeping around the
broken behavior or fixing it in another way.

Supporting multiple paths may be used too, but for now just support
a single one as doing this for all BLENDER_SYSTEM variables is
non-trivial. The main use case for that would be add-ons anyway, and
those will mainly be handled through upcoming
BLENDER_SYSTEM_EXTENSIONS instead.

Ref #122512

Pull Request: https://projects.blender.org/blender/blender/pulls/122689
2024-06-06 15:28:44 +02:00
Philipp Oeser
9b1d81eec2 Fix #122526: Pie menu executes the active as well as the shortcut button
A bit on shaky ground here, but it looks like we actually dont want to
execute the hovered buttons value/op if we chose another item in the pie
menu. This can be achieved by using the **onfree** arg to
`button_activate_exit` called on the active(hovered) button.

Not sure if this is the correct solution tbh (but maybe it demonstrates
where the bug of #122526 can be located).
I have tested pie menus with this patch and they seems to behave
normally (even nested ones).

Pull Request: https://projects.blender.org/blender/blender/pulls/122567
2024-06-06 11:09:35 +02:00
Campbell Barton
949dfbfaa8 Cleanup: Python script formatting
- Double quotes for strings.
- Trailing commas when wrapped lines.
2024-06-06 11:26:28 +10:00
Campbell Barton
7f7648c6ed Cleanup: spelling in code comments & minor edits
- Use uppercase NOTE: tags.
- Correct bNote -> bNode.
- Use colon after parameters.
- Use doxy-style doc-strings.
2024-06-06 09:55:13 +10:00
Richard Antalik
702948c592 Fix effect strips can not be selected
Caused by excluding effects from selection candidates.
Exclude effects in `get_strip_handle_under_cursor()` instead.
2024-06-06 01:33:45 +02:00
Sergey Sharybin
15b5651712 Fix/workaround linker issues of blender_test on Linux
Seems to be dependent on specific compiler/cmake version.

Is a typical mixture of missing dependencies between libraries,
object files which do not get referenced from other files in the
target, and whole-archive linking of the blender_test target.

Pull Request: https://projects.blender.org/blender/blender/pulls/122801
2024-06-05 21:46:13 +02:00
Guillermo Venegas
5e9d19d58b IO: Import multiple Alembic files at once
Allows to import multiple alembic files in single operator call.

When importing multiple alembic files as background job, import progress
will be divided by all files, so if `5` files are imported, each file
will make progress of `20%`. This can be improved if the job text can be
customized to display for example `Import Alembic 1/5` and using 100%
progress status display for each file, but that is out of the scope of
this pr.

The Scene min and max frame are set based on the minimum/maximum frame
ranges detected from all files.

Pull Request: https://projects.blender.org/blender/blender/pulls/121492
2024-06-05 21:20:25 +02:00
Michael B Johnson
f913fb6159 USD: Add MaterialX shader export
This change adds the ability to export MaterialX networks into the resulting
USD layer.

Details:

A new export option has been added to the USD export to enable MaterialX
export. It is off by default currently due to reasons in the caveats
section.

When enabled, it exports the MaterialX shading network alongside the
UsdPreviewSurface network, on the same USD Material. This allows the same
material to be used by renderers that don't support MaterialX, using the
USDPreviewSurface as a fallback. This is similar to setups in other DCC
packages, and matches the format we've used in our Reality Composer Pro
asset library.

It uses the existing MaterialX framework used to generate MaterialX
documents for rendering, to act as the basis for the USD graph. In this
process it also re-uses the existing texture export code as well if provided
and necessary.

Once the MaterialX document is created, use usdMtlx to generate a USD
shading network. Unfortunately, usdMtlx generates a graph that is unlike
what other DCCs that support MaterialX-embedded-in-USD generates. It
generates several extra prim hierarchies, and externalizes all shader
inputs, making them difficult to edit in other MaterialX graph editors.

To workaround this, generate the MaterialX shading network onto a
temporary stage, where we then run various pre-processing steps to prevent
prim collisions and to reflow the paths once they're converted.

The PrimSpecs are then copied over to their new path. The resulting prim
hierarchy matches what many artists we've worked with prefer to work with.

Caveats:

The Export MaterialX check is off by default. When using the Principled
BSDF, the resulting graph is very usable. However, when using some of the
other BSDFs, the shading networks generated by the existing MaterialX
framework in Blender generate some shading graphs that are difficult for
usdview and other DCC's to understand. The graph is still correct, but
because we're trying to prioritize compatibility, the default is off.

In future PRs we can aim to make the graphs for those other BSDFs play
better with other DCCs.

Other Implementation Details:

As part of this commit we've also done the following:

* Place some of the materialx graphs inside a passthrough nodegraph to
  avoid node conflicts.
* Better handle some shader output types , and better handle some
  conflict cases.
* Moved the ExportTextureFunction to materials.h due to some difficult
  to resolve header ordering issues. This has no effect on any runtime code.
* There is a test for the MaterialX export that does some basic checking to
  make sure we get an export out the other end that matches our expectations

Authored by Apple: Dhruv Govil

This PR is based on an earlier implementation by Brecht van Lommel , as well
as Brian Savery and his teams' work at AMD to implement the general
MaterialX framework within Blender.

Pull Request: https://projects.blender.org/blender/blender/pulls/122575
2024-06-05 20:43:44 +02:00
Miguel Pozo
74224b25a5 GPU: Add GPU_shader_batch_create_from_infos
This is the first commit of the several required to support
subprocess-based parallel compilation on OpenGL.
This provides the base API and implementation, and exposes the max
subprocesses setting on the UI, but it's not used by any code yet.

More information and the rest of the code can be found in #121925.

This one includes:
- A new `GPU_shader_batch` API that allows requesting the compilation
  of multiple shaders at once, allowing GPU backed to compile them in
  parallel and asynchronously without blocking the Blender UI.
- A virtual `ShaderCompiler` class that backends can use to add their
  own implementation.
- A `ShaderCompilerGeneric` class that implements synchronous/blocking
  compilation of batches for backends that don't have their own
  implementation yet.
- A `GLShaderCompiler` that supports parallel compilation using
  subprocesses.
- A new `BLI_subprocess` API, including IPC (required for the
  `GLShaderCompiler` implementation).
- The implementation of the subprocess program in
  `GPU_compilation_subprocess`.
- A new `Max Shader Compilation Subprocesses` option in
  `Preferences > System > Memory & Limits` to enable parallel shader
  compilation and the max number of subprocesses to allocate (each
  subprocess has a relatively high memory footprint).

Implementation Overview:
There's a single `GLShaderCompiler` shared by all OpenGL contexts.
This class stores a pool of up to `GCaps.max_parallel_compilations`
subprocesses that can be used for compilation.
Each subprocess has a shared memory pool used for sending the shader
source code from the main Blender process and for receiving the already
compiled shader binary from the subprocess. This is synchronized using
a series of shared semaphores.
The subprocesses maintain a shader cache on disk inside a
`BLENDER_SHADER_CACHE` folder at the OS temporary folder.
Shaders that fail to compile are tried to be compiled again locally for
proper error reports.
Hanged subprocesses are currently detected using a timeout of 30s.

Pull Request: https://projects.blender.org/blender/blender/pulls/122232
2024-06-05 18:45:57 +02:00
Brecht Van Lommel
939e4b2efc Core: Change portable install folder to portable/
There is a mechanism to store config files in the same folder as the
Blender executable. The typical use case is putting Blender on a USB
drive and taking the config with you.

However the problem is that this is using the 4.2/ folder, which is fine
for config/ but with e.g. addons, studiolights and now extensions this
is mixing user and system files. This requires exceptions, doesn't
work well in some cases and is just generally not great design.

Instead use a folder named portable/ that is separate.

Pull Request: https://projects.blender.org/blender/blender/pulls/122778
2024-06-05 18:36:13 +02:00
Clément Foucault
dea5db7e70 Fix: EEVEE-Next: Firefly caused by denoising shiny surfaces
This was caused by float imprecision in the NDF computation when
alpha was very close to 0. The alpha clamping threshold for the
eval function needs to be higher than the one for the sampling
function.

Fix #118997
2024-06-05 18:20:14 +02:00
Pablo Vazquez
7b601464c3 UI: Add new TAG icon
Introduce a new icon: `TAG`. A generic tag/label, to be used anywhere
there are tags.

Details and images in the pull request.

Pull Request: https://projects.blender.org/blender/blender/pulls/122738
2024-06-05 17:56:51 +02:00
Hans Goudey
05142b3ea8 Fix #122523: Crash/missing loose edge drawing with two viewports
With two viewports, and one viewport with overlays turned off, one viewport
first requests positions without calculating loose geometry, then the second
viewport can request the loose geometry index buffer. In that case the
previously-calculated positions VBO has the wrong size.

To fix this, always calculate loose geometry when the positions are requested.
That's required because we no simple way of checking whether the previously
uploaded positions included loose geometry. That was the state before recent
refactors in this area anyway.

This makes it clear that the optimization to not calculate loose geometry is
meaningless, because the positions buffer will always be requested at some
point when drawing a mesh.
2024-06-05 10:32:27 -04:00
Lukas Stockner
56ff0d414a Fix #121032: Shader Node preview crash for muted nodes with multiple editors
It seems that when ensure_nodetree_previews calls duplicate_material,
ntreeLocalize removes the muted node from the copy of the nodetree,
so later in ensure_nodetree_previews nodeFindNodebyName can't find it
and therefore parent is NULL.

With this change, the muted node just doesn't get its preview updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/122776
2024-06-05 16:27:28 +02:00
Clément Foucault
8f895ec781 Fix: EEVEE-Next: Wrong sun shadow pixel radius calculation
This fixes a number of issue with the pixel radius calculation.
- Fix factor of 2 being in the wrong place.
- `narrowing` is removed as this is not what we want
  to compute (see comment).
- The `lod_min` is not the actual minimum LOD. Clamp by
  both `clipmap_lod_min` and `clipmap_lod_max`.
2024-06-05 16:17:55 +02:00
Omar Emara
9b33340675 Fix #60940: Film-like mapping is bad for RGB curves
The Film-like curve mapping option in the RGB Curves node in the
compositor produces bad results when editing its RGB curves. That's
because Film-like curve mapping only works with the combined curve by
definition, since it is a hue preserving mapping. Furthermore, the
Film-like option ignored the white balancing step altogether.

To fix this, we hide the current curve option for the File-like option
and only allow editing the combined curve, handing the same case for
versioning and RNA updates. Further, we port the implementation from the
realtime compositor which is both correct and takes white balancing into
account.

Pull Request: https://projects.blender.org/blender/blender/pulls/122762
2024-06-05 13:29:39 +02:00
Thomas Dinges
618c497801 Release: Updates for the 4.2 branch
* Version bumps and pointing gitmodules to the branch.
* Splash screen by Blender Studio (studio.blender.org)
2024-06-05 12:31:19 +02:00
Clément Foucault
8d2421bcea Fix: EEVEE-Next: Broken Blend Mode versioning
This was caused by #122706 which moved the
versioning after linking where the engine is
already changed to EEVEE-Next. This made the
versioning never run.

# Conflicts:
#	source/blender/blenloader/intern/versioning_400.cc
2024-06-05 11:37:41 +02:00
Pratik Borhade
25351738f7 UI: Add title to tree view context menus
Add new string member in `AbstractView` class to store title/header of
tree view. Later use this to set title (`pup->title`) of context menu.

Pull Request: https://projects.blender.org/blender/blender/pulls/120694
2024-06-05 11:28:44 +02:00
Sebastian Parborg
38dd4a5e9a Fix: Wonky behaviour of "Frame All" and "Frame Selected" in the VSE
Both these operators would quite often put the framed strips offscreen.
This was in part due to the padding need to make sure that the strips
were not going to be obscured by the scrub area or overlays not being
applied or calculated correctly.

In addition to that, the view positioning logic was not in sync with the
vertical clamping code. This lead to the operators positioning the view
into a forbidden state. So the clamping logic would adjust the view
afterwards and thus put some of the framed strips offscreen.

This patch unifies the logic used by the "frame X" operators and the
clamping code, making them play nice with each other.

Pull Request: https://projects.blender.org/blender/blender/pulls/122219
2024-06-05 11:18:23 +02:00
Jacques Lucke
8beb91118c Cleanup: make format 2024-06-05 10:41:07 +02:00
Leon Schittek
db5d410164 Node Editor: add overlay to automatically label reroute nodes
Add an overlay option to automatically display a label on reroute nodes.

This automatic label is propagated through chained reroute nodes and
is based on the explicit label of linked reroute nodes.

The automatic label is dimmed to distinguish it from manually set ones.

Pull Request: https://projects.blender.org/blender/blender/pulls/113368
2024-06-05 10:02:37 +02:00
Nathan Burnham
1c92d26bfc PyAPI Doc: fix typos causing untyped parameters
The type for `bpy_struct.keyframe_insert()`'s `options` parameter was
instead applied to a non-existent `flag` parameter.

The description and type for `mathutils.Vector.Repeat()`'s `vector`
parameter was instead applied to a non-existent `tuple` parameter.

Also fix a reference to `BMElemeSeq` instead of `BMElemSeq`.

Ref: !122734
2024-06-05 16:25:05 +10:00
Lukas Stockner
5246fb5a57 Cycles: Implement blue-noise dithered sampling
This patch implements blue-noise dithered sampling as described by Nathan Vegdahl (https://psychopath.io/post/2022_07_24_owen_scrambling_based_dithered_blue_noise_sampling), which in turn is based on "Screen-Space Blue-Noise Diffusion of Monte Carlo Sampling Error via Hierarchical Ordering of Pixels"(https://repository.kaust.edu.sa/items/1269ae24-2596-400b-a839-e54486033a93).

The basic idea is simple: Instead of generating independent sequences for each pixel by scrambling them, we use a single sequence for the entire image, with each pixel getting one chunk of the samples. The ordering across pixels is determined by hierarchical scrambling of the pixel's position along a space-filling curve, which ends up being pretty much the same operation as already used for the underlying sequence.

This results in a more high-frequency noise distribution, which appears smoother despite not being less noisy overall.

The main limitation at the moment is that the improvement is only clear if the full sample amount is used per pixel, so interactive preview rendering and adaptive sampling will not receive the benefit. One exception to this is that when using the new "Automatic" setting, the first sample in interactive rendering will also be blue-noise-distributed.

The sampling mode option is now exposed in the UI, with the three options being Blue Noise (the new mode), Classic (the previous Tabulated Sobol method) and the new default, Automatic (blue noise, with the additional property of ensuring the first sample is also blue-noise-distributed in interactive rendering). When debug mode is enabled, additional options appear, such as Sobol-Burley.

Note that the scrambling distance option is not compatible with the blue-noise pattern.

Pull Request: https://projects.blender.org/blender/blender/pulls/118479
2024-06-05 02:29:47 +02:00
Hans Goudey
c1a9ccdf0b Cleanup: Sculpt: Remove redundant flag passed to bounds update
PBVH_UpdateRedraw was always combined with PBVH_UpdateBB.
The use for the "redraw update" isn't clear anyway, since there are
more specific tags for everything that would require a redraw.
2024-06-04 16:06:26 -04:00
Hans Goudey
1e85cdc9ad Cleanup: Sculpt: Move bounds functions to group them together 2024-06-04 16:06:25 -04:00
Hans Goudey
3fa25e3986 Cleanup: Sculpt: Rename and document PBVH bounds functions and fields 2024-06-04 16:06:25 -04:00
Bastien Montagne
fad031a3a9 Fix (unreported) crash when setting current frame from the UI.
Regression from f98b01e492. Better check if a Scene has a sequence
editor, before accessing its data...
2024-06-04 21:51:16 +02:00
Habib Gahbiche
ccdba13492 Compositor: remove viewer crosshair to set tile priority
The functionality has already been removed in https://projects.blender.org/blender/blender/pulls/121176. This patch removes the drawing in backdrop compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/122639
2024-06-04 21:15:17 +02:00
Habib Gahbiche
6521577e4a Fix compositor crop gizmo ignores offset
Backdrop gizmo of Crop Node ignores image offset caused by Transform or Translate node

Pull Request: https://projects.blender.org/blender/blender/pulls/122632
2024-06-04 21:14:35 +02:00
Aras Pranckevicius
078a737fd6 Format 2024-06-04 22:08:42 +03:00
Omar Emara
4f21b26675 Fix #121639: Glare shifts the colors of highlights
The Glare node shifts the color of the highlights when the threshold is
high. That's because the thresholding algorithm simply subtracts the
threshold from the RGB data, which is not expected to retain the same hue
of the color.

To fix this, we do the thresholding only on the luminance of the color
in HSV color space. This eliminates the color shifting and also helps to
smooth the edges of the highlights.

This is a breaking change, but it is more of a fix rather than a change
of behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/122570
2024-06-04 20:59:32 +02:00
Jesse Yurkovich
9ad2c7df0b USD: implement native Unicode support
Make use of USD's new UTF-8 support to allow our import/export code to
accept and generate appropriate USD files. This has been a long standing
shortcoming since USD's introduction, with incomplete and complicated
DCC-specific workarounds often attempted.

Summary of changes
- Export gets a new "Allow Unicode" option defaulting to "false". The
  new Unicode USD files are not backward compatible. DCCs using older
  versions of USD (before 24.03) will not be able to load such files so
  we want to provide this as an opt-in option for now.
- Every location which used to call either `USDHierarchyIterator::make_valid_name`
  or `pxr::TfMakeValidIdentifier` will now go through a new `make_safe_name`
  API instead
- Export code is responsible for passing in the `allow_unicode` option
- Import code will always pass in `true` meaning Blender will happily
  accept both existing and new Unicode USD files

Strangely, USD does not provide a convenient way of making valid UTF-8
identifiers and they left their old API unchanged. We had to roll our
own per their advice: https://forum.aousd.org/t/how-to-make-a-unicode-identifier-valid/1435

Pull Request: https://projects.blender.org/blender/blender/pulls/122471
2024-06-04 20:53:57 +02:00
Harley Acheson
f5131cdee0 Fix #122411: Sub-panels Not Clickable When Popover is Scaled
When a popover includes panels, the calculation of whether the mouse
is over the panel header does not take into consideration local 2D
scaling. Therefore the hit area is in the wrong location if scaled.

Pull Request: https://projects.blender.org/blender/blender/pulls/122696
2024-06-04 20:28:12 +02:00
Sean Kim
dd9ea5de6b Sculpt: Adjust Extrude Mode option descriptions
Adjusts the UI text to be similar to the manual description

Pull Request: https://projects.blender.org/blender/blender/pulls/122731
2024-06-04 20:26:44 +02:00
Hans Goudey
ed998449d4 Cleanup: Remove redundant prefixes in sculpt_boundary.cc
Remove parts of function names that are redundant with the namespace.
2024-06-04 14:22:13 -04:00
Hans Goudey
bf02cead33 Cleanup: Remove redundant prefixes in sculpt_expand.cc
Remove parts of function names that are redundant with the namespace.
2024-06-04 14:22:13 -04:00
Hans Goudey
b5ef3f0b6a Cleanup: Sculpt: Move update flush tags and functions to namespace
Also conver the update flags to  a regular enum class.
Only a single type was used at the same time anyway.
2024-06-04 14:22:13 -04:00
Aras Pranckevicius
7fdfa47f23 VSE: Rounded corners for timeline strips
VSE timeline strips now have rounded corners. Strip corner rounding radius is
4, 6 or 8px depending on strip height (if strip is too narrow to fit
rounding, then rounding is turned off).

This is achieved with a dedicated GPU shader for drawing most of VSE
strip widget, that it could do proper rounded corner masking.

More details and images in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/122576
2024-06-04 20:05:35 +02:00
Jacques Lucke
1604eb9821 Geometry Nodes: expose instance transform field as default input for node groups 2024-06-04 19:02:02 +02:00
Jacques Lucke
820edb920d Geometry Nodes: use instance transform as default in Set Instance Transform node
With this, the node does not change the transforms of the instances by default.
Previously, all instances were always reset to the origin.
2024-06-04 18:42:42 +02:00
Jacques Lucke
a26962ee75 Fix: handle object transforms with skew more gracefully in Object Info node
This is similar to the changes done for `normalized_to_quaternion_safe`.
It's quite easy to get object matrices with skew by rotating an object and making
if a child of another non-uniformly scaled object.
2024-06-04 18:35:37 +02:00
Hans Goudey
aa81e2dd4a Fix #122455: Wireframe overlay can crash with loose geometry
The `nor` vertex buffer wasn't large enough for the indices in the lines
index buffer. This is undefined behavior at best AFAIK. On some drivers
it caused crashes when there was only loose geometry.

This commit makes the VBO large enough for all indices, filling the loose
geometry normals with (0,0,0,0), which the overlay wireframe shader
already checks for.

Pull Request: https://projects.blender.org/blender/blender/pulls/122720
2024-06-04 17:43:11 +02:00
Falk David
b5a4786064 GPv3: Draw Tool: Stabilize Stroke setting
This adds the "Stabilize Stroke" setting to GPv3.

It also makes it possible to hold "shift" to activate the stabilize option
temporarily like in GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/122556
2024-06-04 17:35:48 +02:00
Clément Foucault
57e92e9192 Fix: Overlay: Facing overlay is not transparent with zero alpha
The recent changes removed the blending when rendering
to the framebuffer. The blending was doing the
premultiplication.

Fix #122470
2024-06-04 17:19:22 +02:00
Clément Foucault
916d9d5beb Fix: EEVEE-Legacy: Forgot version bump
This was lost during a merge.
2024-06-04 17:10:05 +02:00
Jacques Lucke
be0d7522ea Geometry Nodes: support link drag search for capture attribute node
Now it's possible to use link-drag-search with the extend socket of the Capture Attribute node again.

Implementation wise, the main unexpected things I noticed are that
`update_and_connect_available_socket` did not update the node declaration and currently uses
socket names instead of identifiers. This works fine right now, but should eventually be changed
to use identifiers (separate from this commit though).

Pull Request: https://projects.blender.org/blender/blender/pulls/122716
2024-06-04 16:58:14 +02:00