Commit Graph

7984 Commits

Author SHA1 Message Date
Clément Foucault
286cbc8317 Fix: EEVEVE-Next: Wrong material reused for transmission material
This is caused by #121137 as the bug disappear if
`can_use_default_cb` returns false.


The issue is caused by the material binning system.
`ShaderKey` uses the `GPUMaterial` to differentiate between
material. But with #121137, different materials can reuse the
same `GPUMaterial`.

The fix is to not reuse the shader for the prepass (even if opaque)
for transmission enabled shaders.

Fix #121343
2024-05-07 17:34:36 +02:00
Clément Foucault
d9915b86a6 EEVEE-Next: Remove shadow softness factor parameter
This parameter was introduced to mitigate shadow tracing
artifacts. These are no longer present since #121317 and
leaving this parameter breaks PBR rules which opens other
issues with shadow disconnected from shading.
2024-05-07 15:49:49 +02:00
Jeroen Bakker
32e6042230 EEVEE-Next: Fix division by zero when copying motion vectors
Due to recent changes geometry without any vertices could lead to
a division by zero when copying motion vectors.

This PR fixes this by skipping the copy step when there are no
vertices to copy.

Pull Request: https://projects.blender.org/blender/blender/pulls/121516
2024-05-07 15:43:51 +02:00
Clément Foucault
d6aa790301 Cleanup: EEVEE-Next: Remove warnings 2024-05-07 15:07:41 +02:00
Clément Foucault
87d164c56b EEVEE-Next: Improve shadow tracing
The goal of this PR is to remove the per face, NDC space
tracing for shadow maps.

This requires custom occluder extrapolation but in return
removes quite a lot of complexity in other areas, namely:
- No more per face transform before the tracing
- No more per face jittering (fix #119565)
- No more frustum padding (increased maximum precision)
- Better use of 32bit precision shadow map
- Fix #121343

This improve softness at relatively low step count (default 6
is better) and reduces light leaking at very low sample
count (sharper). It makes it more intuitive now that
higher sample count is smoother.

Pull Request: https://projects.blender.org/blender/blender/pulls/121317
2024-05-07 14:52:47 +02:00
Clément Foucault
d97e22f2cd Fix: EEVEE-Next: Missing world diffuse lighting
Caused by c99e7519c4

Missed the initial `local_radiance` value.
2024-05-07 12:53:28 +02:00
Iliya Katueshenock
4e3af58885 Cleanup: Avoid unnecessary copies of VArray
Cleanup to avoid unnecessary copies of VArray. This
requires ref-qualifier overloads of dereference operator
of attribute reader and some move operators and constructor
overloads in the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/118437
2024-05-07 04:02:17 +02:00
Jeroen Bakker
c99e7519c4 Fix #120919: EEVEE-Next: Intel UHD support for probe remapping.
Windows/Intel UHD 600 iGPUs crash when compiling probe remapping shader.
The cause is that there is a balanced barrier inside a forloop. When removing
the barrier the compilation works. This is a driver bug and most likely not
being solved as the driver maintenance mode will only be updated for critical
fixes.

This PR works around the issue making the loop condition less complex.

Pull Request: https://projects.blender.org/blender/blender/pulls/121105
2024-05-06 17:02:46 +02:00
Jeroen Bakker
9d07f6d5a0 EEVEE-Next: Fix motion blur large geom on iGPU HD520 devices
Detected when testing mr_elephant on an Intel HD520. When copying
the velocity buffer using the copy shader, the number of scheduled
workgroups could be larger than supported by the device.

This PR fixes this by copying multiple vertices per thread when
the work size cannot cover all the pixels.

Pull Request: https://projects.blender.org/blender/blender/pulls/120915
2024-05-06 17:02:23 +02:00
Jeroen Bakker
62b871d572 Fix #121467: EEVEE-Next: Write varying interfaces in world shader
Intel drivers on Windows platform require all varying interface data
to be written to in the previous stage.

It was detected that the world shader didn't do that as the interface
contains data used for regular objects.

There are several ways how this could be solved:
- Change nodes to use a different path for world materials.
- Include of the draw_model_lib/common_view_lib
- set the failing interface directly.

I chose to set the failing interface directly but I am fine to include
any missing library.

Pull Request: https://projects.blender.org/blender/blender/pulls/121477
2024-05-06 14:58:39 +02:00
Lukas Tönne
fe6c1f4659 Fix #121353: GPv3: Reset shading group pointers for polling in overlays
Grease Pencil overlay drawing code uses the existence of shading groups
to determine which parts of the overlay need to be drawn. If the tool
settings change the shading groups need to be set to null, otherwise
the drawing code will still draw points in curve selection mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/121472
2024-05-06 13:25:34 +02:00
Campbell Barton
98f319ce02 Cleanup: spelling in comments 2024-05-04 15:24:46 +10:00
Campbell Barton
9918488bb1 Cleanup: use uppercase tags, following own style guide 2024-05-03 11:33:21 +10:00
Campbell Barton
5529a94f14 Cleanup: spelling in comments 2024-05-03 11:33:18 +10:00
Falk David
370712fc1b Fix #121354: GPv3: object mode selection outline too big
This was caused by c2504eb779.
The commit changed the factor for the radii, but didn't update the
overlay code for the outlines.

This fix makes sure we're using the right conversion factor.
2024-05-02 16:32:06 +02:00
Campbell Barton
f6b7464b4c Cleanup: spelling in comments 2024-05-02 16:44:10 +10:00
Miguel Pozo
67d292c0e9 Fix: EEVEE-Next: Never tag default materials as GPU_MAT_USE_DEFAULT
Fix issue from a8f8745dcb
2024-05-01 18:03:36 +02:00
Clément Foucault
ab30784076 EEVEE-Next: Implement spherical harmonic deringing
This avoids negative color darkening caused by strong
directionnal lighting.

However, this reduce the contrast a lot since the
deringing is done on the unclampped spherical harmonics
which is itself extracted from unclamped values from
the world.

The solution to this is to add the parameter for
clamping the world light. This setting will be
reused for #68478.

Fix #116036

Pull Request: https://projects.blender.org/blender/blender/pulls/121303
2024-05-01 16:18:51 +02:00
Clément Foucault
826d2ed4ec EEVEE-Next: Move shadow resolution scale to the sampling panel 2024-05-01 14:45:51 +02:00
Clément Foucault
643f4eaedf Fix: EEVEE-Next: Compilation error
Caused by accidentally merging two comflicting
PRs that had no merge conflict.
2024-04-30 20:40:48 +02:00
Clément Foucault
303f91a09c EEVEE-Next: Add slab thickness and thickness from shadow options
Implement the design discussed in #120384.

This adds two parameters. One for changing the approximation
method, and another to use the thickness from shadow map.

We pack the former in the gbuffer by dividing the 16bits
used for thickness by two and use one bit to store the
method.

The thickness from shadow map is now decoupled from the
light evaluation shader. This makes it more performant and
compatible with ray-tracing. This commit also uses the
same biases as shadow mapping to avoid aliasing artifacts
(fix #119339).

This refactors the light evaluation quite a bit to
remove unused bits bits and make the whole transmission
light evaluation without too much complexity.

Pull Request: https://projects.blender.org/blender/blender/pulls/121171
2024-04-30 20:32:46 +02:00
Hans Goudey
bc5f5d9a6c Cleanup: Use reference and rename mesh buffer list variable 2024-04-30 14:23:13 -04:00
Hans Goudey
6c2593cc13 Fix: EEVEE render crash after recent mesh index buffer commit
Caused by 1b7e67a851.
The GPU subdivision extraction was missing the check for whether
neither lines nor lines_loose was requested.
2024-04-30 14:18:28 -04:00
Miguel Pozo
a8f8745dcb Draw: Add default material fallback detection
Detect passes that are functionally equivalent to the default Material
ones to skip their compilation.

Pull Request: https://projects.blender.org/blender/blender/pulls/121137
2024-04-30 19:44:06 +02:00
Hans Goudey
f4bf30c224 Cleanup: Tweak comment and indentation in mesh IBO extraction 2024-04-30 13:03:26 -04:00
Hans Goudey
7799c04cf6 Cleanup: Use const BMesh pointer 2024-04-30 13:03:26 -04:00
Hans Goudey
19cdef03e2 BLI: Add IndexMask::from_bools_inverse utility 2024-04-30 13:03:26 -04:00
Hans Goudey
71df15de04 Fix #121265: Normals of faceless vertices are not displayed
Caused by bace4c9a29 which only
extracted normals at face corners. Solve by also extracting loose edge and
loose vertex normals. And change the BMesh extraction to not use the
face iteration of the MeshExtract system, just because that's simpler.
2024-04-30 13:03:26 -04:00
Hans Goudey
1b7e67a851 Mesh: Lines index buffer creation improvement
Implements another phase of #116901, this time for the `lines` and
`lines_loose` index buffers that store indices for wireframe drawing.
The key improvement is removing loose edge's dependency on the main
edge index buffer. That means for the majority of meshes with no loose
edges, edge index extraction can be completely skipped. Even when there
are loose edges, only the loose edges need to be extracted with
wireframe turned off.

Besides that improvement, there are more changes to use data-oriented
code with visible hot loops instead of the virtual function call design
used for the existing mesh extractor system. For this step I completely
replaced the `extract_lines` object, which is in line with the general
plan for this area.

Additionally, hidden edge filtering is done ahead of time using several
`IndexMask` operations. This means only indices for visible edges need
to be uploaded to the GPU, and no restart index stripping needs to be
performed on macOS.

On my usual test file with 1.9 million vertices, I observed an
improvement from 26 to 33 FPS with wireframe off, and from 9.15 to 9.5
FPS with wireframe on.

Pull Request: https://projects.blender.org/blender/blender/pulls/120720
2024-04-30 15:54:50 +02:00
Nathan Vegdahl
d5a4b98323 Fix #115930: custom colored bones are invisible when drawn in stick mode
The fix here is simple: we ignore the alpha channel in the bone theme
colors, setting it unconditionally to fully opaque.  This is correct
because conceptually the bone theme colors are just RGB, not RGBA,
and the alpha channel doesn't always get set consistently.

Pull Request: https://projects.blender.org/blender/blender/pulls/121256
2024-04-30 15:25:21 +02:00
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