[3.x] Add a per-light shadow blur property#60243
Conversation
This is available for all light types in both GLES3 and GLES2. It only has an effect when the shadow filter is PCF5 or PCF13.
|
I'm not sure about this one. PCF isn't really designed for a variable width shadow blur. The texture sample locations are chosen specifically for the algorithm. By increasing or decreasing the blur, you end up oversampling or undersampling certain pixels which can lead to artifacts. Overall, the implementation seems fine. But there needs to be significant user demand to merge this. |
|
@clayjohn I don't know if users are aware that this was a possible to do, to demand for it, this looks optional and can improve the looks with little effort. What can be done to see if users want this? open a discussion? |
That is certainly a good option! To clarify, I am not suggesting that users need to come here and say that this PR is demanded. I just haven't seen demand for uniformly wider shadow penumbra in 3.x. I have seen people ask for PCSS style shadows (blur increases as distance increases), but not uniform blur (as is implemented in this PR). We added uniform blur in 4.0 as a way to allow users to hide some of the artifacts that come from using PCSS. But in 3.x I'm not sure it adds much value. As you can see, adding blur makes the shadows become blocky and aliased, this is becuase any amount of blur is going to cause undersampling of the shadow map which introduces aliasing. |
I've seen that DPCF (depth-based PCF) could be used to implement a cheaper form of contact-hardening shadows. It could also help make biasing issues less noticeable (since lower blur will tend to do that). It might be worth looking into for 3.x. DPCF is mentioned on slides 59 and after in this presentation (with a code sample on slide 74). |
Follow-up to #60186 (can be merged independently, I'll rebase as needed).
This backports a feature already available in the
masterbranch: per-light shadow blur adjustments.This is available for all light types in both GLES3 and GLES2. It only has an effect when the shadow filter is PCF5 or PCF13.
From my testing, performance is identical compared to before in both GLES3 and GLES2.
For DirectionalLight shadows, there is an issue in GLES2 when the shadow filter mode is PCF13 and the shadow blur is not equal to 1.0. The shadow will flicker as the camera rotates and moves, I don't know why. This does not occur with other shadow filter modes, other light types or in GLES3.
Testing project: test_shadow_b_3.x_1.zip
Preview
The shadow filter mode is PCF13 on all screenshots. The Blue OmniLight had its shadow blur increased to
8.0.GLES3
GLES2