Skip to content

Implement DirectionalLight3D cull masks in Compatibility #107384

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

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

Conversation

Kaleb-Reid
Copy link
Contributor

This allows for using cull masks with DirectionalLight3Ds in the Compatibility renderer.

image

I'm mostly certain that they were not implemented before, I spent a bit of time looking for why they stopped working but I think it's because they never did.

I'm not sure what the optimal way is or if I'm missing anything so I encourage feedback.

Fixes #103595

@Kaleb-Reid Kaleb-Reid requested a review from a team as a code owner June 10, 2025 23:12
@Kaleb-Reid Kaleb-Reid force-pushed the compat-directional-cull-mask branch from 2067153 to f14573b Compare June 10, 2025 23:22
@Kaleb-Reid Kaleb-Reid marked this pull request as draft June 10, 2025 23:26
@Kaleb-Reid
Copy link
Contributor Author

Kaleb-Reid commented Jun 10, 2025

I just realized that this breaks using multiple directional lights so I'm looking into it
Fixed it, just learned about uniform block alignment.

image

@Kaleb-Reid Kaleb-Reid force-pushed the compat-directional-cull-mask branch from f14573b to 90e8534 Compare June 11, 2025 00:53
@Kaleb-Reid Kaleb-Reid marked this pull request as ready for review June 11, 2025 00:53
@Kaleb-Reid
Copy link
Contributor Author

Kaleb-Reid commented Jun 11, 2025

Noticed that turning on shadows on the light puts the light through the lightmap therefore ignoring the check added by this pr. Will be looking into that.
Should be fixed now.
image

@Calinou
Copy link
Member

Calinou commented Jun 11, 2025

Noticed that turning on shadows on the light puts the light through the lightmap therefore ignoring the check added by this pr. Will be looking into that.

Lights with shadows enabled in Compatibility are rendered in a separate pass, as described in Internal rendering architecture.

@Kaleb-Reid Kaleb-Reid force-pushed the compat-directional-cull-mask branch from 90e8534 to 1e7ae93 Compare June 11, 2025 21:38
@Kaleb-Reid Kaleb-Reid marked this pull request as ready for review June 11, 2025 21:38
@Kaleb-Reid Kaleb-Reid force-pushed the compat-directional-cull-mask branch 4 times, most recently from 22328dd to 1585c42 Compare June 11, 2025 21:47
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally, it mostly works as expected (both with shadows enabled and disabled).

Testing project: test_pr_107384.zip

Preview

Forward+ Mobile Compatibility
Image Image Image

One issue I encountered while testing is that I've had a situation where it looked like this in Compatibility (each screenshot taken in a different session):

Image Image
Image Image

It seems to sporadically occur on startup, and is possibly due to uninitialized memory somewhere (which leads to undefined behavior). I've also had one situation where it appeared to render correctly, but part of the sky was pure black. This doesn't occur on master.

A quick way to test is to use Debug > Customize Run Instances..., enable multiple instances and increase the instance count to a value your PC can handle (up to 20).

@Kaleb-Reid Kaleb-Reid force-pushed the compat-directional-cull-mask branch from 1585c42 to 0c88c44 Compare July 1, 2025 02:01
@Kaleb-Reid
Copy link
Contributor Author

@Calinou I'm unable to reproduce this (maybe different graphics driver?), but I have a guess as to why it was doing that and have just pushed what is hopefully the fix.

@Kaleb-Reid Kaleb-Reid requested a review from Calinou July 1, 2025 02:02
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

The issue I reported above appears to be fixed now (tested over 20 launches in Compatibility).

@BossMaink
Copy link

This change appears to cause semi‑transparent objects to no longer be influenced by directional light, even if ALPHA is 1.
image
image
image

different appearance on master
image

@Kaleb-Reid Kaleb-Reid force-pushed the compat-directional-cull-mask branch from 0c88c44 to a8bd26d Compare July 6, 2025 23:08
@Kaleb-Reid
Copy link
Contributor Author

@BossMaink Should be fixed now, I forgot to send in the layer mask for the transparent pass so it was always 0.

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.

Compatibility: Cull Mask on DirectionalLight3D doesn't work
4 participants