Commit Graph

7198 Commits

Author SHA1 Message Date
Hans Goudey
fba7671205 Cleanup: Const correctness, unused variable warning in GP draw code 2023-10-19 15:03:32 +02:00
Hans Goudey
5db502a122 Fix: Build error after bounding box refactor
This function was changed in main after the buildbot built the PR.
Since we are just interested in grease pencil data here, just retrieve
the bounds from the geometry directly.
2023-10-19 15:02:15 +02:00
Hans Goudey
1cbd0f5a85 Refactor: Improve access to object data bounds
Currently object bounds (`object.runtime.bb`) are lazily initialized
when accessed. This access happens from arbitrary threads, and
is unprotected by a mutex. This can cause access to stale data at
best, and crashes at worst. Eager calculation is meant to keep this
working, but it's fragile.

Since e8f4010611, geometry bounds are cached in the geometry
itself, which makes this object-level cache redundant. So, it's clearer
to build the  `BoundBox` from those cached bounds and return it by
value, without interacting with the object's cached bounding box.

The code change is is mostly a move from `const BoundBox *` to
`std::optional<BoundBox>`. This is only one step of a larger change
described in #96968. Followup steps would include switching to
a simpler and smaller `Bounds` type, removing redundant object-
level access, and eventually removing `object.runtime.bb`.

Access of bounds from the object for mesh, curves, and point cloud
objects should now be thread-safe. Other object types still lazily
initialize the object `BoundBox` cache since they don't have
a data-level cache.

Pull Request: https://projects.blender.org/blender/blender/pulls/113465
2023-10-19 14:18:40 +02:00
Hans Goudey
40080f618c Sculpt: Use C++ Set to store PBVH Node BMesh elements
Mainly to simplify code and also add some add type safety, replace
`GSet` with `blender::Set` for the storage of BMesh triangles and
vertices on each PBVH node. Some initial tests point to better
performance too, but the numbers are hard to verify so far.

Because of the larger `PBVHNode`, memory usage slightly increases
(observed a 2% increase with a 1M face grid) for regular Mesh sculpting,
but it seems `Set` is more memory efficient than `GSet`, because I also
observed a 10% decrease in memory usage for dynamic topology.
In the future nodes can be split in a more data-oriented fashion to
reduce memory usage overall.

This also makes it simpler to switch to another type in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/113907
2023-10-19 14:18:15 +02:00
Falk David
6281d9a039 Fix: GPv3 depth buffer
Resolves #113422.

The depth buffer was rendered to, but not correctly merged
with the scene depth buffer. This lead to, e.g. the object appearing
behind the grid.

This fixes the issue by rendering a "merge" pass.

Pull Request: https://projects.blender.org/blender/blender/pulls/113779
2023-10-19 13:22:38 +02:00
Campbell Barton
e7e4e63313 Cleanup: spelling in comments, white-space in comments 2023-10-19 18:53:16 +11:00
Jeroen Bakker
62f721467b Merge branch 'blender-v4.0-release' 2023-10-19 08:03:51 +02:00
Jason Fielder
62219f8da9 Metal: Re-enable workbench NEXT shadows
With the shift to GPU-driven rendering pipeline,
the SSBO vertex fetch paradigm used to
implement workbench shadows on Metal
instead of utilising the geometry shader
path no longer worked correctly.

This is because the draw submission
required vertex amplification up-front,
based on the expected output geometry
amount for a given input geometry.

This patch aims to resolve this
issue through addition of API to
enable the features within the
GPU driven pipeline.

Co-authored-by: Michael Parkin-White <mparkinwhite@apple.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/113498
2023-10-19 08:01:17 +02:00
Miguel Pozo
fc1ee65104 EEVEE-Next: Skip bake if there's not enough VRAM
* Skip the bake if there's not enough GPU memory to allocate all the
   required resources.
* Print bake messages to the command line.

Pull Request: https://projects.blender.org/blender/blender/pulls/113509
2023-10-18 18:49:21 +02:00
Campbell Barton
6ed3b4a5a6 Cleanup: format, quiet unused argument warning 2023-10-18 22:09:27 +11:00
Hans Goudey
e1fd7a8a7b Cleanup: Simplify grease pencil line overlay size counting
Avoid the need to iterate over every curve, and only iterate over the
cyclic attribute if it exists. This removes the check that avoided
creating cyclic segments for curves with only two points. If that
was necessary, some of the complexity would return, but the
new `array_utils` function wouldn't be necessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/113814
2023-10-17 18:29:17 +02:00
Falk David
07749b389d GPv3: Convert radius to blender units
Previously, Grease Pencil used a radius convention where
1 "px" = 0.001 units. This "px" was the brush size which would be
stored in the stroke thickness and then scaled by the point pressure
factor. Finally, the render engine would divide this thickness value by
2000 (we're going from a thickness to a radius, hence the factor of
two) to convert back into blender units.

Store the radius now directly in blender units. This makes it
consistent with how hair curves handle the radius.

* Removes the scaling in the render engine.
* Makes sure the grease pencil primitives use the correct radii
* Changes the drawing tool to work with screen space radius
* Draws the drawing tool cursor in screen space
* Makes sure the scaling is done when converting from legacy
grease pencil objects
* Makes sure the scaling is done when loading previous files

Consequences for the draw tool:
* Since the tool has a radius input in pixels, it now works in screen space. This is a pretty big change to how it works by default before, so a new option will have to be added that allows the brush to be in "Scene" space. This is similar to how it works in sculpt mode. But this is a bigger change, so I would like to split that into a separate PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/113770
2023-10-17 17:00:35 +02:00
Miguel Pozo
6f125661e6 GPU: Add Texture::debug_clear
Clear uninitialized textures to NaN/debug values.
Enabled for `--debug-gpu` only.

Pull Request: https://projects.blender.org/blender/blender/pulls/113781
2023-10-17 15:54:09 +02:00
Miguel Pozo
25c2b17266 Merge branch 'blender-v4.0-release' 2023-10-17 15:46:32 +02:00
Miguel Pozo
405a618d88 Cleanup: Workbench: Remove no longer used properties 2023-10-17 15:45:59 +02:00
Hans Goudey
57c27b47b9 Cleanup: Avoid unnecessary check for empty curves
In `CurvesGeometry`, curves should never be empty. We shouldn't have
to check for that in the drawing code.
2023-10-16 19:51:12 +02:00
Hans Goudey
2528b6da9b Cleanup: Use const in grease pencil drawing code 2023-10-16 19:51:12 +02:00
Clément Foucault
5831913204 Fix EEVEE-Next: SubSurfaceScattering: Invalid buffer format
This fixes issues on NVidia GPUs.
2023-10-16 17:17:18 +02:00
Clément Foucault
69e85382cd Fix #113759: EEVEE-Next: NaN artifacts caused by raytracing denoising
This was caused by spatial denoising pass sampling invalid data.
This patch make it so that there is one padding tile all
around the denoise area.

This simplifies the denoise shader too.

This is a bit wasteful to dispatch tracing tiles for clearing
and a better solution would be to use a separate shader and
tile list only for this purpose.
2023-10-16 17:17:18 +02:00
Falk David
97c5cb19d1 GPv3: Hide points overlay in stroke selection mode
This makes sure that we only show the point selection if the
selection domain is `ATTR_DOMAIN_POINT`.
2023-10-16 15:12:10 +02:00
casey bianco-davis
0508e81b79 GPv3: Add edit mode lines to overlay
Adds lines in edit mode to the overlay.

Pull Request: https://projects.blender.org/blender/blender/pulls/111596
2023-10-16 13:59:26 +02:00
Miguel Pozo
54511f59aa Merge branch 'blender-v4.0-release' 2023-10-16 13:49:44 +02:00
Miguel Pozo
e3014ffc27 Fix #113741: Workbench: Reset TAA on overlay toggle
Reset TAA when enabling overlays,
since we won't have valid sample0 depth textures.
2023-10-16 13:49:12 +02:00
Miguel Pozo
465291e716 Merge branch 'blender-v4.0-release' 2023-10-16 13:25:05 +02:00
Miguel Pozo
f2ba12a053 Fix: Workbench: Volume compositing
Regression after fe39456ba5
2023-10-16 13:24:35 +02:00
Clément Foucault
ba89723abc Cleanup: EEVEE-Next: Volume AABB
Make interface a bit more lined up with the
rest of the BLI API. Also use more of the
vector API.
2023-10-15 15:07:44 +02:00
Campbell Barton
2e0b844b36 Cleanup: spelling in comments 2023-10-14 13:53:00 +11:00
Clément Foucault
3a998fc461 Fix EEVEE-Next: Linking error cause by closure_to_rgba 2023-10-13 19:25:11 +02:00
Clément Foucault
71835808d3 Fix EEVEE-Next: Inverted world coordinates
Caused by 71dfcf4558
2023-10-13 19:21:08 +02:00
Miguel Pozo
6484274048 Merge branch 'blender-v4.0-release' 2023-10-13 19:19:06 +02:00
Miguel Pozo
9e7a576cee Workbench: Fix: depth_in_front not being copied after the first sample 2023-10-13 19:18:46 +02:00
Clément Foucault
8f49407128 Fix EEVEE-Next: Broken Ambient Occlusion
Caused by 71dfcf4558
2023-10-13 19:07:05 +02:00
Clément Foucault
5b1d5fa82f Cleanup: EEVEE-Next: Remove some TODOs
These just move some code around, cleanup the
syntax and make sure to use appropriate libs.
2023-10-13 18:33:15 +02:00
Clément Foucault
ef494b2794 Fix EEVEE-Next: Broken Barycentric on Metal 2023-10-13 18:01:29 +02:00
Clément Foucault
71dfcf4558 EEVEE-Next: Remove common lib usage
Replaces all usage by the the gpu_shader_math
equivalent. This is because the old shader
library was quite tangled.

This avoids dependency hell trying to
mix libraries.

Changes are split into isolated commits until
I had to do mass changes because of inter-
dependencies.

Pull Request: https://projects.blender.org/blender/blender/pulls/113631
2023-10-13 17:59:46 +02:00
Harley Acheson
f7a8536112 Merge branch 'blender-v4.0-release' 2023-10-13 08:36:19 -07:00
Miguel Pozo
42aa97a080 Fix #113580: Workbench: Always setup in_front_depth_tx
Always setup in-front depth, since Overlays can be updated without causing a Workbench re-sync.
2023-10-13 17:12:40 +02:00
Clément Foucault
51f37be0cd EEVEE-Next: Make renderpass lib mandatory for nodetree evaluation
This is to avoid broken materials if they include a AOV node.
This doesn't mean that it adds render passes resources to
every shader.
2023-10-13 16:23:07 +02:00
Jeroen Bakker
a0ef7a7910 Vulkan: Image Editor Drawing
When drawing the image editor the depth of the geometry is set to -1.
This will be clipped in Vulkan, but is valid in OpenGL. This PR patches
the shader to be inside the range that both Vulkan and OpenGL support.

This ensures that images are visible in the image editor.

Pull Request: https://projects.blender.org/blender/blender/pulls/113668
2023-10-13 12:54:23 +02:00
Jeroen Bakker
26adfcdb57 Revert "Metal: Re-enable workbench NEXT shadows"
This reverts commit 95f01288b0.
It fails on non-apple platforms.
2023-10-13 11:05:02 +02:00
Jason Fielder
95f01288b0 Metal: Re-enable workbench NEXT shadows
With the shift to GPU-driven rendering pipeline,
the SSBO vertex fetch paradigm used to
implement workbench shadows on Metal
instead of utilising the geometry shader
path no longer worked correctly.

This is because the draw submission
required vertex amplification up-front,
based on the expected output geometry
amount for a given input geometry.

This WIP patch aims to resolve this
issue through addition of API to
enable the features within the
GPU driven pipeline.

Co-authored-by: Michael Parkin-White <mparkinwhite@apple.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/113498
2023-10-13 11:02:06 +02:00
Jeroen Bakker
28c4abe57c EEVEE: Fix Fallback Shader Shadow Page Tile Store
`eevee_shadow_page_tile_store` shader uses `VIEWPORT_INDEX` and `LAYER`.
Both use an optional extension in OpenGL and Vulkan. When the extension
isn't available a geometry shader is injected to emulate the
extension. The generated geometry shader requires `instance_name` to be
set. This wasn't the case for `eevee_shadow_page_tile_store` shader.

This PR also adds a detection for incompatible shader infos.
- Shaders that use `VIEWPORT_INDEX` or `LAYER` cannot have a geometry stage.
  This check is done in debug and release builds.
- Shaders that use a fallback shader should have instance names set in
  the stage interfaces. This check is only done in debug builds.

Pull Request: https://projects.blender.org/blender/blender/pulls/113649
2023-10-13 10:42:25 +02:00
Campbell Barton
e86fbcd4f0 Merge branch 'blender-v4.0-release' 2023-10-13 10:31:44 +11:00
Campbell Barton
fb58aa5900 Cleanup: typos, duplicate words 2023-10-13 10:21:06 +11:00
Falk David
49b21eba11 GPv3: Support crazyspace in selection code
This adds `GreasePencilEditHints` and correctly implements
`crazyspace::get_evaluated_grease_pencil_drawing_deformation`
to support querying the deformation of points after evaluation.
This is needed for users to properly select points in edit mode while
seeing the effects of the modifiers.

Pull Request: https://projects.blender.org/blender/blender/pulls/113586
2023-10-12 15:42:04 +02:00
Omar Emara
405ec79a0a Fix #112883: GPU compositor crops viewed image
The GPU compositor crops the viewed images to the render resolution.
While the original size and content of the input to the viewer should be
retained as is.

This patch fixes that by specializing compositors that can use composite
outputs to be able to view images of any arbitrary size. This is still
missing the translation offset of the viewer, but this shall be tackled
separately.
2023-10-12 14:03:12 +03:00
Clément Foucault
c8e0a9765e EEVEE-Next: Sphere Probe: Allow evaluation of volume probe
This avoid too dark surfaces if there is no light
in the scene. This prevent energy loss.
2023-10-12 12:50:56 +02:00
Clément Foucault
de2ea031bc Fix EEVE-Next: Broken Parallax
Parallax distance was not actually use.
It was affecting the world and had
unwanted effect if lower than
influence radius.
2023-10-12 12:41:15 +02:00
Clément Foucault
1f12b90ef2 Cleanup: EEVEE-Next: Use references for bind_resources 2023-10-12 12:19:41 +02:00
Clément Foucault
1b4b6bc2f4 Fix EEVEE-Next: Forward Pipeline: Missing resource binds 2023-10-12 12:15:15 +02:00