Skip to content

Conversation

hukasu
Copy link
Contributor

@hukasu hukasu commented Sep 7, 2025

Objective

Fixes #20690

Solution

Have a different default for Tonemapping when tonemapping_luts is on and when it is off, and lock TonyMcMapface, BlenderFilmic and AgX behind feature

Testing

cargo run -p ci

@hukasu hukasu added A-Rendering Drawing game state to the screen M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 7, 2025
Copy link
Contributor

github-actions bot commented Sep 7, 2025

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

@hukasu hukasu changed the title Tonemapping off Change defaults for Tonemapping based on tonemapping_luts feature Sep 7, 2025
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Good strategy, but please note the defaults in the docs.

@hukasu
Copy link
Contributor Author

hukasu commented Sep 7, 2025

@alice-i-cecile should None be used as the default for when tonemapping_luts is off? there are a few modes that are still available with it off

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Sep 7, 2025

Yes, I think so?

@DGriffin91
Copy link
Contributor

I think this makes sense as long as the tonemapping_luts feature is on by default.

Is this supposed to work in this pr?
cargo run --example tonemapping --no-default-features --features bevy_winit,bevy_pbr

I get a bunch of errors like

     | |_- associated item `TONEMAP_METHOD_TONY_MC_MAPFACE` not found for this struct
...
2503 |               } else if method == MeshPipelineKey::TONEMAP_METHOD_TONY_MC_MAPFACE {
     |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated item not found in `MeshPipelineKey`

Comment on lines 2109 to 2116
const TONEMAP_METHOD_ACES_FITTED = 3 << Self::TONEMAP_METHOD_SHIFT_BITS;
#[cfg(feature = "tonemapping_luts")]
const TONEMAP_METHOD_AGX = 4 << Self::TONEMAP_METHOD_SHIFT_BITS;
const TONEMAP_METHOD_SOMEWHAT_BORING_DISPLAY_TRANSFORM = 5 << Self::TONEMAP_METHOD_SHIFT_BITS;
#[cfg(feature = "tonemapping_luts")]
const TONEMAP_METHOD_TONY_MC_MAPFACE = 6 << Self::TONEMAP_METHOD_SHIFT_BITS;
#[cfg(feature = "tonemapping_luts")]
const TONEMAP_METHOD_BLENDER_FILMIC = 7 << Self::TONEMAP_METHOD_SHIFT_BITS;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this MeshPipelineKeys be gated?

@DGriffin91

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 am moving forwards with the asumption that yes

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not really sure of all the implications. Who/what all might depend on them existing. I would guess if they have the feature disabled they're being conscious about things like this missing. Not sure how it would affect plugins that expect them to be there or something. Might be better to resolve at runtime.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would at least be nice to use #[doc(cfg)] to make the fact that these are gated behind a feature apparent on docs.rs

@hukasu
Copy link
Contributor Author

hukasu commented Sep 7, 2025

There are still some examples that use Tonemapping but i don't know if i should add tonemapping_luts to ALL of them

@@ -111,13 +109,18 @@ pub struct TonemappingPipeline {
}

/// Optionally enables a tonemapping shader that attempts to map linear input stimulus into a perceptually uniform image for a given [`Camera`] entity.
///
/// The default when `tonemapping_luts` is enabled is `TonyMcMapface`, otherwise it is `None`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use ReinhardLuminance when the LUT feature is disabled? At least you then get some sort of tonemapping.

Copy link
Member

Choose a reason for hiding this comment

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

Tonemapping can be very distressing for pixel artists: will this affect 2D workflows?

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better that it's off so it's obvious that it's off.

Copy link
Contributor

Choose a reason for hiding this comment

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

After thinking about this more I wonder if it's better for it to remain pink as it is in bevy main so it's blatantly obvious (along with the existing error message) that tonemapping is missing, requiring the user to resolve it.

@DGriffin91
Copy link
Contributor

I'm wonder if using a feature to disable these in this way is a good fit. They are more of an asset and that kind of thing should generally be dealt with at run time. When there's an editor I would assume the situation around this kind of thing will have more clarity. I see the existing feature says:

Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the Tonemapping method for your Camera2d or Camera3d.

Would it work to only disable tonemapping on the camera if this feature is not set and not change anything else? Or maybe we shouldn't manipulate their component and just take a path further down the line that has no tonemapping. The comment for the feature being what it is implies there was a desire for this situation to be unavoidably obvious to the user and require them to explicitly resolve it (by changing the Tonemapping method Camera2d or Camera3d).
Having everything pink and an error stating the cause (as in current bevy main) seems to accomplish this well. Maybe the message could be updated to include something about seeing only pink.

@hukasu
Copy link
Contributor Author

hukasu commented Sep 8, 2025

Would it work to only disable tonemapping on the camera if this feature is not set and not change anything else?

tonemapping_luts is only required for 3 of the tonemapping methods, all others work without LUTS

@hukasu hukasu added the X-Controversial There is active debate or serious implications around merging this PR label Sep 8, 2025
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 M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Controversial There is active debate or serious implications around merging this PR
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Base Color StandardMaterial dosn't work if default-features = false
5 participants