godotengine / godot

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

Vulkan: VoxelGI creates glowing shadow edges #83025

Open WickedInsignia opened 11 months ago

WickedInsignia commented 11 months ago

Godot version

4.2 Dev 6

System information

Windows 11, Nvidia RTX4070ti, AMD Ryzen7700x

Issue description

Voxel GI spills light into shadows in an unrealistic manner, creating a "glow" effect around their edges and propagating light across surfaces that should not be affected by the bounces they're creating. This gives meshes an unintentionally waxy appearance, since this effect is similar to subsurface scattering. It also spills light around corners into areas unaffected by direct light, causing light to leak around sharp angles.

VoxelGI at default settings (128 subdiv). The Glow post processing effect is disabled, so the light leaking into the shadow the structure is casting is caused by Voxel GI: VoxelGIGlowingShadows_128

This is not resolved by higher resolutions (512). Here we can also see the light bleeding around sharp angles more clearly, near the top of the structure: VoxelGIGlowingShadows_512

We can see the effect in the Voxel lighting view (128 for this example): VoxelGIGlowingShadows_128Voxel

Changing Normal Bias can reduce the effect, but causes further leaks in other areas (128): VoxelGIGlowingShadows_128NormalBias

When we use Blender's Cycles as a ground truth example, there is no light bleeding into the shadows. Only light bouncing onto surrounding surfaces: VoxelGIGlowingShadows_BlenderRender

Thus, the optimal result would be as follows. Light shouldn't bleed into shadowed areas on the surface they are cast against nor should it bleed around corners. It should only bounce onto other surfaces: VoxelGIGlowingShadows_128VoxelRevised VoxelGIGlowingShadows_128VoxelRevised02

Steps to reproduce

Simply use VoxelGI with any dynamic light (directional, spot, omni) with shadows turned on.

Minimal reproduction project

VoxelGI_GlowingShadows.zip

Calinou commented 11 months ago

Given how VoxelGI works with a lot of approximations, this may not be entirely fixable.

Static geometry is baked so it could technically be possible to perform some kind of supersampling at bake time (at the cost of longer bake times), but we have few people knowledgeable with VoxelGI.

WickedInsignia commented 11 months ago

Yeah totally understandable. If there's any way for it to determine whether a surface/normal is where the direct light is hitting and bouncing from, there might be some way to tell it not to spread light further onto that surface and simply bounce it away. I expect preventing light bleeding around corners to be more tricky since you're working with a single voxel in that area, there's no way to create a sharp "corner." Either there's a line of light voxels in the shadow area, or a line of dark voxels in the light area.

Regardless I'm seeing it "radiate" light further around corners than it should. I don't see any reason (as an artist, not as a developer who deeply understands VoxelGI) why the slightly lighter voxels at the top edge of this building can't be as dark as the ones directly below them: BistroVoxel02 BistroVoxel01 BistroVoxel03

This also seems to be a situation of dark voxels inside the area that's being hit with light (the entire roof of that building) without negative effects. Again just an artist so I wouldn't be too surprised if I completely misunderstand what the limitations of improving this are.