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: SpotLight3D angles above 90 degrees cause clustering artifacts (even with shadows disabled) #48054

Closed
lyuma opened this issue Apr 20, 2021 · 5 comments · Fixed by #71832

Comments

@lyuma
Copy link
Contributor

lyuma commented Apr 20, 2021

Godot version:
4.0.dev f817e7f

OS/device including version:
Windows 10.0.19041.928
Nvidia RTX 2080 Ti
Driver version 466.22

Issue description:
SpotLight angles seem doubled from what makes intuitive sense to me. For example, an angle of 120 degrees covers roughly 240 degrees of the sphere. 179 degrees covers effectively the whole sphere, same as an omni light.

However, when the Spotlight angle exceeds a Hemisphere (90 degrees in Godot), the spotlight continues to expand, but the clusters collapse to (180-angle) degrees, causing the square clustering artifacts.

image

My opinion is spotlights which are greater than a hemisphere are kind of a strange concept, but if they are intended to be supported, perhaps this could be worked around by having the clustering algorithm treat them like omni lights.

Steps to reproduce:

  1. Open the attached project
  2. Zoom the camera as in the above screenshot, so that the camera is facing the spotlight and the capsule is off to the side.
  3. Play with the spot angle and note how as the angle increases, the cluster squares diminish.
  4. For spot angles < 90, everything renders perfectly fine.

Minimal reproduction project:
SpotLightClusterTest.zip

@Calinou
Copy link
Member

Calinou commented Apr 20, 2021

My opinion is spotlights which are greater than a hemisphere are kind of a strange concept, but if they are intended to be supported, perhaps this could be worked around by having the clustering algorithm treat them like omni lights.

They are intended to be supported, but only when shadows are disabled. If shadows are enabled for an ultrawide spotlight, a node configuration warning is emitted.

@Calinou
Copy link
Member

Calinou commented Jun 30, 2021

I can confirm this on commit 52e3f98 (Linux + NVIDIA). The angle of the clustering artifacts seems to be 180 - angle degrees.

45 degrees (good)

image

135 degrees (bad)

image

@Calinou Calinou added this to the 4.0 milestone Jun 30, 2021
@Calinou Calinou changed the title Spotlight angles above 90 cause clustering artifacts Vulkan: SpotLight3D angles above 90 degrees cause clustering artifacts (even with shadows disabled) Jun 30, 2021
@Calinou
Copy link
Member

Calinou commented Nov 25, 2021

We don't seem to have access to the spot angle in the cluster data, so we can't treat ultrawide SpotLights as OmniLights for the purpose of clustering. The only reference to SpotLights in the cluster builder is here:

case ELEMENT_TYPE_SPOT_LIGHT: {
RD::get_singleton()->draw_list_bind_vertex_array(draw_list, shared->cone_vertex_array);
RD::get_singleton()->draw_list_bind_index_array(draw_list, shared->cone_index_array);
} break;

@rustwork
Copy link

This is also an issue with narrow spotlight angles less than about 40 degrees. It's easy to reproduce by setting a spotlight's angle to about 11, turning up the energy and range and putting a spotlight close to some geometry.

image

Seen in 4.0 alpha 10, 11, 12 and 13 on windows 10, Nvidia Geforce 3060 Ti

@Calinou
Copy link
Member

Calinou commented Nov 29, 2022

@rustwork This isn't exactly the same issue, although it may have a similar cause. See #59262.

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.

5 participants