bevy/crates
Hexroll by Pen, Dice & Paper 222483daaa
Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090)
# Objective

Order independent transparency can filter fragment writes based on the
alpha value and it is currently hard-coded to anything higher than 0.0.
By making that value configurable, users can optimize fragment writes,
potentially reducing the number of layers needed and improving
performance in favor of some transparency quality.

## Solution

This PR adds `alpha_threshold` to the
OrderIndependentTransparencySettings component and uses the struct to
configure a corresponding shader uniform. This uniform is then used
instead of the hard-coded value.

To configure OIT with a custom alpha threshold, use:

```rust
fn setup(mut commands: Commands) {
    commands.spawn((
        Camera3d::default(),
        OrderIndependentTransparencySettings {
            layer_count: 8,
            alpha_threshold: 0.2,
        },
    ));
}
```

## Testing

I tested this change using the included OIT example, as well as with two
additional projects.

## Migration Guide

If you previously explicitly initialized
OrderIndependentTransparencySettings with your own `layer_count`, you
will now have to add either a `..default()` statement or an explicit
`alpha_threshold` value:

```rust
fn setup(mut commands: Commands) {
    commands.spawn((
        Camera3d::default(),
        OrderIndependentTransparencySettings {
            layer_count: 16,
            ..default()
        },
    ));
}
```

---------

Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
2024-10-27 21:18:19 +01:00
..
bevy_a11y Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_animation Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_app Fix bevy_picking plugin suffixes (#16082) 2024-10-27 21:17:18 +01:00
bevy_asset Add AsyncSeekForwardExt trait to allows a similar API to the previous Bevy version (#16027) 2024-10-27 21:17:18 +01:00
bevy_audio Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_color Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_core Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_core_pipeline Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090) 2024-10-27 21:18:19 +01:00
bevy_derive Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_dev_tools fix bevy_dev_tools build (#16099) 2024-10-27 21:18:08 +01:00
bevy_diagnostic Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_dylib Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_ecs More #[doc(fake_variadic)] goodness (#16108) 2024-10-27 21:18:18 +01:00
bevy_encase_derive Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_gilrs Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_gizmos Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_gltf Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_hierarchy Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_image Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_input Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_internal Fix bevy_picking plugin suffixes (#16082) 2024-10-27 21:17:18 +01:00
bevy_log Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_macro_utils Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_math Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_mesh Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_mikktspace Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_pbr Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090) 2024-10-27 21:18:19 +01:00
bevy_picking Emit picking event streams (#16105) 2024-10-27 21:18:18 +01:00
bevy_ptr Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_reflect Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_remote Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_render More #[doc(fake_variadic)] goodness (#16108) 2024-10-27 21:18:18 +01:00
bevy_scene Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_sprite Fix bevy_picking plugin suffixes (#16082) 2024-10-27 21:17:18 +01:00
bevy_state Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_tasks Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_text Use CosmicFontSystem in public bevy_text APIs and remove cosmic_text re-export (#16063) 2024-10-24 23:33:23 +02:00
bevy_time Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_transform Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_ui Fix bevy_picking plugin suffixes (#16082) 2024-10-27 21:17:18 +01:00
bevy_utils More #[doc(fake_variadic)] goodness (#16108) 2024-10-27 21:18:18 +01:00
bevy_window Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00
bevy_winit Release 0.15.0-rc.1 2024-10-22 22:44:41 +02:00