Commit Graph

7954 Commits

Author SHA1 Message Date
Hans Goudey
76a151b9d6 Refactor: Store PBVH in unique_ptr
This requires adding a destructor and deleting move and copy assignment
for SculptSession, because (for now at least) we want to keep the PBVH
as an opaque type (though with one exception for including pbvh_intern.hh
in paint.cc for the SculptSession destructor).

Pull Request: https://projects.blender.org/blender/blender/pulls/121227
2024-04-29 22:21:24 +02:00
Hans Goudey
7c56e16e44 Cleanup: Use references for sculpt PBVH variables 2024-04-29 22:21:23 +02:00
Clément Foucault
760a641023 EEVEE-Next: Remove slope and quantization biases
This avoid self intersection during tracing which expect
unbiased depth. We compensate by adding a 1.5 shadow pixel
offset in the normal direction which is enough to fix
most remaining self shadowing. But another bias parameter
will likely need to be added anyway.

Fixes #121194
2024-04-29 17:05:07 +02:00
Clément Foucault
387df16755 Fix: EEVEE-Next: Missing factor for PCF radius size
Oversight inside #121167
2024-04-29 17:05:07 +02:00
Clément Foucault
e401d996aa Fix: EEVEE-Next: Wrong LOD tagging for punctual shadow maps
The root issue is that `shadow_punctual_footprint_ratio` was not
fed with Z distance but by radial distances to camera and
light.

This commit cleans up this computation by only precomputing the
film pixel radius on CPU. This allow the LOD computation to be
more local and easier to read.

Fix #119725

Pull Request: https://projects.blender.org/blender/blender/pulls/121167
2024-04-29 15:19:49 +02:00
Clément Foucault
bb44bce95c EEVEE-Next: Improve shadow bias
The goal of this PR is to remove any user facing parameter
bias that fixes issues that are caused by inherent nature of
the shadow map (aliasing or discretization).

Compute shadow bias in the normal direction to avoid
both shadow leaking at certain angles or shadow
acnee.

This bias is computed automatically based on the minimum
bias amount required to remove all errors. The render
setting is removed as of no use for now.

#### Normal bias
We do the bias in world space instead of shadow space
for speed and simplicity. This requires us to bias using
the upper bound of biases for the same location in space
(using biggest texel world radius instead of UVZ bias).
This isn't much of an issue since the bias is still less
than 2 texel. The bias is still modulated by facing
ratio to the light so surfaces facing the light have no
biase.

This fixes both self shadowing and flat occluders aliasing
artifacts at the cost of moving the shadow a bit on the
side. This is the blue arrow in the diagram.

We always bias toward the normal direction instead of the
light direction. This is alike Cycles geometric offset for
the shadow terminator fix. This is better since it does'nt
modify the shading at all.

#### Slope bias
To avoid aliasing issue on zero slope receiver, we still
have to use the slope bias with a size of 1 pixel.

#### PCF filtering
We now parametrize the filter around the normal instead of
using the shadow map local space. This requires to use
a disk filter instead of box, which is also more pleasant
for most light shapes (all except rectangle lights).

Setting the filter around normal avoid overshadowing from
zero slope occluders. This cannot be fixed by more slope bias
in light space PCF. We could fix it in light space by projecting
onto the normal plane but that gives an unbounded bias when `N.L`
is near 0 which causes either missing shadows or self shadow if
using an arbitrary max offset value.

To avoid overshadowing from any surface behind the shading
point, we reflect the offset to always face the light.
Doing so instead of using the perpendicular direction
is better for very sharp geometric angles, has less
numerical precision issue, is symetrical and is cheaper.

To avoid any self shadowing artifact on zero slope receivers
with angled neighbors (like a wall and the floor), we have
to increase the slope bias according to the filter size.
This might be overkill in most situation but I don't feel
this should become a setting and should be kept in sync
with the filter. If it has to become an option, it should
simply a factor between unbiased filter and best bias.

#### Shadow terminator

The remaining artifacts are all related to shadow terminator
one way or another. It is always caused by the shading
normal we use for biasing and visibility computation not
being aligned with the geometric normal.

This is still something we need a setting for somewhere.

Pull Request: https://projects.blender.org/blender/blender/pulls/121088
2024-04-27 14:30:52 +02:00
Campbell Barton
c0def6c93d Cleanup: spelling in comments 2024-04-27 11:58:02 +10:00
Clément Foucault
d11c6962b0 EEVEE-Next: Fix decrepancy in shadow rendering on mac M1
The difference was that the depth slope bias was not
written to the depth buffer which could lead to situation
where the value written to the color target was greater
than it should.

Use the depth write feature to output the slope biased
depth. Output 1 depth to not discard and loose the benefit
of early depth test.
2024-04-26 23:19:57 +02:00
Clément Foucault
4d10bbe733 Fix: EEVEE-Next: Missing smoke volumes
Caused by mistake in b8e17cf531.
2024-04-26 13:13:27 +02:00
Clément Foucault
1f2b935146 EEVEE-Next: Display volumes in render mode if drawtype is not solid
This is for consistency with cycles behavior. This doesn't
change the behavior for final render.
2024-04-26 13:12:34 +02:00
Clément Foucault
bc1c35e201 EEVEE-Next: Change lights object matrix for more readability and compactness
This adds a new `Transform` type similar to cycles that reduces
the amount of data passed for a typical affine 3D transform.

This then applies this type to the light data and cleanup
all usage of the former `object_mat`. This also changes the axes
macros into utility accessor functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/121089
2024-04-26 12:54:08 +02:00
Falk David
c2504eb779 Cleanup: Use legacy radius conversion factor constant
This moves the seemingly arbitrary value of  "1 / 2000"
into a constant variable
(`bke::greasepencil::LEGACY_RADIUS_CONVERSION_FACTOR`)
so that it can be used in all the places where
legacy "thickness" values need to be converted.
This also expands the explanation of the factor a bit, so it's
clearer why it is needed.
2024-04-26 12:48:26 +02:00
Clément Foucault
9a530906cf Fix: EEVEE-Next: Metal shader compilation
Caused by implicit cast to float vector.
2024-04-25 17:33:23 +02:00
Clément Foucault
b49333a7a0 Fix: EEVEE-Next: Fix spherical harmonic clamping
The previous implementation was not considering each
channel magnitude, which was not rotationally
invariant. This fixes changes in lighting as the world
rotates (and if clamping is enabled).
2024-04-25 16:45:59 +02:00
Clément Foucault
5938ab099d Fix: EEVEE-Next: Correct octahedral texel solid angle
This fixes the slightly incorrect solid angle by using
the symetries of the mapping. This avoids orientation
dependent lighting. The computation is not much more
expensive.
2024-04-25 16:45:59 +02:00
Brecht Van Lommel
2a65681dea Fix #121069: Crash loading EEVEE byte lightcache after recent refactor 2024-04-25 16:15:41 +02:00
Falk David
fe0e2907b3 GPv3: Remove OB_MODE_PAINT_GREASE_PENCIL flag
This reverts part of 36cda3b3116acba3b895daf68689f8af01b62392
and replaces the use of `OB_MODE_PAINT_GREASE_PENCIL`
`OB_MODE_PAINT_GPENCIL_LEGACY` flag instead.
The `OB_MODE_PAINT_GREASE_PENCIL` is removed.

The `GREASE_PENCIL_OT_draw_mode_toggle` operator is removed
and the `GPENCIL_OT_paintmode_toggle`  operator is adapted to
work with GPv3.

Pull Request: https://projects.blender.org/blender/blender/pulls/121027
2024-04-25 14:23:46 +02:00
Clément Foucault
2a0074c930 Fix: EEVEE-Next: Compile error on Nvidia drivers
Fixes #121057
2024-04-25 08:00:14 +02:00
Clément Foucault
1b04a0d494 Fix: EEVEE-Next: Self shadow issue caused by depth buffer precision
This add a small bias to the shading point position. This avoid
most of the self shadowing artifacts caused by depth buffer
precision. If near/far distances are set to reasonable value
this should not create any shading differences.

Fix #119124
2024-04-24 22:59:13 +02:00
Clément Foucault
fcb19fc4ec Cleanup: EEVEE-Next: Use define for volume probe atlas format 2024-04-24 20:20:35 +02:00
Clément Foucault
211b726f48 Fix: EEVEE-Next: Wrong sphere probe normalization with no volume prove
This was caused by 2 issues:
- The probe selection was running before the volume set_view
  copying undefined data.
- Missing half voxel offset which was making L1 data incorrectly
  blended with other coefficients.
2024-04-24 20:20:35 +02:00
Brecht Van Lommel
badec4fc39 Fix: Assert reading light cache texture after recent changes 2024-04-24 18:34:59 +02:00
Clément Foucault
e725cc3494 Fix: EEVEE-Next: Shadow: Casters behind area lights cast shadow
This introduces fragment clipping for the shadow pipeline.

The fragments are culled using a sphere distance test
for sphere lights, which is then re-purposed as a simple
distance test for area lights.

However, in the case of area lights, this introduces some
light bleeding. To mitigate this, we bring the shadow origin
back towards the light center so that this artifact only
appears if using larger shadow tracing.

Fixes #119334

Pull Request: https://projects.blender.org/blender/blender/pulls/120992
2024-04-24 17:08:12 +02:00
Clément Foucault
b8e17cf531 Fix: EEVEE-Next: Missing fluid volume domain rendering
This was an oversight in the implementation of the new
volume drw API. Now fill up dummy attributes and allow
rendering of the fluid domains.
2024-04-24 17:06:55 +02:00
Clément Foucault
41036348bc Fix: EEVEE-Next: Missing resource bind for volume lighting 2024-04-24 17:06:55 +02:00
Brecht Van Lommel
15b9ae5436 Refactor: Use typed functions for blend file data reading
This makes the read and write API functions match more closely, and adds
asserts to check that the data size is as expected.

There are still a few places remaining that use BLO_read_data_address
and similar generic functions, these should eventually be replaced as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/120994
2024-04-24 17:01:22 +02:00
Clément Foucault
a2becaead3 Fix: EEVEE-Next: Missing resource bind for opaque tagging
Introduced by #120965
2024-04-24 16:25:16 +02:00
Hans Goudey
9193f4554c Cleanup: Move more PBVH API functions to C++ namespace 2024-04-24 07:54:22 -04:00
Clément Foucault
2056b4b563 Fix: EEVEE-Next: Broken uniform attribute in blended materials
Was caused by difference in header order for forward materials.
Fix by adding the missing include in the nodetree lib directly.

Fix #117277
2024-04-24 11:31:39 +02:00
Clément Foucault
6d347dd5ca Fix: EEVEE-Next: Point cloud macro coliding with voronoi texture
Was caused by macro declaration. Remove the macro
and add another `#if` case for EEVEE-next instead.

Fix #115438
2024-04-24 09:38:32 +02:00
Campbell Barton
1865776767 Cleanup: doxygen syntax, use colons after "param" arguments, not "note" 2024-04-24 10:55:44 +10:00
Campbell Barton
019d3ef939 Cleanup: spelling in comments 2024-04-24 10:48:45 +10:00
Clément Foucault
5611cafe5e Fix: EEVEE-Next: Different shading in forward pipeline
This was due to using a different normal than the deferred
pipeline for light facing attenuation.

Use the same heuristic as the deferred pipeline for
consistency and smoother look.

Fix #119750
2024-04-23 22:30:05 +02:00
Clément Foucault
3e9796c7c3 EEVEE-Next: Light-Probe: Make volume probe display relative
This avoid overlap of data spheres when density changes.
2024-04-23 21:47:31 +02:00
Clément Foucault
0023d850e3 EEVEE-Next: Light-Probe: Make sphere probe display reflective
This was the previous behavior in legacy EEVEE.
2024-04-23 21:32:22 +02:00
Clément Foucault
3799920dc1 EEVEE-Next: Light-Probe: Make sphere probe display size relative
The display is now relative to the size of the probe. This avoid
display being too small or too big after re-sizing.
2024-04-23 21:32:22 +02:00
Clément Foucault
dc20def2f9 Fix: EEVEE-Next: Lightprobe: Avoid division by zero
The normalization factor can divide by zero. Add a small
bias to avoid this. Since the bias is the same on both
the numerator and the denominator, the result converges
to 1 as the denominator reaches zero.

This also adds a `saturate` to avoid lighting being
weirdly increase in some part of the volume probe.

Fix #119799
2024-04-23 20:27:28 +02:00
Sietse Brouwer
7b3e063704 GPv3: Overlay for Weight Paint mode
This PR implements the viewport overlay for Weight Paint mode in GPv3.

In Weight Paint mode the stroke points are colored depending on their
weights in the active vertex group.

Pull Request: https://projects.blender.org/blender/blender/pulls/118273
2024-04-23 18:23:38 +02:00
Falk David
0a4a6ebadc GPv3: Use GPv2 object mode flag for weight painting
This mostly reverts bd22059752
and makes sure to use `OB_MODE_WEIGHT_GPENCIL_LEGACY` instead
of `OB_MODE_WEIGHT_PAINT`.

Pull Request: https://projects.blender.org/blender/blender/pulls/120983
2024-04-23 15:48:27 +02:00
Jeroen Bakker
ee46030a5a Fix #114000: EEVEE-Next: Fade/Facing overlays
The fade and facing overlays use a depth equal test. EEVEE next uses
multiple samples to construct the depth and the depth can be different
than the death-center pixel depth.

This PR uses depth-less tests, but in case of the facing overlays it
can produce some artifacts at sharp edges where the normals bleeds.

Other solution would be to render the depth center depth buffer when
one of these overlays are turned on, but that adds overhead as that
will most likely be redrawn for each draw loop.

Pull Request: https://projects.blender.org/blender/blender/pulls/120976
2024-04-23 14:45:42 +02:00
Clément Foucault
5b065b4b9d Fix: EEVEE-Next: Missing shadows in reflection probes
This was caused by the tagging pass not using the right
depth texture format.

This commit changes the opaque tagging pass to use the HiZ
buffer instead so that the shader is not relying on the
depth buffer anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/120965
2024-04-23 12:21:04 +02:00
Campbell Barton
802a45902a Fix flag value overlap EFFECT_POST_BUFFER/EFFECT_NORMAL_BUFFER
These enums used the same value.

---

This looks like an oversight, if it's intentional that both flags share a value it should be noted in code-comments.

Pull Request: https://projects.blender.org/blender/blender/pulls/120961
2024-04-23 09:55:55 +02:00
Clément Foucault
5644a0c621 Fix: EEVEE-Next: Sphere probe disregard the custom parallax checkbox
Fixes #120782
2024-04-22 23:33:08 +02:00
Clément Foucault
8d740b6ea3 Cleanup: DRW: Remove unused legacy function 2024-04-22 23:23:04 +02:00
Clément Foucault
2babe2d678 Fix: EEVEE-Next: Volume objects gets incorrectly culled
Infinite projection matrices do not work with the
current culling pipeline. Since it is expected to have
relatively few volume objects per scene, disabling the
culling for now as fixing it is more involved.

Also only meshes producing fragments will actually
be computed.

Fixes #115595
2024-04-22 23:23:03 +02:00
Clément Foucault
f86135dc6e Fix: EEVEE-Next: GBUffer: Wrong normal layer load
This was because the normal layer code was assuming no missing
closure inside the GBuffer. Now use bin indexing and
fix `gbuffer_read_bin` and `gbuffer_pack`.

Also add test cases for this.

Fixes #120756

Pull Request: https://projects.blender.org/blender/blender/pulls/120779
2024-04-22 21:36:40 +02:00
Hans Goudey
cb639d5d1d Cleanup: Rename "is_mode_active" to "edit_mode_active"
"is_mode_active" doesn't really make sense because some mode
is always active technically. This always referred to edit mode anyway.
2024-04-22 15:31:55 -04:00
Clément Foucault
d44ee7bf11 EEVEE-Next: Make light clamping consistent
This adds clamping at the light combine stage for both direct
and indirect light.

This allows for clamping direct and indirect light separately.
While direct light clamping might not be very desirable in
EEVEE, it might be wanted to reduce the flickering from distant
shiny bumpy surfaces, or for artistic reason.

This happens after applying the BSDF throughput just like cycles.
This is done in order to minimize the performance impact and
allows to split the clamp for direct light and indirect light.

The indirect light clamp value is still used in the ray-tracing
pipeline to clamp the ray intensity. But this differs from cycles
as we clamp the ray without the BSDF throughput here. Sphere probe
have the same issues. Some more energy loss is expected compared
to the direct light clamp.

Note that we still clamp the indirect light after applying BSDF
in case the BSDF is scaling the energy up above the threshold.

This also corrects the clamping for volume that now clamps after
applying the scattering term.

Also adds clamping to volume indirect lighting.

Since we use light probe volumes for both surface and volume
indirect lighting, we need to clamp them at sampling time.

Pull Request: https://projects.blender.org/blender/blender/pulls/120866
2024-04-22 21:19:00 +02:00
Clément Foucault
5f1faec6ff Fix: EEVEE-Next: Tangent normal map node affected by object scale
Use the same approach as Legacy EEVEE and normalize the
normal before interpolation.
Fix #120455
2024-04-22 16:38:13 +02:00
Clément Foucault
3182ce2393 DRW: Add asserts for nullptr binding
These will crash at submission time anyway and will
be hard to track back to the actual resource causing
the issue. Better fail earlier.
2024-04-22 15:26:48 +02:00