Commit Graph

7418 Commits

Author SHA1 Message Date
Hans Goudey
b3aca5b28f Cleanup: Simplify PBVH build process slightly
Before this happened as two steps: first allocating the PBVH with a type,
then calculating the BVH and filling it with data. This just confused things,
so change to allocating the struct when building it. Also move the functions
to the C++ namespace, and fix some cases of requiring the PBVH to be set
when it wasn't yet.
2023-12-14 18:20:46 -05:00
Hans Goudey
262572a6a0 Cleanup: Move PBVH update functions to C++ namespace 2023-12-14 14:56:25 -05:00
Campbell Barton
944e0483a6 Cleanup: clarify naming for MLoopTri
The term `looptri` was used ambiguously for both single & arrays.
The term `tri` was also used, causing `tri->tri`.

Use terms:

- `looptris` for an array or when dealing with multiple items.
- `looptri` is used when dealing with a single item.
- `lt` for a single MLoopTri variables & arguments.

This was already a convention but not followed closely.
2023-12-14 12:32:11 +11:00
Campbell Barton
a4af406b81 Clenaup: spelling in comments 2023-12-14 11:14:50 +11:00
Hans Goudey
cdb2f1e1ba Fix #116140: GPU subdivision ignores completely smooth shading
Extraction of data is done in a different order for GPU subdivision
drawing. The necessary normals domain of the mesh has to be
retrieved before that.
2023-12-13 18:59:28 -05:00
Miguel Pozo
7e4c2b2649 Fix: EEVEE-Next: DeferredProbelLayer emissive materials 2023-12-13 17:02:05 +01:00
Hans Goudey
30d95966d5 Cleanup: Forward declare some classes in mesh headers
Aiming to reduce cases of including headers in headers,
when the final definition might be unnecessary.
2023-12-13 09:18:39 -05:00
Hans Goudey
b52a071e7a Cleanup: Remove unnecessary Mesh C-API functions
Like mentioned in the docstrings, use the C++ API or access methods
in C++ code.
2023-12-13 08:40:21 -05:00
Omar Emara
356480fabb Realtime Compositor: Add static cached images
The Realtime compositor currently relies on the GPU cache in image IDs.
That cache only supports single layer images, so multi-layer images will
be acquired without a cache, introducing significant IO bottlenecks for
the GPU compositor.

This patch ignores the image GPU cache and stores the images in the
static cache manager of the compositor. Draw data was introduced to the
image ID for proper cache invalidation, like other IDs such as masks.

The downside is that the cache will no longer be shared between EEVEE
and the compositor. But realistically, images are not typically shared
between materials and compositors.

This is just a temporary solution until we have proper GPU storage
support for image buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/115511
2023-12-13 09:50:42 +01:00
Clément Foucault
4aff321af5 Fix: EEVEE-Next: Broken surfel lighting
This was caused by #113257 which removed the
simple ltc evaluation usage. This in turn
caused a precision issue for the cases where
V == N and surfel lighting was one of them.

Adding a special case fixes the issue.
2023-12-13 04:06:37 +01:00
Clément Foucault
7f8763d823 Fix: EEVEE-Next: OpenGL errors in probe capture
Was caused by missing / incorrect bindings.
Reuse the same gbuffer setup for all deferred
layer to avoid this problem later on.
2023-12-13 02:47:40 +01:00
Clément Foucault
ac11ccd2bd EEVEE-Next: Add Translucent BSDF support
This adds support for Translucent BSDF.

This also fixes a bug to allow correct
shadowing.

The input normal had to be set back to
non-inverted in the node function to allow
for correct interpretation of the Normal
by Screen Space Reflections.

This add the necessary optimization
and code deduplication to hybrid deferred
and forward pipeline.

Pull Request: https://projects.blender.org/blender/blender/pulls/116070
2023-12-13 02:19:19 +01:00
Hans Goudey
768cd9b763 Cleanup: Remove inline functions and extra includes from draw extraction 2023-12-12 20:08:30 -05:00
Hans Goudey
79ade784b8 Cleanup: Move draw_manager_text.h to C++ 2023-12-12 19:49:26 -05:00
Clément Foucault
c1130ee782 Cleanup: EEVEE-Next: Avoid use of float math when needed 2023-12-13 01:17:00 +01:00
Clément Foucault
c4d91ad328 Fix: EEVEE-Next: Numerical imprecision with emission only volumes
This was caused by the fix to #65771 which biased the extinction.
The fix uses an exact method by taking the limit of the ill defined
computation and replacing the result by the simplified formula.
2023-12-13 01:17:00 +01:00
Hans Goudey
c53e220aef Cleanup: Use C++ attribute API instead of CustomData API
This gives better asserts in debug builds through use of Span, more
safety when name convention attributes happen to have different types
or domains, and simpler code in some cases. But the main reasoning is to
avoid relying on the specifics of CustomData more to allow us to replace
it in the future.
2023-12-12 18:23:59 -05:00
Miguel Pozo
224658266f EEVEE-Next: Add Light Path node support
Fix #113922.

Pull Request: https://projects.blender.org/blender/blender/pulls/116107
2023-12-12 21:27:18 +01:00
Miguel Pozo
b86d656df4 Fix #114284: EEVEE-Next: Light cutoff with small radius 2023-12-12 21:26:24 +01:00
Hans Goudey
5875349390 Fix: Mesh draw normals extraction ignores sharp_edge with no sharp_face
See c4446d7924

When the "fully flat" state comes from "sharp_edge" and "sharp_face"
doesn't exist, we need to check for that for every face when extracting
normals. Eventually these loops should be unrolled so we don't have a
function call per face. That would remove the cost of this check.
2023-12-12 12:46:27 -05:00
Jeroen Bakker
c11004579e GPU: Remove the Word OpenGL from Build Scripts
The build scripts are still referring to gpu tests as being opengl.
Although they can also use Metal or Vulkan. This PR only replaces
the work `opengl` with `gpu` for build options.

Special note is that the windows argument `with_opengl_tests` is
also replaced with `with_gpu_tests` for consistency.

Pull Request: https://projects.blender.org/blender/blender/pulls/116030
2023-12-12 16:02:29 +01:00
Campbell Barton
77204bed17 Cleanup: spelling in comments 2023-12-12 12:58:56 +11:00
Jason Fielder
9313750f0a Metal: Add fallback path for texture atomics V2
This patch adds an alternative path for devices/OSs
which do not support native texture atomics in Metal.
Support is encapsulated within the backend, ensuring
any allocated texture with the USAGE_ATOMIC flag is
allocated with a backing buffer, upon which atomic
operations happen.

The shader generation is also changed for the atomic
case, which instructs the backend to insert additional
buffer bind-points for the buffer resource. As Metal
also only supports buffer-backed textures for
textureBuffers or 2D textures, TextureArrays and
3D textures are emulated within a 2D texture, with
sample locations being indirected.

All usage of atomic textures MUST now utilise the
correct atomic texture types in the high level shader
and GPUShaderCreateInfo declarations.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/115956
2023-12-11 23:00:20 +01:00
Clément Foucault
cf4558d576 Fix: EEVEE-Next: Opaque dielectric packing broken 2023-12-11 22:50:42 +01:00
Hans Goudey
d8497e48e1 Cleanup: Use is_empty() instead of size() == 0 2023-12-11 15:47:11 -05:00
Clément Foucault
fe2a7f4b8d EEVEE-Next: Support ShaderToRGBA on Dithered materials
This adds a new hybrid mode where the light and lightprobe
textures are bound to the gbuffer pass and used by
shaders that use ShaderToRGBA.

The counterpart is that these shaders have less texture
slots available but still two more than the Blended
materials.

These materials will correctly write to the AOVs and
render passes.

This is not too invasive in terms of implementation. The
only quirk was that we needed another fragment shader to
simplify the dependencies on the resources. But if we ever
get pre-processor support in our include / require system
this could be cleaned up.
2023-12-11 20:32:58 +01:00
Clément Foucault
8ab23ea17d Fix: EEVEE-Next: Missing indirect light in ShaderToRGBA
Silly mistake. The lighting was not added to the right
variable.
2023-12-11 20:32:58 +01:00
Miguel Pozo
73a5826bf5 Fix: EEVEE-Next: Film matrix
Fixes motion vectors for static geometry.
Regression from beee7db.
2023-12-11 20:23:04 +01:00
Clément Foucault
3313e9976a Fix: EEVEE-Next: Broken Shadow usage tagging
Broken after recent changes.

Caused by 85f9758302
2023-12-11 19:20:27 +01:00
Hans Goudey
eefe19a7de Fix #115994: Crashes with edit mode tools using custom data correction
Caused by 15cff1fddb reversing source and result arguments.
2023-12-11 13:11:02 -05:00
Clément Foucault
4c14557424 Fix: EEVEE-Next: Undefined behavior with only diffuse material
Diffuse materials still needs the feedback buffer for correct
horizon scan.
2023-12-11 18:24:40 +01:00
Clément Foucault
5fa44c0ff8 Fix: EEVEE-Next: Broken HiZ for planar probe
This was caused by missing resources.
2023-12-11 18:09:06 +01:00
Clément Foucault
3df81b0b86 Fix: EEVEE-Next: Planar Probe rendering broken
Was caused by several small mistakes.
2023-12-11 18:08:20 +01:00
Clément Foucault
85f9758302 Fix: EEVEE-Next: Crash when using Planar Probe
This was caused by missing cryptomatte and
depth buffer input for shadow tagging.
2023-12-11 17:27:10 +01:00
Clément Foucault
a32b4ecd83 EEVEE-Next: Make Hi-Z buffer swap on set_source
This fixes a case where the source was set but the
internal pointers for binding were not updated.

This also tag for update internally.

Cleanup and remove the redundant tagging.

This also use the planar depth buffer as layer view.
2023-12-11 17:27:10 +01:00
Miguel Pozo
b484018d42 Fix: EEVEE-Next: ObjectKey
memset is not guaranteed to clear padding bytes,
which breaks the use of memcmp for comparison.
2023-12-11 17:26:04 +01:00
Clément Foucault
bac94fe307 EEVEE-Next: Make AO node respect the normal input 2023-12-11 14:50:58 +01:00
Clément Foucault
4ed9b4fed0 EEVEE-Next: More work into supporting horizon scan in AO node
This is only part of making inverted scan work.
There are still issues with background not being
considered outside objects.
2023-12-11 14:50:57 +01:00
Clément Foucault
809365d24a Cleanup: EEVEE-Next: Add pipeline defines 2023-12-11 14:50:57 +01:00
Falk David
aa40e9b3c1 Cleanup: GPv3: render engine 2023-12-11 14:23:57 +01:00
Hans Goudey
8157f33911 Cleanup: Move opensubdiv C-API headers to C++
All the relevant code is C++ now, so we don't need to complicate things
with the trip through C anymore. We will still need some wrappers, since
opensubdiv is an optional dependency though. The goal is to make it
simpler to remove the unnecessary/costly abstraction levels between
Blender mesh data and the opensubdiv code.
2023-12-11 07:50:29 -05:00
Hans Goudey
4eee57fc3b Fix #115979: Object bounds display type doubled size
The "size" of a bounding box that used to be calculated by
`BKE_boundbox_calc_size_aabb` was actually the dimensions
divided by two.
2023-12-10 15:52:29 -05:00
Clément Foucault
ae70d25959 EEVEE-Next: Refactor Raytracing pipeline
This de-duplicate some passes in the raytracing
pipeline and make it more ready for adoption
of arbitrary closure evaluation. This last part
means the removal of some per closure type
options.

The put in common the tile classification step
that is now done only once for all 3 closure
type. Also add some speedup to the tile
compaction phase that is now only twice
faster.

The horizon-scan setup was also de-duplicated
and run only if needed, which can save up to
0.5ms is complex scenes.

However, this moves the max-roughness and and
resolution scaling to a common parameter.
This is to be able to support arbitrary closure
evaluation where multiple closure with conflicting
parameters could be evaluated in one tracing pass.

Pull Request: https://projects.blender.org/blender/blender/pulls/116009
2023-12-10 21:38:23 +01:00
Clément Foucault
91fd6b18f3 Fix #115288: EEVEE-Next: Horizon Scan light leaking
This was caused by the normal test being wrong and
not taken into account at all.
2023-12-10 21:36:06 +01:00
Campbell Barton
21525b4ea6 License headers: add SPDX headers 2023-12-10 16:35:15 +11:00
Hans Goudey
e0d95b95cc Fix: Build error and format fixes after previous cleanup 2023-12-08 17:19:46 -05:00
Hans Goudey
854cdd1180 Cleanup: Use consistent "mesh" variable name (replace "me")
"mesh" reads much better than "me" since "me" is a different word.
There's no reason to avoid using two more characters here. Replacing
all of these at once is better than encountering it repeatedly and
doing the same change bit by bit.
2023-12-08 16:40:06 -05:00
Jeroen Bakker
65e58fe574 CMake: Fix Compiling Shader Builder on macOS
Due to changes in the build environment shader_builder wasn't able to
compile on macOs. This patch reverts several recent changes to CMake files.

* dbb2844ed9
* 94817f64b9
* 1b6cd937ff

The idea is that in the near future shader_builder will run on the buildbot as
part of any regular build to ensure that changes to the CMake doesn't break
shader_builder and we only detect it after a few days.

Pull Request: https://projects.blender.org/blender/blender/pulls/115929
2023-12-08 15:47:14 +01:00
Campbell Barton
55c5692364 Cleanup: remove unused variable, invalid comment & typo 2023-12-08 23:03:22 +11:00
Falk David
8efff3b2d7 GPv3: Render to Image
This PR refactors parts of the gpv3 engine and implements the `render_to_image` engine callback.

Pull Request: https://projects.blender.org/blender/blender/pulls/115904
2023-12-08 12:51:15 +01:00