godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.68k stars 20.11k forks source link

SpotLights with shadows enabled cause artifacts to appear in the editor (`3.x` only) #12028

Open Calinou opened 6 years ago

Calinou commented 6 years ago

Operating system or device, Godot version, GPU Model and driver (if graphics related): Windows 10, Godot Git https://github.com/godotengine/godot/commit/409e58e67abde4e7af6e43b32c23338e119377fb, NVIDIA

SpotLights with shadows enabled cause shading artifacts to appear in the editor, see the screenshots below. Tweaking the shadow bias doesn't seem to have any effect on the artifacts.

Narrow spotlight with shadows (broken):

Narrow spotlight with shadows (broken)

Wide spotlight with shadows (broken):

Wide spotlight with shadows (broken)

SpotLights with an angle above 90° look broken with shadows enabled, but they work with shadows disabled.

Ultrawide spotlight with shadows (broken):

Ultrawide spotlight with shadows (broken)

Ultrawide spotlight without shadows (working):

Ultrawide spotlight without shadows (working)

This bug doesn't seem to affect running projects.

SpotLight in running project (working):

Spotlight in running project

reduz commented 6 years ago

As mentioned before. Spoltlights with angles over 90 are not expected to have shadows. Use Omni lights. For the others issues, make a test project showing there arctifacts exist.

Gear-Code commented 6 years ago

I have also found some bugs with spotlight where it won't show any shadows even tho I've activated them and light not showing on any mesh I aim at unless I go really close to it and even then it's still very glitchy.

I have made a simple project in godot 3.0 alpha 1 version where u can see these effects for your self. spotlight bug.zip

Here is also a picture showing spotlight not lighting meshes properly screenshot 12

ghtyrant commented 4 years ago

I do have a similar(?) issue with spotlights. In the image attached there is a spotlight between two cubes, shining its light onto a plane. The plane looks fine but the cubes have weird artifacts.

image

The spotlight has an angle of 54.5°, changing it does not reduce the artifacts. Changing the bias of the light can get rid of the artifacts, but only at a point where the light is really off (shining through the cubes).

What I found that helps so far:

Here you can download a scene to reproduce this issue: http://cloud.skyr.at/f/1170b33942be4162934e/?dl=1

I am using Godot 3.1.1-stable-mono on Windows 10.

Master-J commented 4 years ago

Managed to reproduce the issue in godot 3.2 alpha 3 both in editor and at runtime. I noticed that enabling "reverse cull face" in the light's settings somehow gets rid of the issue but creates some light bleeding, editing biases solve the bleeding. Capture

Olaf-007 commented 4 years ago

It seem like the shadow is "on" the plate. The "reverse cull face" setting makes it even worse.

grafik

Calinou commented 4 years ago

@Olaf-007 When you enable Reverse Cull Face, you should use a slightly negative bias like -0.01. (If it doesn't update correctly, change it back and forth.)

Calinou commented 3 years ago

Note that this is fixed in the master branch following the introduction of shadow normal offset bias/shadow pancaking.

For 3.x, see the recommendations outlined in this PR: https://github.com/godotengine/godot-docs/pull/5340

aaronfranke commented 2 years ago

@Calinou What settings need to be enabled in the master branch to solve this issue there?

Calinou commented 2 years ago

@Calinou What settings need to be enabled in the master branch to solve this issue there?

You can generally keep the default settings, but sometimes you'll have to increase Normal Bias to 2 to avoid shadow acne. If you use large unsubdivided meshes with DirectionalLight3D shadows, increase Pancake Size in the DirectionalLight3D properties.

Positional lights can also have their Bias decreased significantly in some cases (sometimes as low as 0.03). Note that this advice depends on the shadow's Blur property and the shadow resolution set in the project settings (along with the number of visible positional lights in the scene, due to the atlas quadrant subdivisions not having the same resolution by default).

See https://github.com/godotengine/godot/pull/57638 and https://github.com/godotengine/godot/pull/55758.