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

Fix directional shadow bias #51025

Merged
merged 1 commit into from
Aug 13, 2021

Conversation

reduz
Copy link
Member

@reduz reduz commented Jul 29, 2021

  • Simplified code a lot, bias based on normalized cascade size.
  • Lets scale cascades, max distance, etc. without creating acne.
  • Fixed normal biasing in directional shadows.

I removed normal biasing in both omni and spot shadows, since the technique can't be easily implemented there.
Will need to be replaced by something else.

Bugsquad edit: This closes #45115.

* Simplified code a lot, bias based on normalized cascade size.
* Lets scale cascades, max distance, etc. without creating acne.
* Fixed normal biasing in directional shadows.

I removed normal biasing in both omni and spot shadows, since the technique can't be easily implemented there.
Will need to be replaced by something else.
@reduz reduz force-pushed the fix-directional-shadow-bias branch from 81c7b8d to 55d357b Compare July 29, 2021 16:51
@reduz reduz requested a review from a team as a code owner July 29, 2021 16:51
@@ -2701,7 +2701,7 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const
CameraMatrix shadow_mtx = rectm * bias * matrix * modelview;
light_data.shadow_split_offsets[j] = split;
float bias_scale = li->shadow_transform[j].bias_scale;
light_data.shadow_bias[j] = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BIAS) * bias_scale;
light_data.shadow_bias[j] = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BIAS) / 100.0 * bias_scale;
Copy link
Member Author

Choose a reason for hiding this comment

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

I used 100 to avoid integer units for the normalized bias. Could be 1000 I don know.

Copy link
Contributor

@JFonS JFonS left a comment

Choose a reason for hiding this comment

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

Looks good, tested during my work on #51335.

@akien-mga akien-mga merged commit e499758 into godotengine:master Aug 13, 2021
@akien-mga
Copy link
Member

Thanks!

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.

Vulkan: Directional light shadow rendering is broken on some splits after culling changes
4 participants