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: Use Geomerics technique for retrieving irradiance from SH #101141

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BlueCube3310
Copy link
Contributor

Changes the way directional lightmaps are calculated by using the technique described in https://web.archive.org/web/20160313132301/http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf

This implementation is based on https://github.com/kayru/Probulator/blob/4a97a2b021eb2ca7ef696f4ddf36ba9a9432cbb6/Source/Probulator/SphericalHarmonics.h#L136-L151

Calculating SH lighting this way has several benefits, namely it avoids overdarkening caused by the resulting irradiance being negative, as well as enhances the contrast in the colors.

Results:

Before After
old geo_good

Issues:
The contrast seems too high, probably due to incompatibility in the coefficients,
Dimly lit or completely occluded areas exhibit significant artifacting:
geo_bad
geo_bad2

TODO:

  • Fix the aforementioned issues,
  • Implement for Mobile and Compatibility,
  • Optimize the code with glsl magic

@BlueCube3310 BlueCube3310 added this to the 4.x milestone Jan 4, 2025
@BlueCube3310 BlueCube3310 changed the title LightmapGI: Use Geometrics technique for retrieving irradiance from SH LightmapGI: Use Geomerics technique for retrieving irradiance from SH Jan 4, 2025
@Calinou
Copy link
Member

Calinou commented Jan 6, 2025

I wonder if this technique would make it easier to implement specular lobes for directional lightmaps, as I mentioned in #63016 (comment).

@Calinou
Copy link
Member

Calinou commented Jan 30, 2025

Testing this PR rebased on top of master 9ee1873, using the MRP from #96114 (review):

Edit (2025-02-10): Updated screenshots to fix overly saturated lightmap colors since #102203 was fixed.

Before

image

After

image

The directional aspect looks much closer to real-time lighting now 🙂

This appears to work well to address #102300 too, seeing the directional lightmap's brightness now better matches the non-directional one.

@jcostello
Copy link
Contributor

Does this fix or improve this? #63016

@Calinou
Copy link
Member

Calinou commented Jan 30, 2025

Does this fix or improve this? #63016

No, this should be implemented separately. I've attempted to implement this in a branch but didn't get it working correctly yet: https://github.com/Calinou/godot/tree/lightmapgi-directional-draw-direct-specular-lobes

@jcostello
Copy link
Contributor

After

Screenshot_20250130_185123 png webp

In the after, some areas look darker that in the before or the non-directional

@Calinou
Copy link
Member

Calinou commented Feb 10, 2025

In the after, some areas look darker that in the before or the non-directional

I've updated screenshots to match master (and this PR rebased on master) and the issue appears to be gone now, unless you were referring to something else.

@jcostello
Copy link
Contributor

jcostello commented Feb 11, 2025

@Calinou are you sure you updated the images? I still see the issue in your images.

image

In the static directional, you can see the bottom of the image darker than the non-directional or the real time. I think this issue was fix on master with #102424
This is why I'm asking if you updated the images.

The image in that PR doesn't exhibit the darker area in the directional static

image

@Calinou
Copy link
Member

Calinou commented Feb 11, 2025

@Calinou are you sure you updated the images? I still see the issue in your images.

Yes, check the comment's edit history (in the top-right corner of the comment) to see the previous images. They were oversaturated, but the new ones aren't.

However, I initially didn't understand what you were pointing. I didn't notice the darkening in the middle of the image.

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

Successfully merging this pull request may close these issues.

3 participants