godotengine / godot

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

SDFGI HDRI sampling artifacts. #85480

Open viksl opened 10 months ago

viksl commented 10 months ago

Godot version

4.2RC2

System information

Windows 11 - Vulkan - Nvidia RTX 4070 - intel i5 13600KF

Issue description

Strange shadow artifacts as you can see in the video. I've tried all sdfgi settings none helped. Some make it less visible some more some don't influence it at all but I can always find it. I've also tried not just PanoramaSky but also the ProceduralSky, this makes it barely visible but it's still there so the HDR texture only makes it more visible rather than being the sole cause of these artifacts.

I don't know if this is a bug or I'm just inept at tweaking the SDGFI, I don't think there's a single setting which I missed. Increasing the settings in SDFGI inside WorldEnvironment can help but the degree I have to up them to makes SDGFI pretty much useless at that point - you get different issues if you go with settings too high/low in distances and sizes ^.^

(I'll check 4.1 tomorrow or in upcoming days, I'm zero energy and caught the virus)

Video: https://youtu.be/Rl4b5stC0Gs

In my project it makes crazy amount of articats like this with a height map terrain and a forest so it's very visible even in busy scenes broken by many objects not just a straight out empty plane.

I've also tried different HDR textures, pretty much the same issue, again some "don't have" these issues although they do it's just less visible.

obrazek

Steps to reproduce

Use this HDRI for PanoramaSky: https://polyhaven.com/a/fouriesburg_mountain_lookout 4k, EXR. Fly around until you spot the issues, you can try moving the floor box down and up a bit and turning SDFGI on and off to reset it if you can't find the artifacts.

Minimal reproduction project

TestSDFGIPanorama.zip

clayjohn commented 10 months ago

This is an issue with the HDRI you are using. Raw captures of the sky are not suited for use in games. Mostly because the brightness of the sun is so much brighter than anything else. When you go to blur the sky, the sun overwhelms the other samples and leads to these blotchy looking spots.

To prepare an HDRI for games, you need to adjust the dynamic range so that the sun disk is only a few times brighter than the rest of the sky. You cannot just download an .exr photograph of the sky and expect to use it as-is in games

That being said, we can probably do a bit on our side to alleviate the artifacts. I have spent a lot of effort in minimizing this same type of artifact for sky reflections. We can probably do a bit more for SDFGI to reduce the artifact. Realistically though, this is a content issue not an engine issue.

viksl commented 10 months ago

Yeah I expected this I just wasn't sure if it's the case or not since I had some issues like this with SDFGI without panorama too over the time looking into some bug reports before.

Thanks for letting me know :-).

clayjohn commented 10 months ago

Yeah I expected this I just wasn't sure if it's the case or not since I had some issues like this with SDFGI without panorama too over the time looking into some bug reports before.

Thanks for letting me know :-).

Ya, fair enough. SDFGI has similar artifacts in scenes with high frequency lighting (i.e. a small bright light source). The theoretical reason is the same (under sampling), but the solution will be different. In this case, I'm hopeful we can soften the problem a bit with some pre-filtering (like we do for the sky)

viksl commented 10 months ago

Is that already part of the sdfgi rework or that's coming even later?

Calinou commented 10 months ago
clayjohn commented 10 months ago

Is that already part of the sdfgi rework or that's coming even later?

It would come later. As again, this is a sky issue, not an SDFGI issue

viksl commented 10 months ago

Oh I just found the same issue without HDR and without SDFGI completely. Turns out it's also an LOD issue, LOD system is somewhat broken. Particularly similar to video on large terrains it seems the LOD switches to a different level even when you are literally walking on the terrain and this causes some really weird shadow artifacts, depending on where the camera is pointing the LOD level changes which causes weird sahdows popping in and out and well just weird behaviour.

In this case I'm not 100% sure if it was only the HDRI so I'm leaving this info here for anyone who finds this since as mentioned earlier in my original project I had these issues (turning of LOD solves it) so maybe my repro project happened to hit similar issue which is caused by the improper HDRI as clayjohn mentioned while originally my project has been suffering from the LODs. (just to be clear before someone says I shouldn't use LOD on terrain or something, it doesn't have to be terrain, just a large mesh seems to be more than enough ;0).

I just wanted to make sure this info sticks to this since I might have been wrong at what was the issue.