Open markushall opened 1 year ago
Can you notice these artifacts when running the project? I notice your project is using the canvas_items
stretch mode, not viewport
. Zooming a lot in the editor tends to exaggerate artifacts that won't be noticeable in real world conditions.
If we zoom in a bit on the lamp and the LightOccluder2D there are stripes of what looks like some kind of inverted anti-aliasing going on, the further we get from the light source.
This is expected, as 2D shadow resolution is limited and doesn't scale with camera zoom for performance reasons. You can change it in the project settings (Rendering > 2D > Shadow Atlas > Size).
Thanks a lot! Yes, I got a sawtooth line when running the exported project (export all, release):
However, I can confirm that upping the shadow atlas size (to 8192) removes the artifacts when running the example project (debug). They are still visible in the editor, but I don't think that's much of an issue.
In my actual project, not the example one, I had to increase the shadow atlas size to 16384 (or maybe I can set it a tad smaller) to get rid of the artifacts. I have no idea on what impact that will have have in terms of performance and memory consumption in the finished game, but I guess time will tell.
I think the underlying issue is that there doesn't appear to be a way to control the bias used for shadow casting, like you can with shadow maps in 3D. This would likely alleviate the issue entirely in your case, without having to increase shadow resolution.
I can replicate this issue too on a very low resolution viewport due to 2D pixelart.
When using PCF13 and changing filter smooth, some strange "square" artifacts can be observed. In this clip I am changing the slider from filter smooth 0 to maximum and back. When maxing out the value, the artifacts become most visible:
https://github.com/user-attachments/assets/a38316b2-f0f2-4492-846a-acfd5f2abaab
Godot Engine v4.3.stable.steam.77dcf97d8 OpenGL API 3.3.0 NVIDIA 546.17 - Compatibility - Using Device: NVIDIA - NVIDIA GeForce GTX 1080
Godot version
v4.1.2.stable.flathub [399c9dc39]
System information
Godot v4.1.2.stable (399c9dc39) - Freedesktop SDK 23.08 (Flatpak runtime) - X11 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 1660 SUPER (nvidia) - Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz (8 Threads)
Issue description
I am working on a low-res (384 x 216) pixel game using the mobile renderer, and I have a problem with the light occluder producing weird artifacts. This effect increases with the distance to the light source.
Minimal reproducible example scene:
If we zoom in a bit on the lamp and the LightOccluder2D there are stripes of what looks like some kind of inverted anti-aliasing going on, the further we get from the light source.
The closest I get to removing this effect is when setting Cull Mode to CounterClockWise. That makes the artifacts go away on the top side but adds them to the bottom side instead.
Misc observations:
Steps to reproduce
Minimal reproduction project
occlusion_test.zip