Commit Graph

101693 Commits

Author SHA1 Message Date
Miguel Pozo
567a2e5a6f EEVEE Next: Overscan support
Add overscan support for both viewport and final renders.

Pull Request: https://projects.blender.org/blender/blender/pulls/110313
2023-08-03 16:19:08 +02:00
Hans Goudey
eabff37483 Mesh: Add API functions to assign vertex normals
A few places already calculated vertex normals with better contextual
information to improve performance. To allow changing the storage of
vertex normals more (mostly for improved caching), change some code
from "get normals, set values, clear dirty flag" to "make vertex
normals data, give to mesh". This makes the API less awkward too,
since previously the "get for write" and "clear dirty" calls always
had to be separated.

Pull Request: https://projects.blender.org/blender/blender/pulls/110754
2023-08-03 16:13:04 +02:00
Clément Foucault
8e33b20de9 EEVEE-Next: Irradiance Bake: Add validity based dilation
Implement invalid sample points filling. Improves invalid regions
but introduce light leak.

Grid sample points are considered invalid if they have a ratio of
front-face ray hit under the given threshold. This is a post-processing
pass on the baked lighting that fills dark regions produced by
invalid sample location (e.g.: inside walls) with valid neighbor
samples data.

Two new parameters are added:

- Dilation Threshold: Validity threshold under which grid samples are
considered invalid. Invalid samples will gather valid lighting data
from valid neighbors inside the dilation radius.
- Dilation Radius: Radius of the dilation process. Expressed in grid
sample distance.

The validity of each point is progressively refined just like the
lighting data during the baking process.

The dilation process is implemented as a post-processing pass during
the loading of the grid data into the irradiance atlas. This allows
live tweaking the dilation parameters.

Pull Request: https://projects.blender.org/blender/blender/pulls/110386
2023-08-03 15:48:33 +02:00
Clément Foucault
17db856686 EEVEE-Next: Ray-tracing Denoise Pipeline
This is a full rewrite of the raytracing denoise pipeline. It uses the
same principle as before but now uses compute shaders for every stages
and a tile base approach. More aggressive filtering is needed since we
are moving towards having no prefiltered screen radiance buffer. Thus
we introduce a temporal denoise and a bilateral denoise stage to the
denoising. These are optionnal and can be disabled.

Note that this patch does not include any tracing part and only samples
the reflection probes. It is focused on denoising only. Tracing will
come in another PR.

The motivation for this is that having hardware raytracing support
means we can't prefilter the radiance in screen space so we have to
have better denoising. Also this means we can have better surface
appearance with support for other BxDF model than GGX. Also GGX support
is improved.

Technically, the new denoising fixes some implementation mistake the
old pipeline did. It separates all 3 stages (spatial, temporal,
bilateral) and use random sampling for all stages hoping to create
a noisy enough (but still stable) output so that the TAA soaks the
remaining noise. However that's not always the case. Depending on the
nature of the scene, the input can be very high frequency and might
create lots of flickering. That why another solution needs to be found
for the higher roughness material as denoising them becomes expensive
and low quality.

Pull Request: https://projects.blender.org/blender/blender/pulls/110117
2023-08-03 15:32:06 +02:00
Alexander Gavrilov
36c6bcca1a Python API: expose the math mapping vertex positions to B-Bone segments.
Recently a user expressed interest in exporting baked animation
with B-Bone segments. Currently the python API already exposes
segment matrices via a PoseBone method, but there is no access
to the mapping of vertices to the segments.

Although currently the math is simple and easy to re-implement,
forcing Python add-ons to do that would cause a maintenance issue
if the mapping is ever changed later (it's quite dumb, ignoring
the rest pose curve, and there definitely is room for improvement).

This patch extracts the relevant math into a BKE function, and
exposes it in the python API as a new PoseBone method.

Pull Request: https://projects.blender.org/blender/blender/pulls/105419
2023-08-03 14:44:39 +02:00
Christoph Lendenfeld
0d7b0045c6 Animation: Graph Editor curve drawing performance improvement
In current blender, when drawing curves in the Graph Editor,
it always iterates over the whole curve.
From first to last vertex no matter what is shown on screen.
Instead of that, find the bounding keyframes and iterate within them.

Additionally to that, break apart the logic into two sections
* first iterate over keyframes and add `float2` into a `Vector`
* then iterate over all those points and draw them

The second optimization is to make the Bezier resolution
dependent on the keyframe distance in screenspace.
Previously it just went off the distance between keys in frames,
but that doesn't make sense if you are zoomed out.

## Performance Numbers
The following performance numbers are the
average time **per curve** on a mocap file of 6000f (each frame has a key).
The numbers were generated **without** showing keyframes to only focus
on the performance of this patch.
Also they are from a debug build, so they just make sense relative to each other

| - | before | after |
| - | - | - |
| zoomed in | ~1000μs | ~77μs |
| zoomed out | ~1000μs | ~430μs |

This only affects the actual curves.
Keyframe and handle drawing can likely still be improved

Pull Request: https://projects.blender.org/blender/blender/pulls/110301
2023-08-03 14:43:21 +02:00
Clément Foucault
ba444218ac Cleanup: Editors: Remove unused code 2023-08-03 14:23:46 +02:00
Guillermo
5b3398a673 Fix #110161: Crash on dragging a Speaker NLA strip
`NLASTRIP_TYPE_TRANSITION` was being used incorrectly as a flag, having
`NLASTRIP_TYPE_TRANSITION=1` and `NLASTRIP_TYPE_SOUND=3` in the enum
`eNlaStrip_Type`, when evaluating `NLASTRIP_TYPE_SOUND &
NLASTRIP_TYPE_TRANSITION` gives a invalid truish value.

Also `strips` that can't be placed were freed, but no removed from the
`strips list`, this will cause a error if the `strip` is at begin
or end of the list.

Pull Request: https://projects.blender.org/blender/blender/pulls/110605
2023-08-03 14:19:49 +02:00
Christoph Lendenfeld
c4631644ee Fix #108961: Wrong Label and Tooltip for Timeline
The property label on the Timeline for showing only channels
from selected objects was wrong,
indicating it shows only keyframes from selected channels.

This fixes it by using the same label and description as the dope sheet uses.

Pull Request: https://projects.blender.org/blender/blender/pulls/110569
2023-08-03 14:16:08 +02:00
Jacques Lucke
9b54e7cc7f Fix: free nullptr in grease pencil 2023-08-03 13:22:41 +02:00
Jacques Lucke
359f8d0559 Fix compiler error in stubs because some headers are now C++
All the stubs used to be extern "C", now a few of them are not anymore.
E.g. `paint_is_face_hidden`.
2023-08-03 13:16:36 +02:00
Clément Foucault
d8a860b605 Cleanup: Editors: Remove unused ED_screen_preview_render
This was introduced before workspaces were a thing.
It isn't used anymore and is easy to bring back if needed.
2023-08-03 12:52:43 +02:00
Miguel Pozo
9db289924f EEVEE Next: Motion Blur fixes
Fix motion blur for viewport re-projection and final image renders.

Pull Request: https://projects.blender.org/blender/blender/pulls/110114
2023-08-03 12:48:12 +02:00
Campbell Barton
0af370a62d Cleanup: use C++ style sizeof(struct::member) instead of casting nullptr 2023-08-03 20:23:01 +10:00
Campbell Barton
bbf073c4ed Cleanup: use POINTER_FROM_INT for PyGetSetDef definitions
This makes it clear '(void *)0' represents a zero index instead of
a value that's typically nullptr when ignored.
2023-08-03 20:04:04 +10:00
Falk David
13e9f553b9 Cleanup: GPv3: Use references in editor functions
Instead of using pointers for these functions, they should be using
references (in most cases) and let the caller make sure that the
layer actually exists.
2023-08-03 11:51:59 +02:00
Amelie Fondevilla
655b2b6c2c GPv3: Delete grease pencil frames
Implementation of the delete frame operator for grease pencil channels.
Changes in the GreasePencil::remove_frame_at function so that it returns a boolean.

Pull Request: https://projects.blender.org/blender/blender/pulls/110746
2023-08-03 11:49:14 +02:00
Jason Fielder
ee96947abc Fix #110372: Curve edit handles fixed in Metal backend
There were two separate issues occurring here:

With some other recent changes to curve handles, an early exit was
added when the handles should not display, however, this early exit
was not discarding geometry in the Metal implentation, but leaving
values undefined. Resulting in random geometry flickering on screen.
This may not previously have happened in certain modes if the vertex
buffers were zero-initialised up-front (which only happens with certain
debug flags).

Curve handle geometry generation would render incorrectly when
outputting triangleStrips IF the transparent border was disabled.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/110719
2023-08-03 11:34:52 +02:00
Jason Fielder
0f39e46914 DRW: Support optimal prim type for indirect curves in Metal
Adds support for generating curve primtiives avoiding the
use of primtiive restarts. This maixmises geometry performance
when using Metal.

Also ensure that the existing index buffer optimization path is
skipped for indirect draw calls where counts are not known at
submission time.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/109972
2023-08-03 11:19:48 +02:00
Campbell Barton
de391cf811 Cleanup: use nullptr instead of zero 2023-08-03 19:17:43 +10:00
Campbell Barton
c6f3f19648 Cleanup: reduce variable scope when removing in a while loop 2023-08-03 19:17:43 +10:00
Jason Fielder
049f0798a3 Fix #110293: Metal: Resolve tile corruption in Cycles render preview
PixelBuffer required addition of buffer re-allocation during mapping
to avoid host updates over-writing previous in-flight data as required
by the GPU. Changes allow multiple copies of existing pixel data to
be in-flight simultaneously.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/110305
2023-08-03 11:17:04 +02:00
Falk David
110ea98ea2 GPv3: Fix missing tag in frames map
In `Layer::remove_frame` there is a case where the frame is not removed,
but overridden by a null-frame. In this case, the frames map was not
tagged, when it should have been.
2023-08-03 11:13:44 +02:00
Falk David
270a229728 Fix: GPv3: Crash on undo when changing frames map
Changing the frames map would lead to a crash later in undo.
This was because the `frames_storage` was not written to file corectly.

When the `frames_storage` was tagged dirty, it recreated the
`frames_storage.num` as well as the `keys` and `values` pointers.
The `keys` and `values` pointers were written after the update, but
since the `num` is just an `int` in the embeded struct, it was written
before being updated. This lead to an out-of-sync state and later
to the crash.

The fix makes sure we write the struct *after* updating it.
2023-08-03 11:13:44 +02:00
Pratik Borhade
1cf4bc2719 Fix #110694: Edit bones draw as they were in pose mode
During the refactor 4aef0204ac, assignment of overlay color for edit
mode was removed from get_bone_wire_color.

Pull Request: https://projects.blender.org/blender/blender/pulls/110715
2023-08-03 11:03:39 +02:00
Hans Goudey
a049f3b5df Cleanup: Use references for mesh extraction render data and cache 2023-08-02 23:59:31 -04:00
Hans Goudey
55970fa367 Cleanup: Simplify mesh triangle material counting
Use `parallel_for` instead of the C threading API, extract some
constant checks from hot loops, and use `EnumerableThreadSpecific`
for thread-local storage.

Pull Request: https://projects.blender.org/blender/blender/pulls/105940
2023-08-03 05:02:36 +02:00
Hans Goudey
9cad2e8771 Fix #110682: Loading old files crashes from missing DNA rename
Missing in 5e9ea9243b
2023-08-02 22:26:10 -04:00
Campbell Barton
19e698cc39 Cleanup: use C++ includes, various non-functional changes for C++ 2023-08-03 09:44:28 +10:00
Campbell Barton
8c8ff6b85b Cleanup: spelling in comments, use C-style comments 2023-08-03 09:44:28 +10:00
Hans Goudey
8bb8cfb54e Cleanup: Remove unnecessary struct keyword from C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/110734
2023-08-03 01:11:28 +02:00
Hans Goudey
731d296f35 Cleanup: Move mesh related blenkernel headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110730
2023-08-02 22:14:18 +02:00
Germano Cavalcante
72d7e3e684 Fix Compiler Error in Clang
```
error: type 'float' cannot be narrowed to 'int' in initializer list [-Wc++11-narrowing]
```
2023-08-02 16:26:34 -03:00
Julian Eisel
8662575f40 UI: Avoid slight text color flashing while clicking preview tiles
Text of preview-tile widgets would change color while pressing the mouse
button on them, this wasn't useful and just made the UI feel glitchy.
The widget background already indicates the state well.

Preview-tile widgets are currently only used in the asset view template.
More usages will be introduced in the asset-shelf patch (#104831).
2023-08-02 21:09:06 +02:00
Germano Cavalcante
c59ba19c0b Fix #110722: Wrong value when starting a transformation
Caused by 5ed14e9269.

That commit accidentally removed the `copy_v2_v2_int(t->mval, mval);`
line which was responsible for initializing the value of `mval`.
2023-08-02 15:51:55 -03:00
Germano Cavalcante
f1d44dd64a Transform: Refactor: Use float vector type for 'TransInfo::mval'
In most cases float access is required for this member.
2023-08-02 15:35:09 -03:00
Germano Cavalcante
e423fd469d Cleanup: Move int to float conversions outside the function
The function doesn't actually use the `int` value, so the parameter
already comes as `float`, this avoids unnecessary conversions.
2023-08-02 15:25:22 -03:00
Germano Cavalcante
897f6523ab Cleanup: Remove unnecessary parameter in 'transform_fn' callback
That `const int[2]` parameter is `t->mval` accessed in a different way
and many times it is not even used.

tmp
2023-08-02 15:04:12 -03:00
Bastien Montagne
4f673f18af Move BKE_lib_override.h header to be fully C++.
This implies using the `.hh` extension, and removing the `extern "C"`
blocks from it.

Pull Request: https://projects.blender.org/blender/blender/pulls/110718
2023-08-02 17:44:37 +02:00
Falk David
873453005d Fix: GPv3 not rendering when origin is out of view
This was because the `ob->runtime.geometry_set_eval` was populated
with the new `GreasePencilComponent` but
`GeometrySet::compute_boundbox_without_instances()` did not compute
the bounding box of the grease pencil geometry.
Thus the bounding box was not correctly set and the object not
correctly rendered.
2023-08-02 17:36:38 +02:00
Ray Molenkamp
d43ceb1974 Fix: bpy build on windows
functions imported from creator.cc still had extern the "C"
attribute causing a linker error due it it looking for the
undecorated symbol for these functions.
2023-08-02 08:08:36 -06:00
Falk David
331969159e Fix: Unreported memory leak
Whenever `grow_array` in
`blender/source/blender/blenkernel/intern/grease_pencil.cc` was called,
it would not free the original array after relocating the data to the
newly allocated memory. This fixes the memory leak.
2023-08-02 15:52:21 +02:00
Jacques Lucke
8f4fccaa33 Creator: move to C++
Also see #103343.

Co-authored-by: Hans Goudey <h.goudey@me.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/110539
2023-08-02 15:34:45 +02:00
Ray Molenkamp
7983dce79b Fix: bpy build on windows
functions imported from creator.c were missing the extern "C"
attribute causing a linker error due it it looking for the
decorated symbol for these functions.
2023-08-02 07:25:30 -06:00
Pratik Borhade
56832ed59a GPv3: Basic layer channel selection
PR adds support for the selection of grease pencil layers in
animation editor.
- selection status is stored in `GreasePencilLayerTreeNode`
- Existing `GP_LAYER_TREE_NODE_SELECT` flag is used for selection
- selection of channel updates the active layer in object properties

Part of #110056

Pull Request: https://projects.blender.org/blender/blender/pulls/110133
2023-08-02 15:17:08 +02:00
Amelie Fondevilla
fd75695bed GPv3: Insert grease pencil keyframe from the dopesheet
Adaptation of the operator `ACTION_OT_keyframe_insert` to take into account grease pencil channels.
Grease pencil keyframes can now be inserted in blank mode, or in additive mode (duplicate the current frame in the new keyframe).

Two API functions were added :
 * `add_duplicate_drawings` which copies the data of a drawing to creates a duplicate, and
 * `insert_duplicate_frame` which creates a duplicate frame of an existing one either by copy or instance.

The additive mode option is also added to the UI.

The Layer method `frame_key_at` previously private was set to public.

Pull Request: https://projects.blender.org/blender/blender/pulls/110649
2023-08-02 14:56:18 +02:00
Hans Goudey
4309c32be6 Mesh: Replace older flip faces utilities
Replace `BKE_mesh_face_flip_ex()` with `bke::mesh_flip_faces()`.
This gives better performance since it avoids custom data name
lookups for every face index, and processes data in a more cache
friendly way. Also remove the `CustomData_swap` API function
as mentioned in 09b6eac5c4.

Flipping 16 million faces, I observed a 3.25x speedup, from 760 to 230 ms.

Pull Request: https://projects.blender.org/blender/blender/pulls/110702
2023-08-02 14:15:27 +02:00
Falk David
b2f61b5c8a GPv3: Replace int with FramesMapKey
This adds the `FramesMapKey` alias to the `blender::bke::greasepencil` namespace.

Pull Request: https://projects.blender.org/blender/blender/pulls/110714
2023-08-02 14:02:23 +02:00
Campbell Barton
7cc3ef3260 Cleanup: use C++ includes, various non-functional changes for C++ 2023-08-02 20:30:02 +10:00
Sergey Sharybin
b655571f70 Render: Make GPU compositor a BaseRender method
The C-style API is still in place, but the implementation
is moved to a virtual method.

This is part of unification of viewport and final render
structure.

Should be no functional changes.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/110696
2023-08-02 10:30:25 +02:00