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

Vulkan: DirectionalLight3D PSSM 2 Splits exhibits shadow acne not present in other modes, and shadows are unstable #59232

Closed
mrjustaguy opened this issue Mar 17, 2022 · 1 comment · Fixed by #82974

Comments

@mrjustaguy
Copy link
Contributor

Godot version

4.0 Alpha 4

System information

Windows 11, Vulkan, Nvidia GTX 1050 Ti, 511.23

Issue description

2 Split mode has severe Shadow Acne issues, unrelated to Shadow Resolution (both Orthogonal and 4 Split don't have Any issues in the same example) and the Shadows are unstable with 2 Splits (they jitter as the camera moves) again, unlike the other modes.

Steps to reproduce

Switch Between Orthogonal or 4 Split Mode and 2 Split mode and Observe the differences

Minimal reproduction project

Bug.zip

@Calinou
Copy link
Member

Calinou commented Mar 17, 2022

I can confirm this on master fb28025, both with the Vulkan Clustered and Vulkan Mobile backends. This doesn't occur on 3.x 6073277, both with GLES3 and GLES2.

PSSM 2 Splits

2022-03-17_16 50 47

PSSM 4 Splits

2022-03-17_16 50 55

Orthogonal

2022-03-17_16 50 51

Shadow stabilization is performed here:

// This trick here is what stabilizes the shadow (make potential jaggies to not move)
// at the cost of some wasted resolution. Still, the quality increase is very well worth it.
const real_t unit = (radius + soft_shadow_expand) * 2.0 / texture_size;
x_max_cam = Math::snapped(x_vec.dot(center) + radius + soft_shadow_expand, unit);
x_min_cam = Math::snapped(x_vec.dot(center) - radius - soft_shadow_expand, unit);
y_max_cam = Math::snapped(y_vec.dot(center) + radius + soft_shadow_expand, unit);
y_min_cam = Math::snapped(y_vec.dot(center) - radius - soft_shadow_expand, unit);

There doesn't appear to be a condition for the number of splits used. However, unlike Orthogonal or PSSM 4 Splits, using PSSM with 2 splits will result in a non-square shadow map texture for each split (with the first split in the top half, and the second split in the bottom half):

} else if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
atlas_rect.size.height /= 2;
if (p_pass == 0) {
} else {
atlas_rect.position.y += atlas_rect.size.height;
}
}

@Calinou Calinou changed the title Vulkan Directional Light 2 Split Issues Vulkan: DirectionalLight3D PSSM 2 Splits exhibits shadow acne not present in other modes, and shadows are unstable Mar 17, 2022
@Calinou Calinou modified the milestones: 4.0, 4.x Feb 20, 2023
@akien-mga akien-mga modified the milestones: 4.x, 4.2 Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants