Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically increase Light3D shadow bias when shadow blur is above 1.0 #55758

Closed

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Dec 9, 2021

This makes it possible to adjust shadow blur without having to tweak bias to avoid shadow acne. The formula automatically increases shadow bias, normal bias and transmittance bias when shadow blur is above 1.0:

shadow_blur_bias_factor = max(1, 0.5 + shadow_blur * 0.5);

At the highest shadow blur value allowed in the inspector (8), the shadow bias and normal bias will each be multiplied by 5.5.

Automatic adjustment is not performed for PCSS-style shadow blur (light size > 0) yet.

This partially addresses #53534.

TODO

  • Leave shadow bias unaffected when shadow quality is set to Hard, since constant blur will not affect the shadow's appearance with this setting.

Preview

Note: The bias values used in the demo below are from #55757.

DirectionalLight3D

Visible lines between PSSM shadow splits will be attenuated if #48776 is merged.

Before

shadow_blur_directional_old2.mp4

After

shadow_blur_directional_new.mp4

OmniLight3D

Before

shadow_blur_omni_old2.mp4

After

shadow_blur_omni_new.mp4

SpotLight3D

Before

shadow_blur_spot_old2.mp4

After

shadow_blur_spot_new.mp4

@Ansraer
Copy link
Contributor

Ansraer commented Dec 10, 2021

Would be nice if this was somehow displayed in the inspector. Right now user input is just ignored if it is below the min value.

@mrjustaguy
Copy link
Contributor

Does this change affect the total shadow blur (so after Quality blur multiplier is applied) or only the setting blur?

It should affect the total because higher quality softness tend to create more shadow acne because of their internal higher blur multipliers.

@Calinou
Copy link
Member Author

Calinou commented Dec 10, 2021

Would be nice if this was somehow displayed in the inspector. Right now user input is just ignored if it is below the min value.

This acts as a multiplier, so I don't see how the value can be ignored (regardless of the blur setting you're using). The multiplier itself is an implementation detail (like the shadow Z near/far ranges), so I didn't mention it in the class reference.

Does this change affect the total shadow blur (so after Quality blur multiplier is applied) or only the setting blur?

It should affect the total because higher quality softness tend to create more shadow acne because of their internal higher blur multipliers.

Right now, this PR doesn't take the shadow quality blur factor into account. This should be feasible, but I think the base automatic adjustment will work well enough. I fear that further increasing the shadow bias factor automatically will result in too much peter-panning at high shadow quality settings.

This makes it possible to adjust shadow blur without having to tweak
bias to avoid shadow acne. The formula automatically increases
shadow bias, normal bias and transmittance bias when shadow blur
is above 1.0:

    shadow_blur_bias_factor = max(1, 0.5 + shadow_blur * 0.5);

At the highest shadow blur value allowed in the inspector (8),
the shadow bias and normal bias will each be multiplied by 5.5.

Automatic adjustment is not performed for PCSS-style shadow blur
(light size > 0) yet.
@Calinou
Copy link
Member Author

Calinou commented Nov 6, 2022

Superseded by #68339, which is a more robust solution to the original problem.

@Calinou Calinou closed this Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants