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

Fix lightmap captures not applied in one octant #89281

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

permelin
Copy link
Contributor

@permelin permelin commented Mar 8, 2024

GI from probe captures was not applied to dynamic objects in the (-,-,-) octant of the lightmap. If the object had traveled from a different part of the lightmap, it would simply not update anymore and kept whatever ambient light it had from before. If the object on the other hand came from outside of the lightmap into this octant, it would receive no ambient light at all.

The same bug also caused incorrect blending when the object is inside several overlapping lightmaps.

The bug lies in a blending factor for overlapping lightmaps. This factor is mostly cancelled out when there is only a single lightmap, except that the captured light is not applied at all if the blend is not greater than zero. The calculation of blend did not account for inner_pos being in the [-1, 1] interval, which would cause blend to become negative.

GI from probe captures was not applied to dynamic objects in the (-,-,-)
octant of the lightmap. If the object had traveled from a different part
of the lightmap, it would simply not update anymore and kept whatever
ambient light it had from before. If the object on the other hand came
from outside of the lightmap into this octant, it would receive no
ambient light at all.
@permelin permelin requested a review from a team as a code owner March 8, 2024 12:11
@AThousandShips AThousandShips added this to the 4.3 milestone Mar 8, 2024
@jcostello
Copy link
Contributor

Nice, I think I saw that issue happening

@akien-mga akien-mga requested a review from DarioSamo March 8, 2024 21:45
Copy link
Contributor

@DarioSamo DarioSamo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. For the record I haven't actually modified the code relevant to this before so I could be wrong (I've modified the lightmap baker but not the part that uses the lightmap during rendering), but the math makes sense to me.

@akien-mga akien-mga merged commit 5c6614f into godotengine:master Mar 8, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@permelin permelin deleted the fix-lm-capture-octant branch March 19, 2024 18:23
@clayjohn clayjohn added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release topic:rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants