Skip to content

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

Open
beicause wants to merge 9 commits intobevyengine:mainfrom
beicause:feature-gate-ltc
Open

Gate LTC LUTs behind a feature and merge them to a texture array#24065
beicause wants to merge 9 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
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: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

3 participants