Commit Graph

8578 Commits

Author SHA1 Message Date
Clément FOUCAULT
a4cd59e369 Overlay-Next: Prepass: Grease Pencil
Allow selection of grease pencil objects.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/127238
2024-09-06 13:29:53 +02:00
Clément FOUCAULT
bd66008344 Overlay-Next: Prepass: Curves, Point Cloud and Particle
Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/127198
2024-09-06 12:40:51 +02:00
Philipp Oeser
e758c4c851 Fix #127208: Crashes using "Clipping Region..."
Typo in 508b39661d resulting in:
Error: Cannot find shader create info named
"overlay_armature_dof_clipped"

So now "overlay_armature_dof_lipped" >> "overlay_armature_dof_clipped"

Pull Request: https://projects.blender.org/blender/blender/pulls/127224
2024-09-06 11:00:35 +02:00
Hans Goudey
07d7404390 Fix: Correct wireframe drawing after recent PBVH storage refactor
Somehow this untested implementation made it in, I thought I had
tested this. The mistake I made was imagining the VBOs were "indexed"
using the node vertex indices, but we use a flat duplicate-per-triangle
vertex VBO format.
2024-09-05 15:42:15 -04:00
Hans Goudey
d33e708343 Refactor: Sculpt: Use function to access PBVH
Part of #118145.
In the future we want to move the ownership of the BVH tree to the
original mesh rather than `SculptSession`, in order to persist it
across some more general non-topology changing operations like
node tools. The first step of that change is replacing all places
that used `SculptSession::pbvh` for access with a function.
2024-09-05 14:16:40 -04:00
Hans Goudey
39e653d479 Cleanup: Sculpt: Add geometry index accessor functions to node structs
Add `.faces()`, `.verts()`,`.all_verts()`, and `.grids()` functions to nodes.
Don't change BMesh data access yet. More complex const correctness
makes that situation more difficult.

Pull Request: https://projects.blender.org/blender/blender/pulls/127201
2024-09-05 20:07:03 +02:00
Hans Goudey
5e63435e74 Sculpt: Store faces instead of triangles in BVH
Currently each sculpt BVH node stores the indices of its triangles.
It also stores triangles of vertex indices local to the node, and also
potentially the indices of the face corners in the node.

The problem with this is that the leaf nodes store plenty of redundant
information. The triangles in each face aren't split up between multiple
nodes, so storing triangle instead of face indices is unnecesssary. For
the local vertex triangles, there is also duplicate information-- twice
the number of indices as necessary for quad meshes. We also often need
a node's faces, which is currently done with a triangle to face map
using 4 bytes per triangle.

This "double storage" results in extra processing too. For example,
during BVH builds we need to combine twice the number of "Bounds"
objects for a quad mesh. And we have to recalculate a node's face
indices every time we want them.

This commit replaces the PBVH triangle indices with face indices, and
replaces the local vertex triangles array by using a `VectorSet` to store
each node's vertex indices. This results in significant performance and
memory usage improvements.

|                   | Before   | After    | Improvement |
| ----------------- | -------- | -------- | ----------- |
| BVH build time    | 1.29 s   | 0.552 s  | 2.3x        |
| Brush stroke time | 3.57 s   | 2.52 s   | 1.4x        |
| Memory usage      | 4.14 GiB | 3.66 GiB | 1.3x        |

All testing is done with a 16 million vertex grid and a Ryzen 7950x.

My guess is that the brush stroke time is improved by the added sorting
of node vertex indices, and by the overall increase in memory bandwidth
availability for mesh data. Personally I'm pleasantly surprised by the
whole improvement, since I usually try to avoid hash table data
structures for this sort of use case. But a lookup into this set ends up
just being a boolean and with an array lookup, so it's quite cheap.

Pull Request: https://projects.blender.org/blender/blender/pulls/127162
2024-09-05 16:21:43 +02:00
Clément FOUCAULT
093192a9d0 Cleanup: DRW: Remove unused variable warning 2024-09-05 12:23:43 +02:00
Campbell Barton
3a1e637e26 Cleanup: spelling in comments 2024-09-05 11:31:47 +10:00
Hans Goudey
b14badf3ea Cleanup: Subdiv: Use Span and float3 for vertex positions 2024-09-04 13:13:43 -04:00
Hans Goudey
d601bf7e3d Sculpt: Restructure PBVH drawing to avoid overhead
This commit rewrites the PBVH drawing using many of the principles from the
ongoing sculpt refactor. First of all, per BVH node overhead is minimized.
Previously the main entry point to the drawing API was per node, so there
was significant overhead fetching global data and maintaining caches on
a per-node basis. Now all of that "global" work happens for the entire
geometry.

We also now avoid creating wireframe index buffers and batches unless
the viewport actually requests wireframe data. This was theoretically
possible before, but the whole logic flow was so convoluted that the
optimization was too difficult. Similarly, multithreading is used more
consistently now. Because of OpenGL, flushing vertex/index buffers to
the GPU has to happen on the main thread, but everything else can be
multithreaded. With outer loops processing all relevant PBVH nodes,
it's now trivial to apply multithreading wherever possible.

Testing performance, overall this commit results in a 10% improvement in
the time between opening a file with a large mesh sculpt and the first
possible interaction. Specifically I measured a change from 8.4 to 7.6
seconds on a completely visible 16 million vertex mesh with a Ryzen 7950x.
I also measured a decrease in memory usage from 4.79 to 4.31 GB.
For multires I observed a similar improvement in memory usage,
though less of a performance improvement.

There are still significant opportunities for future improvement. #122775
would be particularly helpful. #99983 would be helpful too, though more
complicated, and #97665 describes the problems a bit more generally.

Part of #118145.

Pull Request: https://projects.blender.org/blender/blender/pulls/127002
2024-09-04 17:40:50 +02:00
Sebastian Parborg
cfbb6b5627 Fix: Remove unused typedefs from the legacy armature overlay 2024-09-04 16:13:42 +02:00
Clément Foucault
3ab60972b5 Fix: Overlay-Next: Missing select_bind call 2024-09-04 14:35:18 +02:00
Laurynas Duburas
e310e0450f Overlay-Next: add selection mode to relations
Adds selection mode to relations.
Fixes `overlay_extra_wire_vert.glsl` to support `drw_CustomID` and `in_select_buf` for `select_id_set`.

Pull Request: https://projects.blender.org/blender/blender/pulls/127082
2024-09-04 14:29:35 +02:00
Clément Foucault
05deb10405 Fix: Overlay: Intel driver hang caused by shader compilation
Thanks @xavierh for the fix.

Fix #126812
2024-09-04 13:44:42 +02:00
Clément Foucault
508b39661d Overlay-Next: Armature
Functional Changes:
- Custom shapes using empties now supports line width.
- Line width is supported on MacOS.
- Fixed Stick bone drawing on MacOS.

Some shaders are duplicated and ported to the new
primitive expansion API.

The legacy code inside `overlay_armature.cc` have been
guarded behind `NO_LEGACY_OVERLAY` which can
be enabled to make sure no legacy code is used unnoticed.
This allows for spotting more easily code that needs to be
ported. Moreover, it is easier to remove this legacy code
when the time comes.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/126474
2024-09-04 12:56:37 +02:00
Miguel Pozo
d3909d42c6 Fix #125506: GP flicker in Video Sequencer
`gpencil_engine_enabled` is uninitialized at `Film::init` time,
so this replaces the check to rely on the DepsGraph instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/127113
2024-09-04 12:13:40 +02:00
Aras Pranckevicius
174387e4d9 Fix #126908: 3D view background color affects attribute text outline color
The change was accidentally done in #121383 which primarily concerned
itself with overlay text colors, but started to use TH_BACK theme color
for the draw manager text (e.g. for geometry nodes value visualization)
outline color. Change behavior to use black or white outline color, based
on lightness of text color.

Pull Request: https://projects.blender.org/blender/blender/pulls/127071
2024-09-03 22:01:14 +02:00
Julian Eisel
a8c08e4a8c Refactor: Sculpt/Paint: Rename brush "tool" to "brush type"
The term "tool" is historic from before the actual tool system got
introduced. Since then the term was already a bit confusing, because it
wasn't directly related to the tool system, but there was still some
relationship between the two. Now brushes and their types are decoupled
much more from the tool system, with a single "Brush" tool supporting
all kinds of brushes (draw, grab, cloth, smooth, ...).

For a more clear terminology, use "brush type" instead of "tool".

For #126032 we need to write the brush type to the asset metadata (done
in !124618), so we can filter brushes based on the type (so the grease
pencil eraser tool only shows eraser brushes, for example). I'd like to
use future proof names for that to avoid versioning of asset metadata in
future, so I'd rather do the full naming change now.

RNA properties (thus BPY names) are not changed for compatibility
reasons. Can be done in 5.0, see blender/blender#124201.

Pull Request: https://projects.blender.org/blender/blender/pulls/126796
2024-09-03 15:20:34 +02:00
Miguel Pozo
1340aa615a Fix: EEVEE: Crash with >16 AOVs
Null check the result of `get_aov_texture`.
Reported in #127059.
2024-09-03 13:27:06 +02:00
Jeroen Bakker
5b16da6246 EEVEE: Fix insecure string literal
Detected by Sergey.
2024-09-03 11:10:27 +02:00
Campbell Barton
d19c13eb82 Cleanup: spelling & punctuation in comments 2024-09-03 12:59:37 +10:00
Miguel Pozo
7a55bdeaf9 EEVEE: Enable translation of screen messages
Add `Instance::info_append` so it's easier to log correctly formatted
info, and `Instance::info_append_i18n` to support string localization.

Co-authored-by: Damien Picard
Co-authored-by: Bastien Montagne <mont29@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/124257
2024-09-02 20:13:31 +02:00
Clément Foucault
7d95fed911 Overlay-Next: In-Front support
This adds the missing in-front passes submission
and reorder the passes for better performance.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/127020
2024-09-02 19:14:01 +02:00
Clément Foucault
94608b32ab Overlay-Next: Fix crash in 2D image view 2024-09-02 16:36:23 +02:00
Clément Foucault
1c2918f50f DRW: Fix crash when entering UV editor 2024-09-02 16:17:21 +02:00
Jeroen Bakker
835e626a28 Workbench: Fill unused texture slots
Workbench doesn't fill all texture slots. In OpenGL it should match what
the shader is using, where some texture slots that have been defined can
be optimized away when not used. The Vulkan backend however uses all the
resources that has been defined in the shader create info.

When using a texture shader in workbench the shader would raise a
validation warning as there are slots defined that are never uploaded.
This PR fixes this by always set dummy textures in those slots.

Pull Request: https://projects.blender.org/blender/blender/pulls/127064
2024-09-02 11:12:47 +02:00
Clément FOUCAULT
895e315f2e Overlay-Next: Add Alt+B clipping support
Add back clipping using the same GL clip planes as before.

The difference is that the clip planes are now stored in the
`GlobalsUboStorage` instead of relying on another separate
UBO.

One annoyance of the current design is that the `overlay::Instance`
has to be created with the clipping state. This could be fixed later
by making the shader module a pointer instead of a reference.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/127018
2024-09-02 10:54:10 +02:00
Campbell Barton
ff3949426c Cleanup: spelling in comments 2024-09-02 16:55:19 +10:00
Laurynas Duburas
ce28af7352 Overlay-Next: Image
Overlay-Next version of image.

Rel #102179

Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/126243
2024-08-30 18:11:14 +02:00
Clément Foucault
cfb261928c Overlay-Next: Fluid
Straight-forward port.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/126878
2024-08-30 17:48:52 +02:00
Clément Foucault
e22b931cfb Overlay-Next: Xray Fade
Straight-forward port.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/126967
2024-08-30 17:33:28 +02:00
Clément FOUCAULT
870d664e31 Overlay-Next: Edit Curves
Straightforward Port

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/126892
2024-08-30 16:03:44 +02:00
Campbell Barton
d497452a73 Cleanup: typo, spaces in comments, comment blocks & use double quotes 2024-08-29 17:16:44 +10:00
YimingWu
17397dae19 Fix #125680: Grease Pencil edit overlay shader theme switch
Grease Pencil v3 was using the same shader as particle strands, this leads
to sharing edit overlay color as particle strands. This patch fixes this
behaviour by adding a grease pencil toggle in the shader so grease pencil
overlay will use appropriate color and point sizes specified in the theme.

Pull Request: https://projects.blender.org/blender/blender/pulls/125689
2024-08-28 09:10:05 +02:00
Jeroen Bakker
8e80cfdfd9 EEVEE: Enable Shader Specialization Spatial Denoise
Spatial denoise uses shader specialization. The current shader had
this disabled for OpenGL and Vulkan. As OpenGL and Vulkan supports
shader specialization it is fine to enable them. Would result in
better optimized shaders.

I checked other shaders as well. This was the only one ignoring shader
specialization.

Pull Request: https://projects.blender.org/blender/blender/pulls/126830
2024-08-27 15:30:26 +02:00
Jeroen Bakker
dc8f5d5b89 Fix #125333: EEVEE: Trigger render step between rendering of samples
EEVEE doesn't trigger a render step between samples which leads to not recycling
memory on Metal backend leading to slower animation rendering and even out of
memory.

This PR uses the same approach as for workbench to solve the issue.

NOTE: Fix needs to be backported to 4.2
Pull Request: https://projects.blender.org/blender/blender/pulls/126781
2024-08-26 12:53:42 +02:00
Hans Goudey
1376c78e46 Cleanup: Further explicit retrieval of data in PBVH draw 2024-08-23 11:17:17 -04:00
Hans Goudey
5ece086678 Cleanup: Separate PBVH VBO format creation to functions 2024-08-23 11:17:16 -04:00
Clément Foucault
e5ba4cc7b0 Fix: Overlay: Missing backface culling in facing overlay
Same fix as for legacy overlay.

Fix #126351
2024-08-23 17:10:42 +02:00
Clément Foucault
0bad30317c Fix: Overlay: Missing backface culling in facing overlay
It was a side effect of enabling the depth write.

The fix is to enable the backface culling when it can
be honored.

However, this only works in solid mode.

Candidate for backporting to 4.2

Fix #126351
2024-08-23 17:10:42 +02:00
Clément Foucault
0d4c76c986 Fix: EEVEE: Material without Closure flag skip rendering
If a deferred layer doesn't contain any material with
a non-null closure flag, the deferred layer is skipped.

However, material with null closure flag exists and
still need to render opaque.

Fix this case by modifying the closure bits for the
deferred and probe pipelines.

Candidate for backporting to 4.2

Fix #126459
2024-08-23 16:45:01 +02:00
Hans Goudey
205d95107e Cleanup: Miscellaneous changes in draw_pbvh.cc
Reorganization to make the retrieval of data from the arguments struct
more explicit, combined with a bit of renaming. Mostly to make a future
diff visually simpler.
2024-08-23 10:18:38 -04:00
Clément Foucault
65efde82c3 EEVEE: Update shadow finalize test 2024-08-23 16:11:28 +02:00
Jeroen Bakker
6607d66274 Fix: EEVEE crash when baking light probes
Due to recent changes EEVEE crashes when baking light probes.
Film checks if the viewport compositor is enabled via
DST. In the baking thread this is not initialized and can crash
or lead to incorrect results.

Fixed by first checking if we are updating the viewport.

Pull Request: https://projects.blender.org/blender/blender/pulls/126685
2024-08-23 14:20:42 +02:00
Campbell Barton
b76fcc3a1f Cleanup: add missing headers to CMake's file listing 2024-08-23 10:19:53 +10:00
Campbell Barton
07b11206eb Cleanup: sort cmake file lists 2024-08-23 10:19:53 +10:00
Hans Goudey
6e845f54c3 Fix #126464: Subdiv optimal display edges causes broken wires on Metal
Caused by d1049f6082.
The old 255 FORCE_HIDE value converts to 1.0f as a float, not 255.0f.
2024-08-22 09:48:44 -04:00
Omar Emara
997ab86906 Compositor: Add Composite node for new CPU compositor
This patch implements the Composite node for the new CPU compositor.
This is essentially equivalent to the Viewer node commit.
2024-08-22 14:48:52 +03:00
Jeroen Bakker
7391810b53 Fix #126556: EEVEE: Metadata not available when only use material layer
When only rendering the cryptomatte material layer, the meta data wasn't
exported. Note this issue is due to differences not reproducable in 4.3.
But the fix should also be applied there for consistency.

Pull Request: https://projects.blender.org/blender/blender/pulls/126631
2024-08-22 11:31:34 +02:00