Commit Graph

105968 Commits

Author SHA1 Message Date
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
Hans Goudey
67ec39defa Cleanup: Use Map instead of GHash for memfile writing
The goal is to simplify future work on #106903.

Pull Request: https://projects.blender.org/blender/blender/pulls/117141
2024-01-16 19:41:30 +01:00
Hans Goudey
b6d493e8a7 Cleanup: Use LISTBASE_FOREACH file in memfile merge 2024-01-16 13:36:43 -05:00
Hans Goudey
bd9ee026cf Cleanup: Remove unnecessary extern symbols in undofile header 2024-01-16 13:35:38 -05:00
Hans Goudey
34d2bfecb7 Cleanup: Make format 2024-01-16 13:25:46 -05:00
Falk David
595c70c90c Cleanup: GPv3: Modifier filter UI 2024-01-16 18:37:34 +01:00
Jacques Lucke
776604be66 Fix #117168: crash when using layout panel in popover
Using layout panels in this context is not yet supported. Therefor, the fix
is to raise an exception instead of crashing.

The problem here is that layout panels need an a parent panel which
has a persistent state. The popover currently does not only has a very
short-lived panel currently that is freed directly after drawing.
Also see `ui_paneltype_draw_impl`.

It's likely that support for this can be added in the future but it's currently
unclear how many changes this would require.
2024-01-16 18:33:14 +01:00
Falk David
6a23ea705a GPv3: Change display name of modifier to "Opacity" 2024-01-16 18:19:24 +01:00
Falk David
991b588cc0 Fix: GPv3: Opacity modifier compilation error
The parameters for `threading::parallel_for_each` were not correct.
2024-01-16 18:17:26 +01:00
Lukas Tönne
c02f3c94d9 GPv3: Opacity modifier
Opacity modifier implementation based on GP2.
Functionality is largely unchanged.

_Color Mode_ is either `Stroke` or `Fill` for modifying color opacity or
`Hardness`.
_Uniform Opacity_ does two things at once (!):
- Sets the same opacity value for every point in a stroke.
- Sets opacity as an absolute value rather than a factor.

_Weight as Factor_ (button to the right of Opacity Factor): Use the
vertex group as opacity __factor__ rather than an overall __influence__.
This is confusing and hard to convey, but copies behavior from GP2.

The _Influence_ panel contains the same filter settings as the GP2
modifier, with some small changes:
- _Layer_ selects only strokes in the respective layer (with an _Invert_
  option)
- _Material_ selects only points with the respective material (with an
  _Invert_ option)
- _Layer Pass_ and _Material Pass_ select only strokes/points which are
  rendered in the respective pass.
  _Note 1: Layers don't have UI for setting a pass yet, this will be a
  generic layer attribute. This can be set through the API for testing._
  _Note 2: In GP2 a pass value of zero was used to disable pass filters.
  Since zero is a valid pass ID an explicit flag has been added for the
  purpose of turning pass filters on and off._
- _Vertex Group_: This can be used as an additional influence filter on
  points. If _Weight as Factor_ is enable the vertex group instead
  replaces the opacity factor. In _Fill_ mode the vertex group weight of
  the stroke's first point is used as influence for the entire stroke.
- _Custom Curve_ is another possible influence factor per point. The
  curve input value is the relative position of a point along its
  stroke.

The Influence settings have been moved into a separate DNA struct, which
should help with reusability in various modifiers. Various utility
functions can be found int `MOD_grease_pencil_util.hh` for handling
influence settings and generating `IndexMasks` for modernized C++ code.

Pull Request: https://projects.blender.org/blender/blender/pulls/116946
2024-01-16 16:56:14 +01:00
Jacques Lucke
766c1e2f8d Fix: crash trying to store an attribute on unsupported grease pencil domain
This crash happened when trying to store an attribute on the edge domain
on a grease pencil geometry.
2024-01-16 16:19:28 +01:00
Jacques Lucke
6a35c8c99e Fix: incorrect Exists output in Named Attribute node for grease pencil
Grease pencil needs some special handling because it stores layer attributes
independently of point/curve attributes.
2024-01-16 16:16:12 +01:00
Lukas Tönne
83d3ba8a58 Fix #116477: Node group sockets with subtypes have broken idnames
Loading pre-4.0.20 node groups with sockets using subtypes causes
broken socket identifiers. This is because the node tree interface now
expects sockets to use the base identifiers ("NodeSocketFloat" instead
of "NodeSocketFloatFactor" etc.).

To correct this the conversion code now replaces socket idnames that
include a subtype suffix with their base names. This fix is also applied
to files between versions 4.0.20 and 4.1.10, where the socket types
may have been converted incorrectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/117133
2024-01-16 15:32:33 +01:00
Hans Goudey
ccd85adabb Fix #117158: Multires sculpting crash
The change to use `float3` in `frontface` didn't account for the
fact that the values we sometimes null.
2024-01-16 08:53:14 -05:00
Philipp Oeser
c5e2ec8a1a Report when register_class overrides classes with the same bl_idname
The unregistering of already registered classes is expected behavior,
however this was done silently and can be unsafe as two Addons may have
the same names for operators and in case of name collision the addon
registered first will break silently / start behave unexpectedly.
So reporting the unregister step seems reasonable.

During Addon development, this might seem noisy when classes are
frequently updated, however catching the problematic cases instead of
being silent might be beneficial.

Part of #116370

Pull Request: https://projects.blender.org/blender/blender/pulls/116374
2024-01-16 14:43:39 +01:00
Lukas Tönne
53e34dba80 Fix #115727: Draw panel buttons in the node editor side bar
In 13fac109 the node panels got support for individual option button
callbacks, but these were not included in the node editor side bar.
Only the older top-level buttons are drawn there.

The panel structure is currently not accessible in python since it is
part of the `NodeDeclaration` system. To draw node input sockets and
buttons in the correct panel order as they appear on the node, a new
template function `uiTemplateNodeInputs` has been added. This iterates
over declared panels and their contents in the appropriate order and
draws the buttons before sockets in the same panel.

Pull Request: https://projects.blender.org/blender/blender/pulls/116936
2024-01-16 13:37:57 +01:00
Aras Pranckevicius
f16dbd0360 ImBuf: no need to use double precision inside IMB_transform
Double precision pixel coordinate interpolation was added in 3a65d2f591 to
fix an issue of "wobbly" resulting image at very high scale factors. But
the root cause of that was the fact that the scanline loop was repeatedly
adding the floating point step for each pixel, instead of doing multiplication
by pixel index (repeated floating point additions can "drift" due to
imprecision, whereas multiplications are much more accurate).

Change all that math back to use single precision floats. I checked the
original issue the commit was fixing, it is still fine. Also added a gtest
to cover this situation: `imbuf_transform, nearest_very_large_scale`

This makes `IMB_transform` a tiny bit faster, on Windows/VS2022/Ryzen5950X
scaling an image at 4K resolution:
- Bilinear: 5.92 -> 5.83 ms
- Subsampled3x3: 53.6 -> 52.7 ms

Pull Request: https://projects.blender.org/blender/blender/pulls/117160
2024-01-16 13:32:47 +01:00
Jeroen Bakker
8954099042 EEVEE: Fix Lights On High-res Monitors
When using EEVEE on high resolution monitors the light buffers might not
get initialized as there are range checks that pass in the first try.

- number of tiles needed is larger than the max_tile_count_threshold
- total_word_count is smaller than max_word_count_threshold as it is
  never set (still initialized to zero.

Solution is to not exit on the first try. In a later stage we might want
to use something that doesn't require any looping.

Fixes: #117128
Pull Request: https://projects.blender.org/blender/blender/pulls/117164
2024-01-16 13:29:25 +01:00
Falk David
c4aef91652 Fix: GPv3: Selection not working in crazyspace
The check if the number of layers in the original and evaluated objects match was inverted.
2024-01-16 10:54:58 +01:00
Sybren A. Stüvel
211f6ddd29 Refactor: Anim, add ATTR_WARN_UNUSED_RESULT to some functions
Add `ATTR_WARN_UNUSED_RESULT` to the
`BKE_animsys_eval_context_construct` and
`BKE_animsys_eval_context_construct_at` functions. They are pure
functions, and without using their returned value they are pointless.

No functional changes.
2024-01-16 10:48:44 +01:00
Omar Emara
753c52ba15 Fix: Sequencer crash with scene strip of no composite output
If a scene sequencer strip references a scene with no composite output,
it will crash due to null image buffer output. This patch fixes that by
allocating an empty buffer in those cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/117135
2024-01-16 09:13:30 +01:00
Campbell Barton
a294a9083e UI: don't show property shortcuts in menus
Operator shortcuts aren't shown in this case,
use the same logic for properties.
2024-01-16 14:09:37 +11:00
Hans Goudey
17040a0b24 Fix #117108: Memory leak report with static select engine data
Now that the select engine data uses non-trivial objects in its global
data, storing it at the global scope causes trouble due to arbitrary
construction and destruction order. Instead use the construct on first use
idiom to make the order clear. Though this struct probably shouldn't be
static at all, it does simplify memory management as well, it's nice to
remove the need to manually clear the arrays.

Pull Request: https://projects.blender.org/blender/blender/pulls/117147
2024-01-16 01:55:18 +01:00
Hans Goudey
da5d3c11b6 UI: Consistent capitalization in operator description
The HIG mentions that these descriptions and messages
generally don't capitalize names of specific concepts or things.
2024-01-15 13:30:35 -05:00
Harley Acheson
dc18622572 Fix: Handle Deleted Files in the Recent List
Handle items in the Open Recent list being unavailable. Keep current
overall behavior, but show "File Not Found" on the tooltip.

Pull Request: https://projects.blender.org/blender/blender/pulls/117139
2024-01-15 19:23:01 +01:00
Hans Goudey
3e76a1a6c2 Cleanup: Move BKE_lib_id.h to C++ 2024-01-15 12:44:14 -05:00
Hans Goudey
ca560cd15e Cleanup: Move BKE_undo_system.h to C++ 2024-01-15 12:44:13 -05:00
Sebastian Parborg
5c32b9ad38 VSE: Speed up "Alpha Over/Under" if the pixels are fully transparent or opaque
Before we always did a float conversion of the colors even if we
wouldn't use the result.
Because the float conversion does alpha premultiplication, we can
use some shortcuts to skip a lot of computations

In a edit with a lot of fully transparent pixels, I observed a reduction
in total render time from 1m 31s to 1m 17s.

Pull Request: https://projects.blender.org/blender/blender/pulls/117134
2024-01-15 18:12:51 +01:00
Hans Goudey
78587261da Cleanup: Use standard variable name for mesh face corner normals 2024-01-15 11:39:50 -05:00
Hans Goudey
62dbef895b Mesh: Add missing sharing of cached face corner normals
Sharing of the normals cache between copied meshes was missing from
89e3ba4e25, which under-represented the benefits of the
change. In a simple file where geometry nodes causes a re-evaluation
without changing the normals, this increased FPS from 2.6 to 14.
2024-01-15 11:19:49 -05:00
Thomas Barlow
fdb56c4e8d RNA: Speed up raw array access when the property is stored contiguously
Recent and ongoing efforts have changed many properties to be stored
contiguously in memory, e.g. mesh attributes. This patch updates
rna_raw_access to make use of this and copy the entire contiguous block
of memory when the property is stored contiguously.

This is faster and scales much better with larger arrays.

Pull Request: https://projects.blender.org/blender/blender/pulls/116015
2024-01-15 17:17:02 +01:00
Falk David
35e8959d77 GPv3: Add function to get the index of a layer 2024-01-15 17:01:54 +01:00
Miguel Pozo
ef6b6031de Fix #117123: EEVEE: Broken Specular BSDF
Add missing disable sss flag
2024-01-15 16:57:18 +01:00
Aras Pranckevicius
709b00179f VSE: add Bicubic filtering option, and optimize bicubic performance
Part of overall "improve filtering situation" (#116980) task:

* Add Bicubic filtering option to strip Transform "Filter" setting.
Previously this option only existed in Transform Effect "Interpolation"
setting.
  - With this addition, it feels like the transform effect could
    possibly be marked as legacy/deprecated, since the regular Transform
    that is on all strips can do everything that Transform Effect did?
* Speed up bicubic filtering (used now in VSE, but also in CPU Compositor,
  image paint, etc.) by slightly simplifying the code and using some SIMD.
  Upscaling 96x54 image to 3840x2160 resolution, using Bicubic filtering:
  - Windows (VS2022, Ryzen 5950X): 35.5ms -> 15.1ms
  - Mac (clang 15, M1 Max): 29.6ms -> 24.4ms
* Add gtest coverage for bicubic functionality.

Pull Request: https://projects.blender.org/blender/blender/pulls/117100
2024-01-15 16:38:41 +01:00
Sybren A. Stüvel
21f9fee58f Anim: after deleting bone collection, activate the proper one
Fix an issue where, after deleting the active bone collection, the
incorrect bone collection became the active one.

The solution was to store the active bone collection index before
deletion, instead of after.
2024-01-15 15:58:38 +01:00
Miguel Pozo
c4add0c19a FIx: EEVEE-Next: PlanaProbePipeline gbuffer layout 2024-01-15 15:50:12 +01:00
Hans Goudey
34e39c6b53 Cleanup: Add missing include and forward declaration to DRW header 2024-01-15 08:31:19 -05:00
Hans Goudey
f9fbf832f5 Fix #114244: Smooth operators destroy sharp edge tags
After the replacement of auto smooth with a modifier, sharp edges are
always used, so the "shade smooth", "shade flat", and "smooth by angle"
operators cleared the attribute. However, often users spend significant
time manually tagging edges sharp, and the operators make it too easy to
lose that data.

To keep the old behavior by default, add an option called "Keep Sharp
Edges". Though this can make the operators "ineffective" at their goal
of changing the way the meshes look, or result in redundant data stored
on the mesh, it's a much safer default, especially as users get used to
the new workflow.

Pull Request: https://projects.blender.org/blender/blender/pulls/117069
2024-01-15 14:05:24 +01:00