EEVEE-Next: Shadow resolution scale and adaptive filtering #119436
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
Code Documentation
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#119436
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "pragma37/blender:pull-eevee-shadow-resolution-scale"
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?
Allow the user to scale shadow-map resolution per-light.
Adapt the PCF scale based on shadow-map to pixel footprint ratio, since we can no longer assume that higher LODs don't need filtering.
This allows using much lower shadow resolutions, which can yield quite significant performance improvements, with relatively little perceptual quality loss (at the cost of softening shadow edges).
The per-light resolution scale is a literal scale, so for example 0.5 means half the resolution. The Scene Simplify Shadows setting has been updated to match this behavior.
@blender-bot build +gpu
@ -131,0 +133,4 @@
int shadow_directional_level(LightData light, vec3 lP)
{
int clipmap_lod = int(ceil(shadow_directional_level_fractional(light, lP)));
return clamp(clipmap_lod, light.clipmap_lod_min, light.clipmap_lod_max);
you are clamping twice. I don't think that is necessary.
I did it to workaround possible floating point precision issues causing troubles with the later
ceil
.But maybe I was just overly paranoid.
@ -131,0 +144,4 @@
*/
float shadow_punctual_footprint_ratio(LightData light,
vec3 P,
float perspective_division,
Pass
float dist_to_cam
andbool is_perspective
for clarity.@ -470,0 +478,4 @@
float dist_to_cam = distance(P, drw_view_position());
float perspective_division = 1.0;
if (drw_view_is_perspective()) {
perspective_division = distance(P, drw_view_position());
you are computing
dist_to_cam
again@blender-bot build +gpu
@ -819,2 +819,3 @@
float pcf_radius;
int _pad0;
/* Shadow Map resolution bias. */
float lod_bias;
Then remove
_clipmap_lod_bias
since it is redundant (and would remove some dirty define code).@ -1311,6 +1311,8 @@ void ShadowModule::set_view(View &view, GPUTexture *depth_tx)
pixel_world_radius_ = screen_pixel_radius(view, int2(target_size));
tilemap_projection_ratio_ = tilemap_pixel_radius() / pixel_world_radius_;
data_.tilemap_projection_ratio = tilemap_projection_ratio_;
Do not duplicate data. Remove the private member.
@ -464,3 +464,3 @@
rand = sampling_rng_2D_get(SAMPLING_SHADOW_V);
#endif
vec2 pcf_offset = interlieved_gradient_noise(UTIL_TEXEL, vec2(0.0), rand);
vec2 pcf_offset = interlieved_gradient_noise(UTIL_TEXEL, vec2(5, 7), rand);
This is yielding strong flickering in the noise pattern due to correlation between the 2 random numbers.
Use this instead:
@ -470,0 +481,4 @@
light, P, is_perspective, dist_to_cam, uniform_buf.shadow.tilemap_projection_ratio);
float lod = -log2(footprint_ratio) + light.lod_bias;
lod = clamp(lod, 0.0, float(SHADOW_TILEMAP_LOD));
float pcf_scale = pow(2.0, lod);
Never use
pow(2.0, lod)
. Poor precision and bad perf. Useexp2(lod)
instead.Same for
pow(x, 2.0)
usepow2(x)
.@ -307,0 +307,4 @@
prop = RNA_def_property(srna, "shadow_resolution_scale", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_ui_range(prop, 0.0f, 2.0f, 0.25f, 2);
RNA_def_property_ui_text(prop, "Shadow Resolution Scale", "Bias the Shadow Map resolution");
This needs more attention. This can be polished later with the UI team.
However, it should already be stated that:
0
means the lowest possible resolution.1
tries to match screen pixel density.2
is double the resolution.I don't know if it should be mentioned in the tooltip that this is also affected by the simplify option.
I've updated the tooltip to :
I think that kind of covers all your suggestions without being overly wordy, but feel free to suggest an alternative.
Not too sold on using blue noise for the filter offset:
It may improve the per-sample flickering, but the final image looks worse IMO.
If the noise persists at higher sample count (in F12 render) then it's some correlation artifacts. You can try using another layer of the blue noise (the alpha), you can try scrambling the resulting numbers quite more using
noise = fract(noise * 6.1803398875)
(but that doesn't do miracle).But to be honest, in my tests, the code I gave you in the previous comment did yield a noise free result with enough sample. I know it combines 2 RNG offsets and that looks weird but it is worth a try.
If you are only comparing a low amount of samples (<200) then yes, the result can look noisier than IGN since the random numbers are using leaped Halton sequences that has very slow convergence.
Yes, those images were taken at 64 samples IIRC. The blue noise eventually converges, but it needs more samples to look ok.
Take into account that this is essentially an optimization feature.
If lowering render times comes at the cost of heavily increasing the number of samples needed, then there's no point in using it.
I think this is good to go. (after fixing the conflicts obviously)