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

[Merged by Bors] - bevy_gltf: Add support for loading lights #3506

Closed
wants to merge 3 commits into from

Conversation

superdump
Copy link
Contributor

Objective

  • Add support for loading lights from glTF 2.0 files

Solution

  • This adds support for the KHR_punctual_lights extension which supports point, directional, and spot lights, though we don't yet support spot lights.
  • Inserting light bundles when creating scenes required registering some more light bundle component types.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Dec 31, 2021
@mockersf mockersf added A-Assets Load files from disk to use for things like images, models, and sounds C-Feature A new feature, making something new possible and removed S-Needs-Triage This issue needs to be labelled labels Dec 31, 2021
@superdump
Copy link
Contributor Author

When the range is not specified, gltf says it should be infinite. I think that is a bad idea and would instead like to implement an intensity threshold mechanism where the range is calculated as sqrt(intensity / intensity threshold) considering the light intensity falloff is as 1 / distance^2. I’d like to test this idea a little bit to get something that works well in practice and I want to do this for all point lights anyway to limit their range for clustering.

@superdump
Copy link
Contributor Author

I've now done a bunch of testing of point lights of different intensities and calculating the range of the light based on an illuminance threshold and I empirically landed on a threshold of 0.1 lumens / m^2 which was the same value as aclysma found to be safe in their experiments for rafx. I thought a higher value was going to be safe but then I tried a dimmer light and 0.1 was needed. Note that I did this testing using my https://github.com/superdump/bevy/tree/point-light-range-example branch and also having removed the additional attenuation term (saturate(1.0 - distance^4 / range ^ 4)^2) in pbr.wgsl, which is meant to allow for a smooth-looking falloff with a light range configured smaller than the physical falloff range.

I'll probably go through and retest some examples now to see if this makes the cluster stuff explode, and if so, manually limit the range of lights in those examples, commenting why.

I also fixed up some documentation.

superdump and others added 3 commits January 1, 2022 17:39
This adds support for the KHR_punctual_lights extension which supports point,
directional, and spot lights, though we don't yet support spot lights.

Inserting light bundles when creating scenes required registering some more
light bundle component types.
Radius is the size of the inside of the light and defaults to 0 in bevy. It is unspecified in gltf.

Co-authored-by: François <[email protected]>
@superdump
Copy link
Contributor Author

This got a little bigger than I was expecting so I'll move the light range stuff out into a separate PR and return this one back to being just about loading lights from gltf.

@superdump
Copy link
Contributor Author

This got a little bigger than I was expecting so I'll move the light range stuff out into a separate PR and return this one back to being just about loading lights from gltf.

I've now removed the lighting calculation stuff from this PR so this is just loading lights from gltf.

@cart
Copy link
Member

cart commented Jan 3, 2022

Looks good to me!

@cart
Copy link
Member

cart commented Jan 3, 2022

bors r+

bors bot pushed a commit that referenced this pull request Jan 3, 2022
# Objective

- Add support for loading lights from glTF 2.0 files

## Solution

- This adds support for the KHR_punctual_lights extension which supports point, directional, and spot lights, though we don't yet support spot lights.
- Inserting light bundles when creating scenes required registering some more light bundle component types.
bors bot pushed a commit that referenced this pull request Jan 3, 2022
# Objective

- Add support for loading lights from glTF 2.0 files

## Solution

- This adds support for the KHR_punctual_lights extension which supports point, directional, and spot lights, though we don't yet support spot lights.
- Inserting light bundles when creating scenes required registering some more light bundle component types.
@mockersf
Copy link
Member

mockersf commented Jan 3, 2022

bors retry

bors bot pushed a commit that referenced this pull request Jan 3, 2022
# Objective

- Add support for loading lights from glTF 2.0 files

## Solution

- This adds support for the KHR_punctual_lights extension which supports point, directional, and spot lights, though we don't yet support spot lights.
- Inserting light bundles when creating scenes required registering some more light bundle component types.
@bors bors bot changed the title bevy_gltf: Add support for loading lights [Merged by Bors] - bevy_gltf: Add support for loading lights Jan 3, 2022
@bors bors bot closed this Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants