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

LightmapGI Directional results in more aliased shadows for lights with Static bake mode #88470

Closed
Tracked by #56033
WickedInsignia opened this issue Feb 18, 2024 · 8 comments · Fixed by #95888
Closed
Tracked by #56033

Comments

@WickedInsignia
Copy link

Tested versions

4.3 Dev3

System information

Windows 11, Nvidia RTX4070ti, AMD Ryzen7700x

Issue description

Activating Directional in LightmapGI disables Bicubic Interpolation.

Directional on:
GodotDirectionalOnBicubic

Directional off:
GodotDirectionalOffBicubic

Steps to reproduce

Turn on Directional in Lightmap GI.

Minimal reproduction project (MRP)

Not needed. Just turn the setting on in any scene.

@Calinou
Copy link
Member

Calinou commented Feb 18, 2024

There's no bicubic interpolation to disable because it hasn't been reimplemented in 4.x yet 🙂

What you're pointing out is likely the DirectionalLight Angular Distance property not being taken into account when baking directional lightmaps (or its Blur multiplier). It could also be due to the lightmap baking causing aliasing on its own when Directional is enabled, even if angular distance is being taken into account.

@Calinou
Copy link
Member

Calinou commented Jul 11, 2024

I can confirm this on 4.3.beta 92c8e87. This is not a tonemapping issue: it stays regardless of which tonemapper is used, and is present in all rendering methods. It also occurs even if the light's Angular Distance is 0.0.

The issue does not go away when using darker materials (which rules out a clamping/overexposure issue) and is present with all light types, not just DirectionalLight3D.

Minimal reproduction project: test_lightmap_directional_shadow_aliasing.zip
Remember to bake lightmaps after loading the scene.

Directional disabled Directional enabled
image image

@Calinou Calinou changed the title Lightmap Directional Disables Bicubic Interpolation LightmapGI Directional results in more aliased shadows for lights with Static bake mode Jul 11, 2024
@clayjohn
Copy link
Member

I just took a look at this, it appears that the issue is the denoiser isn't smoothing out the aliasing as much when using the directional mode.

They look the same with denoising turned off. This should be an easy fix.

Additionally, it looks way better with #95828 and #89919

@clayjohn
Copy link
Member

Turns out it is not an easy fix. I still can't find why its not working. However, I can confirm that the problem is only with the JNLM denoiser, using OIDN works fine

@Calinou
Copy link
Member

Calinou commented Aug 20, 2024

Turns out it is not an easy fix. I still can't find why its not working.

Directional lightmaps seem to work with bicubic sampling in master and with #95828: #95828 (review)

I'm not sure if JNLM is really able to smooth out shadows. It's intended to do denoising only after all, so any shadow smoothing is more of a byproduct than an intended consequence. Shadows on directional lightmaps seem to look smooth enough already with bicubic sampling and direct light antialiasing, even without any denoiser in place. This seems like a good thing to me, since I expect shadows to always be smooth regardless of the denoiser in use.

@clayjohn
Copy link
Member

I think I've figured out the root cause of this issue, it has to do with how we scale the spherical harmonics. We are baking the directional lightmaps way too bright and then scaling back at run time. I'm trying to figure out the proper scaling factors now.

This will impact the work that @BlueCube3310 is doing on scaling the L1 spherical harmonics for compression

@Calinou
Copy link
Member

Calinou commented Aug 20, 2024

We are baking the directional lightmaps way too bright and then scaling back at run time.

Yes, I remember discussing this in #61910. It turns out what I was doing was actually wrong (which was our initial guess).

@clayjohn
Copy link
Member

Using the coefficients from https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/gdc2018-precomputedgiobalilluminationinfrostbite.pdf we can get things to look the same between directional and non-directional!

Before directional Before non-directional After directional After directional (no normal map)
Screenshot from 2024-08-20 16-41-12 Screenshot from 2024-08-20 16-37-18 Screenshot from 2024-08-20 16-40-20 image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants