EEVEE-Next: Add shadow bias based on depth reconstruction precision #111478
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111478
Loading…
Reference in New Issue
No description provided.
Delete Branch "pragma37/blender:pull-eevee-next-shadow-bias"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Avoid self-shadowing artifacts by adding shadow bias based on world position reconstruction precision.
This also updates the Renderbuffers depth texture to use a 32 bit format for extra precision, and to match the HiZ texture.
@ -14,1 +14,4 @@
float depth_reconstruction_precision(float depth)
{
vec3 P = get_world_space_from_depth(uvcoordsvar.xy, depth);
Can't you have the same result with
get_view_space_from_depth
? That would save 2 matrix multiply.@ -171,12 +175,17 @@ ShadowSample shadow_punctual_sample_get(
float radius_divisor = receiver_dist / abs(lP.z);
samp.occluder_dist = occluder_z.x * radius_divisor;
samp.bias = (occluder_z.y - occluder_z.x) * radius_divisor;
samp.bias += bias;
I would guard this behind a
#ifdef DEFERRED_EVAL
directive to avoid the cost in other passes.I don't know if the Dead Code Elimination would be good enough on all platform to eliminate the
+ 0.0
.If we do this maybe we should move the shadow bias parameter to a global variable?
It would be quite weird to ignore a function parameter based on a preprocessor define.
That said, even if the compiler doesn't ignore the add, is that going to cause any measurable difference?
It is a value that takes one register and is long lived.
9732d02bcc
to01c1d86c0a
I am not convinced by this approach. I find it a bit too complicated for what it tries to solve.
The aliasing is caused by 2 factor:
Scene depth buffer quantization:
This can be fixed by added a small constant bias to the depth buffer value right after reading it (the
nextafter2
). Thisnextafter
only works if depth buffer is using float32 format to have the same quantization bias as the format (otherwise you need to bias to 4.8e-7 or a bit higher. ref http://terathon.com/gdc07_lengyel.pdf slide 26 or search for2.4e-7
or4.8e-7
in the code (this should definitely be put into a utility somewhere) ).But do note that float32 depth format offer no benefit with conventional projection matrix (https://developer.nvidia.com/content/depth-precision-visualized). So while I'm ok with enable it (MacOS already enables it by default) I would like to see a comparison.
I would suggest to just bias the shading point reconstruction instead of computing the error. This is done in many other passes the same way and it doesn't create much difference on the final image.
Shadowmap aliasing:
This is already mitigated by the slope bias in the shadow fragment shader (
float f_depth = gl_FragCoord.z + fwidth(gl_FragCoord.z);
) andu_depth += 2;
.But that doesn't solve projective or perspective aliasing (i.e: https://i.stack.imgur.com/7GPmi.jpg). That is why we have the manual normal bias. However, since this scales with the shadow resolution it needs to be adjusted with the view distance just as much as shadow resolution changes with distance (that's what the
/* TODO(fclem): Scale based on depth. */
is about).I would not consider scaling it differently for each light but simply scaling it with the distance the same way the shadow LOD request does it. This would improve the situation quite a lot.
@ -27,3 +35,4 @@
vec3 V = drw_world_incident_vector(P);
float vPz = dot(drw_view_forward(), P) - dot(drw_view_forward(), drw_view_position());
g_depth_reconstructionn_bias = depth_reconstruction_precision(vP, depth);
g_depth_reconstructionn_bias
typo, doublen
Checkout
From your project repository, check out a new branch and test the changes.