EEVEE-Next: Add Shadows PCF #118220
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#118220
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "pragma37/blender:pull-eevee-pcf-shadows"
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?
Add percentage closer filtering to shadowmap sampling.
Adds a setting to control the radius to the Light UI.
Notes:
eevee_shadow_tracing_lib
, but not toeevee_shadow_lib
, which is used by volumes (not required) and thickness (required, but might be better to use tracing there too?).I've made a test to add PCF for sharp (0 radius) shadows too:
https://projects.blender.org/pragma37/blender/src/branch/test-eevee-pcf
(Note that this is a separate branch, it's not included in this PR)
It currently has issues at page edges, but that can be fixed. The downside is that this needs to actually evaluate the PCF inline (sampling the shadowmap texture multiple times instead of distributing it across render samples), which is expensive.
However, to implement this I've modified the lighting evaluation to use
shadow_sample
instead ofshadow_eval
(which uses shadow tracing) for lights with 0 radius, so the final performance ends up being pretty much the same.On a simple scene with 4 point lights, the
EvalLights
pass timings look like this:shadow_sample
(PCF off): ~1.38 msshadow_sample
(PCF on): ~3.33 msshadow_eval
: ~3.19msI'd say the quality improvement is worth adding it at least as an option.
Add pcf
223be74c25WIP: EEVEE-Next: Add Shadows PCFto EEVEE-Next: Add Shadows PCF@blender-bot build +gpu
Implementation looks good (except this matrix inversion that can be simplified).
I'm unsure about the parameter being on the scene rather than per light. But that could be changed later I think.
@ -724,6 +724,7 @@ class RENDER_PT_eevee_next_shadows(RenderButtonsPanel, Panel):
col = layout.column()
col.prop(props, "shadow_normal_bias", text="Normal Bias")
col.prop(props, "shadow_pcf_radius", text="PCF Radius")
Filtering Radius
is a better term. PCF is a technical term.@ -1023,3 +1023,3 @@
/* Bias the shading point by using the normal to avoid self intersection. */
float normal_bias;
int _pad2;
float pcf_radius;
Add description.
@ -99,0 +125,4 @@
vec3 shadow_punctual_reconstruct_position(ShadowSampleParams params, LightData light, vec3 uvw)
{
vec3 clip_P = uvw * 2.0 - 1.0;
mat4 winmat = shadow_punctual_projection_perspective(light);
Given this function is called twice, I would put the
winmat
or ratherwininv
(or both) in theShadowSampleParams
to avoid setting it up twice. The compiler should be smart enough to eliminate it when not needed.@ -99,0 +126,4 @@
{
vec3 clip_P = uvw * 2.0 - 1.0;
mat4 winmat = shadow_punctual_projection_perspective(light);
vec3 lP = project_point(inverse(winmat), clip_P);
This inverse is very nasty. Please create a
shadow_projection_perspective_inverse
and populate it manually. Might as well do the TODO and simplify it for the symmetrical case.This is the simplified function:
This link is the inversion for the symmetric matrix.
@ -406,6 +408,64 @@ SHADOW_MAP_TRACE_FN(ShadowRayPunctual)
/** \name Shadow Evaluation
* \{ */
vec3 shadow_pcf_offset(LightData light, const bool is_directional, vec3 P, vec3 Ng)
Add overall description of what this function does.
@ -409,0 +427,4 @@
return vec3(0.0);
}
/* Compute shadomap TBN matrix. */
shadow-map
@ -409,0 +451,4 @@
BP = line_plane_intersect(light._position, normalize(BP - light._position), P, Ng);
}
mat3 TBN = mat3(TP - P, BP - P, Ng);
You could do it with a
mat2x3
.@ -409,0 +460,4 @@
rand = sampling_rng_2D_get(SAMPLING_SHADOW_V);
#endif
vec2 pcf_offset = interlieved_gradient_noise(UTIL_TEXEL, vec2(0.0), rand);
pcf_offset = pcf_offset * vec2(2.0) - vec2(1.0);
Nitpick:
pcf_offset * 2.0 - 1.0;
@ -1917,8 +1917,8 @@ typedef struct SceneEEVEE {
int shadow_ray_count;
int shadow_step_count;
float shadow_normal_bias;
float shadow_pcf_radius;
Rename to
shadow_filter_radius
. No need to mention PCF anywhere but on EEVEE's code (implementation detail).@ -54,3 +73,2 @@
/* TODO(fclem): Remove. Only here to avoid include order hell with common_math_lib. */
mat4x4 shadow_projection_perspective(
float left, float right, float bottom, float top, float near_clip, float far_clip)
mat4x4 shadow_projection_perspective(float side, float near_clip, float far_clip)
You can remove the
TODO
on top as this is now a valid optimization@ -76,0 +95,4 @@
float d = 2.0 * near_clip * far_clip;
mat4x4 mat = mat4x4(1.0);
if (side != 0.0 && z_delta != 0.0) {
I'm wondering if we could remove this check as we ensure both are valid on CPU side.
The only issue I found is that it crease some overshadowing in some areas (see image). But that's expected as the shadow depth slop bias isn't set accordingly. This can be fixed later on.![image](/blender/blender/attachments/2a60e2ce-4b03-4502-86ad-d4b08ae09e39)
@ -2968,1 +2968,4 @@
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 6)) {
LISTBASE_FOREACH (Light *, light, &bmain->lights) {
light->shadow_filter_radius = 3.0f;
I would default to value of 1.0 for old scenes. This would match the old behavior.
JawSFM referenced this pull request2024-08-14 22:32:23 +02:00