Skip to content

Fix light culling mask behavior in Mobile and Compat renderers#98266

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
franeaux:fix-light-visual-instance
Oct 24, 2024
Merged

Fix light culling mask behavior in Mobile and Compat renderers#98266
Repiteo merged 1 commit into
godotengine:masterfrom
franeaux:fix-light-visual-instance

Conversation

@franeaux

@franeaux franeaux commented Oct 17, 2024

Copy link
Copy Markdown
Contributor

Fixes #94643. Added logic which checks the light's culling mask settings before proceeding with lighting calculations to wherever not present (namely the Forward-Mobile and Compatibility renderers). Just a simple port of the one already used in the Forward-Plus renderer.

Pictures for comparison:

MRP: Compatibility:
bug-compat
Forward+:
bug-fplus
Forward-Mobile:
bug-mobilee
Fixed: Compatibility:
fix-compat
Forward+:
fix-fplus
Forward-Mobile:
fix-mobile

(Also fixes the bug in editor mode too)

@franeaux franeaux requested a review from a team as a code owner October 17, 2024 14:23
@AThousandShips AThousandShips added this to the 4.4 milestone Oct 17, 2024
@AThousandShips AThousandShips added cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release labels Oct 17, 2024

@Calinou Calinou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tested locally, it works as expected in Mobile and Compatibility.

However, the solution used in Mobile is probably not the correct one, as it'd leave performance on the table since lights would not be culled on the CPU before being sent to the GPU. See comments in #86105, as it's the same fix as applied there (except it's applied in two locations in that PR).

I suggest looking at moving the culling to the CPU side in Mobile, as is already done in Compatibility in your PR. If you can't find a way to do this, then I suggest removing the Mobile changes so the Compatibility changes can be merged first.

@franeaux

Copy link
Copy Markdown
Contributor Author

Oh I see! I'll look for a while and hope i find the correct fix but if not ill just do as you said and try again only with the compatibility fix. ty for the directions!

@clayjohn

Copy link
Copy Markdown
Member

I think in both cases the check should be inside of pair_light_instances() so that it is done at culling time and also you aren't pairing with lights that are masked out anyway.

@franeaux

franeaux commented Oct 19, 2024

Copy link
Copy Markdown
Contributor Author

(I really should have consulted this page again before making the changes, I think I added the culling logic for Mobile just before the pairing call but I'll revise it if need be.)

Shifted culling back to CPU so that the light instances indices wont be sent to the buffer at all. Also covers both spot and omni lights in Mobile now.

@franeaux franeaux requested a review from Calinou October 19, 2024 07:48

@Calinou Calinou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tested locally, it works as expected in Compatibility and Mobile.

This should be good to merge after squashing the 2 commits together; see PR workflow for instructions.

@franeaux franeaux force-pushed the fix-light-visual-instance branch from a8f304d to ac907f8 Compare October 22, 2024 17:35

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the light is already culled in _scene_cull() then this check is unnecessary right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. I skipped the check and it works just fine. (sry for that!)

@franeaux franeaux force-pushed the fix-light-visual-instance branch from ac907f8 to fcea158 Compare October 23, 2024 03:10

@clayjohn clayjohn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great now! Thank you for investigating further.

@clayjohn clayjohn removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Oct 23, 2024
@Repiteo Repiteo merged commit ba4e67e into godotengine:master Oct 24, 2024
@Repiteo

Repiteo commented Oct 24, 2024

Copy link
Copy Markdown
Contributor

Thanks!

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

Labels

bug cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release topic:rendering

Projects

None yet

5 participants