Commit Graph

120055 Commits

Author SHA1 Message Date
Alexander Gavrilov
f5602becde Shape Keys: replace the BKE_keyblock_from_key function with find_index.
The function for retrieving a shape key by its index is named
somewhat confusingly, and effectively reimplements BLI_findlink.

However, more importantly, for some reason it is coded to return
null for the index 0 instead of the basis shape key. This severely
limits its usability in some cases.

This refactor replaces the function with a simple strongly typed
wrapper around BLI_findlink, using a different name, and updating
the call sites to check that the index is not 0 where necessary.
2024-01-18 13:17:20 +01:00
Jeroen Bakker
1ba2c933b4 Fix: Compile Issue Grease Pencil 2024-01-18 13:07:09 +01:00
YimingWu
4d387843e9 GPv3: Subdivide Modifier
This ports the Subdivide modifier from GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/117056
2024-01-18 13:02:53 +01:00
Bastien Montagne
03c1cc4310 Cleanup: Move BKE_lib_query header to Cpp era. 2024-01-18 12:21:19 +01:00
Omar Emara
feb2d02709 Realtime Compositor: Rewrite Pixelate node
This patch rewrites the pixelate node to average a window of a certain
pixel size, following the new CPU implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/117243
2024-01-18 11:52:20 +01:00
Falk David
c448fd214c Fix: ModifierTypeFlag max value
The maximum value of `ModifierTypeFlag` was not updated.
2024-01-18 11:46:10 +01:00
Omar Emara
5309d1c574 Fix: Crash in Defocus node when no camera exist
The Defocus node crashes when no camera exist in the scene. We fix this
by defaulting to a focus distance of 10 when a camera doesn't exist.
2024-01-18 12:34:55 +02:00
Sergey Sharybin
baab14ca38 Compositor: Re-write Pixelate node for CPU compositor
The old implementation was a simple rounding operation and was not
implemented for full-frame compositor.

The issue with the old implementation is that it will not give
satisfactory results for images with high frequency details,
including cases when is used for a preview on Cycles render with
low number of samples. Additionally, when applied on animated
footage it produces very noisy result.

The new algorithm uses an explicit pixel size setting, which allows
the node to be used on its own, without need to have scale-down and
scale-up nodes. It also uses neighbour averaging, which produces
better looking result during animation and noisy input images.

The old tiled compositor setup will render without changes with
this change. This commit does not include modifications in the GPU
compositor implementation.

Ref #88150

Pull Request: https://projects.blender.org/blender/blender/pulls/117223
2024-01-18 11:30:55 +01:00
Jeroen Bakker
545f2c04fa EEVEE: Skip Forward Rendering Pipeline Stages When Empty
Increase performance when drawing scenes that don't have blended materials. This should
save some CPU and GPU cycles as parts (or the whole pipeline) can be skipped.

Mostly it ensures that the hiz isn't tagged dirty and has a chance that it is being reused
by other areas. Shadows and irradiance caches aren't forced to be updated.

Mac Studio M1 Ultra
 - space_raceship.blend went from 27 fps to 33 fps (10%-20% improvement).

This is a common scenario to optimize as by default materials are not blended and require
user action to set them up. When using compositing/renderpasses, blended materials aren't
supported and most likely not being used.

Pull Request: https://projects.blender.org/blender/blender/pulls/117269
2024-01-18 11:10:03 +01:00
Omar Emara
d875e5d4cb Fix: Wrong GPU compositor assert in background mode
An assert that ensures the GPU compositor executes in a non main thread
wrongly fires in background mode, that's because in background mode,
rendering happens in the main thread. So add a condition for background
mode.
2024-01-18 11:31:59 +02:00
Christoph Lendenfeld
d08e826b24 Fix #115183: Show errors only shows errors when channels have been expanded
When enabling the "Only Show Errors" option in the Dope Sheet/Graph Editor,
it might not show anything even though there are FCurves with errors.
The issue is that the flag `FCURVE_DISABLED` is set by the drawing code,
which means the channels have to be visible first.
This creates a workflow issue where you want to filter down to only the
curves with problems, but you need to find them first...

This PR fixes the issue by validating all FCurves whenever the option
is enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/116815
2024-01-18 10:27:12 +01:00
Campbell Barton
0192a955be Cleanup: reduce variable scope & use const values 2024-01-18 15:19:04 +11:00
Campbell Barton
12195eb6e1 PyAPI: keep the associated preference when renaming an add-on module 2024-01-18 14:53:53 +11:00
Damien Picard
8564e03cdf Fix FPS menu in "Format" panel not following translation setting
The FPS menu was using a cached value which wasn't being refreshed
when translation changed.

Add `bpy.app.handlers.translation_update_post` handler which runs
when translation changes, this can be used to clear any cached UI
values.

Ref !117049
2024-01-18 11:31:38 +11:00
Campbell Barton
d068407a00 Fix #114801: Scene.use_audio value flipped
Regression in [0] caused the value to be flipped.

[0]: e37dc17991
2024-01-18 11:01:13 +11:00
Campbell Barton
b8a340e630 UI: always return shortcuts from UI_but_string_info_get on request
Change the behavior of UI_but_string_info_get to fill in shortcuts
when requested.

Previously shortcuts were ignored for menus, because showing shortcuts
in tool-tips which are already displayed in the menu isn't needed.

Move this logic to tool-tip creation so other the shortcuts may be
accessed in other contexts.
2024-01-18 10:52:58 +11:00
Campbell Barton
a3b4078be3 Cleanup: spelling in comments 2024-01-18 10:39:24 +11:00
Campbell Barton
c48283edcb Cleanup: quiet enum conversion warning 2024-01-18 10:38:23 +11:00
Hans Goudey
633e8f09c8 Cleanup: Remove unused asset C functions
This information can be retrieved from `AssetRepresentation` now.
Also remove unnecessarily specific lambda capture. That usually suggests
usage in `std::function` with a more complex lifetime.
2024-01-17 11:13:35 -05:00
Harley Acheson
8ba7e40bb4 Revert #106653: Cleanup Dialog to Manage Orphaned Data
Reverting 58e1e88dc3 because of concerns by reviewer.

Pull Request: https://projects.blender.org/blender/blender/pulls/117241
2024-01-17 17:05:24 +01:00
Falk David
4a77cdf745 Cleanup: GPv3: Remove unused editor function 2024-01-17 16:53:56 +01:00
Falk David
f566f51f29 Cleanup: GPv3: Move curve smoothing to geometry namespace
Moves the `gaussian_blur_1D` and `smooth_curve_attribute` functions to the `geometry` namespace.

Pull Request: https://projects.blender.org/blender/blender/pulls/117238
2024-01-17 16:48:35 +01:00
Omar Emara
e4a93d7b8c Compositor: Add High Precision option to Kuwahara
For high radii Kuwahara, we use a Summed Area Table (SAT) implementation
to accelerate the classic variant of the algorithm. The problem is that
due to limited floating point precision, the SAT can produce artifacts
in its output.

An attempt to fix this was implemented in #114191, and while that patch
improved precision by 10x, the artifacts still existed, albeit less
noticeable. But since the improved precision also meant a performance
penalty, it was decided that the improvement is not worth it.

Since the artifacts are only noticeable for scenes with very high
values, this patch adds a High Precision option that defaults to false
and can be enabled by the user upon noticing any artifacts. The option
simply uses direction convolution instead of SAT in this case. The
downside, of course, is that it can be orders of magnitude slower.

An alternative to using this option is for the user to clamp the input
or downsample the image. Both methods should be documented in the
documentation.

Fixes: #113578.

Pull Request: https://projects.blender.org/blender/blender/pulls/115763
2024-01-17 14:30:29 +01:00
Pratik Borhade
1e85feb542 Fix #117161: Detectable geometry for the brush doesn't update after Undo
Caused by aaa25bc882
This seems to be due to missing flag for updating bounds

Pull Request: https://projects.blender.org/blender/blender/pulls/117192
2024-01-17 14:29:53 +01:00
Jacques Lucke
c954940e76 Fix: remove assert when creating interface socket
We don't actually protect against interface sockets with empty
names elsewhere. This assert was triggered when trying to group
a `Bake` node, because it tried to create an interface socket of
the extend socket. This case is handled by the check below.
2024-01-17 14:27:51 +01:00
Falk David
049e48b431 GPv3: Add curve plane normal cache
This adds a cache to read a normal vector for a plane that (roughly) fits a curve.
If the curve lies on a plane, the vector always point along this plane normal, otherwise it's an approximation.
The cache is lazily calculated and invalidated when the positions are tagged for a change.
2024-01-17 14:09:42 +01:00
Omar Emara
f020e436d5 Fix #117171: Assert in GPU compositor Denoise node
Blender asserts when an Image node is directly connected to a Denoise
node in the GPU compositor. This is because the node reads the image to
host memory, but the cached image didn't specifiy host read usage. This
patch adds the host read usage flag to the IMB module GPU image creation
functions.
2024-01-17 14:45:04 +02:00
Jacques Lucke
f777b1b183 Cleanup: make format 2024-01-17 13:41:33 +01:00
Jacques Lucke
9df4ffc0c2 Geometry Nodes: reorganize panels in modifier
The goal is to simplify the interface of the geometry nodes modifier while also
making it more scalable. This allows creating better looking modifiers which
feel more built-in. No functionality is removed by this patch.

The following changes are done:
* The `Output Attributes` panel is hidden when there are no output attributes.
* The `Internal Dependencies` panel is replaced by a new `Manage` panel that
  contains all the stuff that is common to all geometry nodes modifiers. It
  contains new `Bake` and `Named Attributes` panels for now.

Potential next steps:
* Merge `Output Attributes` panel with the rest of the input list.
* Support hiding the `Manage` panel under some circumstances.

Pull Request: https://projects.blender.org/blender/blender/pulls/117170
2024-01-17 13:40:30 +01:00
Jacques Lucke
8feba61c41 Geometry Nodes: support synchronous baking
Previously, calling the bake operator was always creating a job that will
be run in parallel to Blender. This is good when baking from the UI, but may
be undesired when baking with a script.

Now, when the `exec` method of the bake operator is called, the baking
happens synchronously. That means that the operator call will return only
after the baking is done. The `invoke` method has the same behavior as
before. This approach is similar to e.g. `FLUID_OT_bake_all`.

I did notice that calling the invoke method from a script can still result
in a crash sometimes, probably due to conflicting depsgraph evaluations.
That has to be investigated more.
2024-01-17 13:32:10 +01:00
Omar Emara
65e1a3a5c3 Compositor: Port redesigned Defocus node to CPU
This patch ports the redesigned GPU Defocus node to the CPU.

Pull Request: https://projects.blender.org/blender/blender/pulls/117174
2024-01-17 13:19:10 +01:00
Jacques Lucke
f811e9c6d6 Fix: crash when adding repeat zone from search
The issue was that some code expected the "extend" sockets
to always exist. This was already always true from the user
point of view, but not internally.

There are different possible fixes, but this patch makes sure
that the extend socket will be available as expected. This is
achieved by making them part of the static node declaration.
We want to extend the static declaration of such dynamic
nodes anyway, to improve reflection capabilities without
having to instantiate nodes.
2024-01-17 12:45:06 +01:00
Pratik Borhade
e39bd974a0 Cleanup: Curves: Remove redundant resizing in extrude operator
Curve resizing is already handled in `copy_only_curve_domain` (i.e.
copy curve nums/attributes, point_num = 0, fresh offset array)

Pull Request: https://projects.blender.org/blender/blender/pulls/117166
2024-01-17 12:31:52 +01:00
Pratik Borhade
b10953d957 Fix #117191: Crash using the Extrude tool and Snap Base
`GIZMO_GT_button_2d` has no modal/custom_modal callback function
defined hence the crash due to calling `modal_fn()`

Pull Request: https://projects.blender.org/blender/blender/pulls/117194
2024-01-17 12:28:14 +01:00
Pratik Borhade
8b454fe5d4 Curves: Debug crash after switching to sculpt mode
`bounds_min_max` returns an optional and it can be `nullopt` when
curve points are 0.

Pull Request: https://projects.blender.org/blender/blender/pulls/117163
2024-01-17 12:20:28 +01:00
Jacques Lucke
65b722bc30 Geometry Nodes: expose NodesModifierBake.node property in Python API
This allows scripts to filter the set of bakes by e.g. the node name.
More filtering options will be necessary, but this is a good start.
2024-01-17 11:48:06 +01:00
Jacques Lucke
7149424087 Geometry Nodes: expose bake id in Python API
This is necessary to be able to invoke baking of individual bake nodes
or simulation zones with Python.
2024-01-17 10:37:30 +01:00
Aras Pranckevicius
b85fecee67 VSE: Speedup Subsampled 3x3 image filter
Make Subsampling 3x3 filter twice faster (on 4K UHD resolution,
Windows/VS2022/Ryzen5950X: 52.7ms -> 28.3ms), by reformulating how it works:

Conceptually Subsampling filter is a box filter: it sums up N source image
pixels, computes their average and outputs the result. Critical thing is,
that should be done in premultiplied space so that colors from fully or
mostly transparent regions do not "override" opaque  colors.

Previously, when operating on byte images, the code achieved this by always
working on byte values, doing "progressively smaller" lerp into byte color
result, taking care of premultiplication and again storing the "straight"
alpha for each sample being processed. This meant that for each sample, there
are 3 divisions involved! This also led to some precision loss, since for all
9 samples all the intermediate results would only be stored at byte precision.

Reformulate that by simply accumulating the premultiplied color as a float.
This gets rid of all divisions, except the last step when said float needs to
be written back into a byte color.

The unit test results have a tiny difference, since now it is arguably better
(as per above, previously it was having some precision loss).

Pull Request: https://projects.blender.org/blender/blender/pulls/117125
2024-01-17 10:26:50 +01:00
Sergey Sharybin
11c2028795 Render: Set non-color colorspace for ImBuf of data passes
This allows code outside of the render pipeline to make proper
decisions about how the imbuf of render passes are to be handled.

For example, IMB_create_gpu_texture() will now properly select
single channel grayscale texture format for depth pass coming from
multilayer EXR, additionally solving assert in the GPU compositor
code which verifies expected and actual imbuf texture format.

Pull Request: https://projects.blender.org/blender/blender/pulls/117184
2024-01-17 10:02:59 +01:00
Sergey Sharybin
40035046ca Fix incorrect number of planes for ImBuf used for render passes
Set the number of planes based on the number of pass channels.

If the pass contains 2 passes or more than 4 passes set the number
of planes to the previously used value of 32.

This is needed because quite some areas check for the number of
planes for various optimizations. For example, this is one of the
factors which make IMB_create_gpu_texture() to choose the texture
format. If the number of planes for the depth pass is set to the
previously used this function will never consider using single
channel GPU texture.

Unfortunately, this change is not enough to make the GPU texture
to use single channel format as the color space of the image
buffer is also checked, and that is nullptr which means scene linear.
2024-01-17 10:02:58 +01:00
Campbell Barton
ae29c8d950 Fix font sub-pixel AA impacting character spacing when AA is disabled 2024-01-17 18:36:54 +11:00
Campbell Barton
7dd81cad94 Fix #117188: Context.temp_override() failed with full-screen areas
Using screen changing functions with screens used for full screen areas
isn't supported & caused corrupt screen data.

Add checks that the current and overriding screen support switching,
raising an error when they don't. Also add a check when restoring the
context not to change any full screen areas.
2024-01-17 16:18:54 +11:00
Hans Goudey
a2032a9aa5 Fix: Tooltip contains bogus text after recent button string cleanup
The code still needs to differentiate a null string from an empty
string in one cast I missed earlier.
2024-01-16 19:32:05 -05:00
Hans Goudey
35028d9480 Fix: Memory leaks after recent button string cleanup 2024-01-16 19:18:37 -05:00
Campbell Barton
fd4dc38264 Fix #107805: Render border without an active region crashes 2024-01-17 11:13:07 +11:00
Harley Acheson
58e1e88dc3 UI: Cleanup Dialog to Manage Orphaned Data
Creates a new "Cleanup" dialog that allows purging unused data blocks,
as well as a window used for managing unused data blocks.

Pull Request: https://projects.blender.org/blender/blender/pulls/106653
2024-01-17 01:09:12 +01:00
grady
796577d76e Outliner: Double-click on item icon to select contents/hierarchy
Allow double-clicking on Outliner items to select all child items.

Pull Request: https://projects.blender.org/blender/blender/pulls/110151
2024-01-17 00:45:43 +01:00
laurynas
a6fd1f5034 Fix: Curves extrude with all points selected
CurvesGeometry has no ".selection" attribute when all control points
are selected. The earlier code assumed that the attribute always exists.
Also Python tests are added for the "extrude" operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/117095
2024-01-16 21:59:15 +01:00
Hans Goudey
bff51ae66c Cleanup: Use std::string to store UI button string
This simplifies memory management and button string manipulation in
general. Just change one of the few strings stored in `uiBut` for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/117183
2024-01-16 21:04:17 +01:00
Aras Pranckevicius
2391338ba0 Cleanup: simplify code in IMB_transform
There were some abstractions inside `IMB_transform` implementation
that were kinda getting in the way. I want to speed up Subsampled3x3
filtering by reformulating the math being done, but that needs to
sample byte images while storing intermediate result as a float -- but
the whole `Pixel`, `PixelPointer` et al. machinery was not quite prepared
to deal with that. Feels like those helper classes do not achieve much,
just make the code longer.

So remove them (`Pixel`, `PixelPointer`, `ChannelConverter` etc.) and
use simple functions. Now the code is more straightforward (IMHO) and
270 lines shorter (40% of the whole file!), and allows me to do the
follow-up optimization easier.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/117182
2024-01-16 20:39:09 +01:00