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

LightManager.Builder.castLight=false not disabling emitted light #8427

Open
kaisermittenburg opened this issue Feb 9, 2025 · 4 comments
Open

Comments

@kaisermittenburg
Copy link

⚠️ Issues not using this template will be systematically closed.

Describe the bug
LightManager.Builder.castLight functionally does nothing as far as I can tell. I've tried this with DIRECTIONAL, POINT, and SUN lights.

To Reproduce
Steps to reproduce the behavior:

  1. Use LightManager.Builder to build a DIRECTIONAL light.
  2. Ensure that you specify castShadows(true)
  3. Ensure that you specify castLight(false) on the builder
  4. (optional) Set the light intensity to something obscene; something that would be noticeable if it were emitting light.
  5. Add the light to the scene, etc...

Expected behavior
As the code documentation suggests, I expect to see shadows, but no light emitted.
"In some situations it can be useful to have a light in the scene that doesn't actually emit light, but does cast shadows."

Smartphone (please complete the following information):

  • Device: Samsung Galaxy Tab S8+ (tablet)
  • OS: Android 14.0

Additional context
This can also be seen on an emulated Android 14 device in Android Studio with an OpenGL pipeline on a RTX 2080

@kaisermittenburg
Copy link
Author

Minor correction: setting castLight to false DOES appear to fully disable lighting for some light types (point light), but does not show shadows as the documentation suggests. For the directional light type, setting the bool doesn't appear to affect anything.

@romainguy
Copy link
Collaborator

romainguy commented Feb 10, 2025

If castLight is set to false, shadows can't appear automatically as they are are an absence of light. If you want a non-light casting light to cast shadows, you need to use the shadowMultiplier feature: https://google.github.io/filament/Materials.md.html#materialdefinitions/materialblock/lighting:shadowmultiplier

Directional lights are always assumed to be visible (ie castLight doesn't affect them)

@pixelflinger We should apply this feature to directional lights or have the docs explain what's going on

@pixelflinger
Copy link
Collaborator

Yes, a light doesn't cast shadows... It casts light, except where there is an object that blocks it out -- it's the object that casts shadows.

If a light doesn't produce light, it cannot be blocked by an object; everything is in shadow in the first place.

As Romain suggested you can use a shadow multiplier to artificially darken an area, but that's not PBR anymore at this point.

The problem with the directional light is probably an oversight, I will take a look.

@kaisermittenburg
Copy link
Author

Thank you for the explanation - that makes sense, I was curious how a shadow could exist without there being light to occlude. I think the wording of the code comment for castLight is a little confusing in this regard.

Thanks for the quick response. I look forward to working with Filament more.

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

No branches or pull requests

3 participants