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

Refactored shadowmapping. #37678

Merged
merged 1 commit into from
Apr 8, 2020
Merged

Conversation

reduz
Copy link
Member

@reduz reduz commented Apr 8, 2020

image

  • Made shadow bias size independent, so it will remain when changing light or camera size.
  • Implemented normal offset bias, which greatly enhances quality.
  • Added transmission to subsurface scattering

Closes #17260
Bugsquad edit: closes godotengine/godot-proposals#262, fixes #34010, fixes #29690, fixes #23603, fixes #12148, fixes #13575, fixes #24587, fixes #11398

@clayjohn clayjohn added this to the 4.0 milestone Apr 8, 2020
@reduz reduz force-pushed the refactor-shadowmapping branch from 41f0f74 to a96540a Compare April 8, 2020 03:25
@@ -414,11 +416,8 @@ void DirectionalLight3D::_bind_methods() {
DirectionalLight3D::DirectionalLight3D() :
Light3D(RenderingServer::LIGHT_DIRECTIONAL) {

set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed the defaults here and then never replaced them

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah..

@Zireael07
Copy link
Contributor

That's closing A LOT of issues 😉


{

#if 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentionally left out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, this is from a previous attempt to implement normal bias in this type of light which I wasn' t very convinced about. The one above works better.

@reduz reduz force-pushed the refactor-shadowmapping branch 2 times, most recently from 5fc9e01 to c3e7b44 Compare April 8, 2020 13:15
- Made shadow bias size independent, so it will remain when changing light or camera size.
- Implemented normal offset bias, which greatly enhances quality.
- Added transmission to subsurface scattering
- Reimplemented shadow filter modes

Closes godotengine#17260
@reduz reduz force-pushed the refactor-shadowmapping branch from c3e7b44 to 4ffc0d6 Compare April 8, 2020 14:20
@reduz reduz merged commit 26ecd92 into godotengine:master Apr 8, 2020
akien-mga added a commit to akien-mga/godot that referenced this pull request Apr 20, 2020
Subgroups were added in godotengine#37678 but not properly handled everywhere
where PROPERTY_USAGE_GROUP is.
@fire
Copy link
Member

fire commented Apr 22, 2020

How difficult is the backport of the code for 3.2?

@KeyboardDanni
Copy link
Contributor

Is there a patchset or fork that brings these changes to 3.x? There's probably no way this would be in an official 3.x release since the changes to shadow/light properties would break compatibility, but it would be great if I could take advantage of the improved shadows now instead of Waiting For Godot 4.1. The shadows in 3.x are serviceable but could be a lot sharper and there isn't a way to avoid both artifacting and peterpanning. The shadows in 4 on the other hand are basically magic.

@Calinou
Copy link
Member

Calinou commented Jul 29, 2022

Is there a patchset or fork that brings these changes to 3.x? There's probably no way this would be in an official 3.x release since the changes to shadow/light properties would break compatibility, but it would be great if I could take advantage of the improved shadows now instead of Waiting For Godot 4.1. The shadows in 3.x are serviceable but could be a lot sharper and there isn't a way to avoid both artifacting and peterpanning. The shadows in 4 on the other hand are basically magic.

Se #43207, which backports a fix from this pull request.

While it's technically possible to backport the other features (at least under GLES3), it'd be too much work to backport for 3.6. Feel free to tackle this if you feel adventurous still, but it won't be easy 🙂

The shadows in 3.x are serviceable but could be a lot sharper

If you want sharper shadows, you have to increase their resolution or decrease Shadow Max Distance on a DirectionalLight. It works like that in 4.0 too. There isn't any other way around this, other than implementing godotengine/godot-proposals#3908.

Directional shadows look a bit sharper out of the box on 4.0 due to #43207 (on aspect ratios wider than 1:1), but this is more of a side effect of that fix than an actual feature.

Note that sharper shadows are not always better from an artistic point of view. Blurrier but more temporally stable shadows are often preferable in my experience, especially for moving objects.

@KeyboardDanni
Copy link
Contributor

Shadows in 4.0 are definitely a bit sharper with the same settings versus 3.x (and a lot sharper with a wider aspect ratio). But the big thing for me is that with 3.x I can get simultaneous artifacting and peterpanning, whereas with 4.0 I can avoid both.

Shadows_PCF5_3_x
Shadows_PCF5_4_0

This is with 4k textures in both.

I know about the reverse culling option, but it adds artifacting to sharp corners, and for my visual style I don't want to subdivide everything. I want the graphics looking sharp and clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment