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

Log a warning when the tonemapping_luts feature is disabled but required for the selected tonemapper. #10253

Merged
merged 6 commits into from
Oct 27, 2023

Conversation

Elabajaba
Copy link
Contributor

@Elabajaba Elabajaba commented Oct 25, 2023

Objective

Make it obvious why stuff renders pink when rendering stuff with bevy with default_features = false and bevy's default tonemapper (TonyMcMapFace, it requires a LUT which requires the tonemapping_luts, ktx2, and zstd features).

Not sure if this should be considered as fixing these issues, but in my previous PR (#9073, and old discussions on discord that I only somewhat remember) it seemed like we didn't want to make ktx2 and zstd required features for bevy_core_pipeline.

Related #9179
Related #9098

Solution

This logs an error when a LUT based tonemapper is used without the tonemapping_luts feature enabled, and cleans up the default features a bit (tonemapping_luts now includes the ktx2 and zstd features, since it panics without them).

Another solution would be to fall back to a non-lut based tonemapper, but I don't like this solution as then it's not explicitly clear to users why eg. a library example renders differently than a normal bevy app (if the library forgot the tonemapping_luts feature).

I did remove the ktx2 and zstd features from the list of default features in Cargo.toml, as I don't believe anything else currently in bevy relies on them (or at least searching through every hit for ktx2 and zstd didn't show anything except loading an environment map in some examples), and they still show up in the cargo_features doc as default features.


Changelog

  • The tonemapping_luts feature now includes both the ktx2 and zstd features to avoid a panic when the tonemapping_luts feature was enable without both the ktx2 and zstd feature enabled.

@JMS55 JMS55 added this to the 0.12 milestone Oct 25, 2023
@github-actions
Copy link
Contributor

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

match key.tonemapping {
Tonemapping::None => shader_defs.push("TONEMAP_METHOD_NONE".into()),
Tonemapping::Reinhard => shader_defs.push("TONEMAP_METHOD_REINHARD".into()),
Tonemapping::ReinhardLuminance => {
shader_defs.push("TONEMAP_METHOD_REINHARD_LUMINANCE".into());
}
Tonemapping::AcesFitted => shader_defs.push("TONEMAP_METHOD_ACES_FITTED".into()),
Tonemapping::AgX => shader_defs.push("TONEMAP_METHOD_AGX".into()),
Tonemapping::AgX => {
#[cfg(not(feature = "tonemapping_luts"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why warn instead of gating the actual enum variants behind the flag? That way we'd make the invalid states not representable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather not change the default tonemapper depending on what features are enabled, and this avoids users wondering why their bevy library or game (with default features disabled) looks different than everyone else's.

# Include tonemapping Look Up Tables KTX2 files
tonemapping_luts = ["bevy_internal/tonemapping_luts"]
# Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`.
tonemapping_luts = ["bevy_internal/tonemapping_luts", "ktx2", "zstd"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit ugly (since tonemapping_luts already depends on them in bevy_core_pipeline's cargo.toml), but stops the ktx2 and zstd features from appearing as optional features in the cargo_features doc when they're already enabled.

@Elabajaba Elabajaba marked this pull request as ready for review October 25, 2023 18:57
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Oct 26, 2023
@alice-i-cecile
Copy link
Member

[7:03 PM]Jasmine: I'm good with it, but small nit "tonemapping method" -> actual component name in the error message.

Agreed on both counts :)

@cart cart added this pull request to the merge queue Oct 27, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 27, 2023
@alice-i-cecile alice-i-cecile removed this pull request from the merge queue due to a manual request Oct 27, 2023
@alice-i-cecile
Copy link
Member

Waiting on some final tweaks that the author wanted to add :)

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 27, 2023
Merged via the queue into bevyengine:main with commit 65b3ff1 Oct 27, 2023
25 checks passed
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
…uired for the selected tonemapper. (bevyengine#10253)

# Objective

Make it obvious why stuff renders pink when rendering stuff with bevy
with `default_features = false` and bevy's default tonemapper
(TonyMcMapFace, it requires a LUT which requires the `tonemapping_luts`,
`ktx2`, and `zstd` features).

Not sure if this should be considered as fixing these issues, but in my
previous PR (bevyengine#9073, and old
discussions on discord that I only somewhat remember) it seemed like we
didn't want to make ktx2 and zstd required features for
bevy_core_pipeline.

Related bevyengine#9179
Related bevyengine#9098

## Solution

This logs an error when a LUT based tonemapper is used without the
`tonemapping_luts` feature enabled, and cleans up the default features a
bit (`tonemapping_luts` now includes the `ktx2` and `zstd` features,
since it panics without them).

Another solution would be to fall back to a non-lut based tonemapper,
but I don't like this solution as then it's not explicitly clear to
users why eg. a library example renders differently than a normal bevy
app (if the library forgot the `tonemapping_luts` feature).

I did remove the `ktx2` and `zstd` features from the list of default
features in Cargo.toml, as I don't believe anything else currently in
bevy relies on them (or at least searching through every hit for `ktx2`
and `zstd` didn't show anything except loading an environment map in
some examples), and they still show up in the `cargo_features` doc as
default features.

---

## Changelog

- The `tonemapping_luts` feature now includes both the `ktx2` and `zstd`
features to avoid a panic when the `tonemapping_luts` feature was enable
without both the `ktx2` and `zstd` feature enabled.
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
…uired for the selected tonemapper. (bevyengine#10253)

# Objective

Make it obvious why stuff renders pink when rendering stuff with bevy
with `default_features = false` and bevy's default tonemapper
(TonyMcMapFace, it requires a LUT which requires the `tonemapping_luts`,
`ktx2`, and `zstd` features).

Not sure if this should be considered as fixing these issues, but in my
previous PR (bevyengine#9073, and old
discussions on discord that I only somewhat remember) it seemed like we
didn't want to make ktx2 and zstd required features for
bevy_core_pipeline.

Related bevyengine#9179
Related bevyengine#9098

## Solution

This logs an error when a LUT based tonemapper is used without the
`tonemapping_luts` feature enabled, and cleans up the default features a
bit (`tonemapping_luts` now includes the `ktx2` and `zstd` features,
since it panics without them).

Another solution would be to fall back to a non-lut based tonemapper,
but I don't like this solution as then it's not explicitly clear to
users why eg. a library example renders differently than a normal bevy
app (if the library forgot the `tonemapping_luts` feature).

I did remove the `ktx2` and `zstd` features from the list of default
features in Cargo.toml, as I don't believe anything else currently in
bevy relies on them (or at least searching through every hit for `ktx2`
and `zstd` didn't show anything except loading an environment map in
some examples), and they still show up in the `cargo_features` doc as
default features.

---

## Changelog

- The `tonemapping_luts` feature now includes both the `ktx2` and `zstd`
features to avoid a panic when the `tonemapping_luts` feature was enable
without both the `ktx2` and `zstd` feature enabled.
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 C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants