Skip to content

Gate LTC LUTs behind a feature and merge them to a texture array#24065

Merged
alice-i-cecile merged 11 commits intobevyengine:mainfrom
beicause:feature-gate-ltc
May 4, 2026
Merged

Gate LTC LUTs behind a feature and merge them to a texture array#24065
alice-i-cecile merged 11 commits intobevyengine:mainfrom
beicause:feature-gate-ltc

Conversation

@beicause
Copy link
Copy Markdown
Member

@beicause beicause commented May 2, 2026

Objective

Alternative to #24004.

#23288 adds ltc luts for rect light support which implicitly requires bevy_image/ktx2 and bevy_image/zstd otherwise loading ltc luts will panic.

We either accept to always enable area light supoort (#24004), or add a feature to opt out it (this PR).

Solution

Gate ltc luts behind a feature and merge them to a texture array.

Testing

rect_light example works.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-24065

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@beicause beicause force-pushed the feature-gate-ltc branch from 57c1f35 to 2a4bb58 Compare May 2, 2026 00:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-24065

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@kfc35 kfc35 added A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 2, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering May 2, 2026
@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented May 2, 2026

Please make sure the new lut passes ktx validate: #23900

@kfc35
Copy link
Copy Markdown
Contributor

kfc35 commented May 2, 2026

This PR makes progress on #23975, so I’ll add it to the milestone for expedited consideration

With this, the deferred_rendering example works for 1) Deferred and 2) Forward, but 3) Forward + Prepass doesn’t work. I’ll add more detail in the GH issue.

@kfc35 kfc35 added this to the 0.19 milestone May 2, 2026
@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented May 2, 2026

I like this more than the other PR.

Maybe we should rename the feature to "rect_lights" or something though? Idk

@beicause
Copy link
Copy Markdown
Member Author

beicause commented May 2, 2026

I like this more than the other PR.

Maybe we should rename the feature to "rect_lights" or something though? Idk

PointLight may use ltc luts too #23400

@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented May 2, 2026

Ahh right, nvm.

@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented May 2, 2026

How about "area_lights"?

@kfc35 kfc35 added the D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes label May 2, 2026
@beicause
Copy link
Copy Markdown
Member Author

beicause commented May 2, 2026

How about "area_lights"?

"area_lights" sounds like we should gate the RectLight code as well. How about "area_light_luts"?

@kfc35 kfc35 added D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels May 2, 2026
@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented May 2, 2026

"area_lights" sounds like we should gate the RectLight code as well

Why not do that? They need the LUTs to function, no?

@beicause
Copy link
Copy Markdown
Member Author

beicause commented May 2, 2026

"area_lights" sounds like we should gate the RectLight code as well

Why not do that? They need the LUTs to function, no?

I'm not sure about this, it would add complexity. We didn't do it for tonemapping_luts either.

Copy link
Copy Markdown
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

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

Checked out the branch and everything looks the same wrt RectLights. Did not find any issues in the code. As I have also mentioned, it also allows the deferred_rendering example to run too!

I just have a (long) non-blocking comment about requiring the feature for the testbed.

Comment thread crates/bevy_internal/Cargo.toml Outdated
Comment thread _release-content/release-notes/area_lights.md Outdated
Comment thread crates/bevy_pbr/src/lib.rs Outdated
Comment thread Cargo.toml Outdated
Comment thread Cargo.toml
name = "testbed_3d"
path = "examples/testbed/3d.rs"
doc-scrape-examples = true
required-features = ["area_light_luts"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

non-blocking comment: I know that I recently added a rect_light to the lights scene, but I don’t know if this should necessarily be added as a required feature in Cargo.toml, similar to how the ui testbed doesnt require the debug ui feature flag. The ui testbed doesn’t insert the debug outline scene if the feature isn’t enabled. Perhaps something similar should be done for the 3d testbed? It’ll allow the 3d testbed to keep growing in feature complexity without needing to specify a growing list of required flags.

A related question is, do we expect the app to fail loudly if the app creator adds a RectLight, but did not enable the associated feature? If the answer is no, then I think I wouldn’t require the feature here. I also then wouldn’t do any feature gating of the RectLight in the testbed so that case could theoretically be tested.

I agree that it should be added in example-run.yml though, which you have done. I also would still require it for the rect_light example as well

beicause and others added 2 commits May 2, 2026 23:40
Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented May 3, 2026

One comment: Is there somewhere we can error_once! log if area lights are used without the feature being enabled?

@JMS55 JMS55 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 3, 2026
@alice-i-cecile
Copy link
Copy Markdown
Member

One comment: Is there somewhere we can error_once! log if area lights are used without the feature being enabled?

Blocking on this :) Looks good otherwise.

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels May 3, 2026
kfc35 added a commit to kfc35/bevy that referenced this pull request May 4, 2026
…s to `DownlevelFlags(INDEPENDENT_BLEND)` (bevyengine#24067)

# Objective

- Help out with bevyengine#23975 
- Fixes an issue on WebGL2 as a result of bevyengine#23629
- Supporting bevyengine#23975 on WebGL2 necessitates fixing the “Forward +
Prepass” option on the `deferred_rendering` example. The WebGPU focused
solution to bevyengine#23629 requires this PR to also allow the “Forward +
Prepass” option to work.

## Solution

- @beicause mentioned gating the whole pipeline of
`background_motion_vectors.rs` to `DownlevelFlags(INDEPENDENT_BLEND)` as
implied in the error message in [this issue
comment](bevyengine#23975 (comment)).
It works!

## Testing

- Included the change from this PR on top of bevyengine#24065, and it fixes the
`deferred_rendering` example on WebGL2.
@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented May 4, 2026

Use error_once!().

@beicause
Copy link
Copy Markdown
Member Author

beicause commented May 4, 2026

The code later in this file also uses Local<bool>, I think it's slightly faster than once.

Users can potentially insert in their own AreaLightLuts (though it's uncommon).

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels May 4, 2026
@alice-i-cecile alice-i-cecile enabled auto-merge May 4, 2026 03:41
@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 4, 2026
Merged via the queue into bevyengine:main with commit 0ff7c35 May 4, 2026
44 checks passed
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in Rendering May 4, 2026
cart pushed a commit to chronicl/bevy that referenced this pull request May 4, 2026
…yengine#24065)

# Objective

Alternative to bevyengine#24004.

bevyengine#23288 adds ltc luts for rect
light support which implicitly requires `bevy_image/ktx2` and
`bevy_image/zstd` otherwise loading ltc luts will panic.

We either accept to always enable area light supoort (bevyengine#24004), or add a
feature to opt out it (this PR).

## Solution

Gate ltc luts behind a feature and merge them to a texture array.

## Testing

`rect_light` example works.

---------

Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants