bevy/crates/bevy_core_pipeline/src
Hexroll by Pen, Dice & Paper d01db9b672
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 19:08:34 +00:00
..
auto_exposure Implement WorldQuery for MainWorld and RenderWorld components (#15745) 2024-10-13 20:58:46 +00:00
blit Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
bloom fix: Skip some rendering logics when the viewport width or height is zero (#15654) 2024-10-08 22:52:19 +00:00
contrast_adaptive_sharpening Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
core_2d Implement WorldQuery for MainWorld and RenderWorld components (#15745) 2024-10-13 20:58:46 +00:00
core_3d Implement WorldQuery for MainWorld and RenderWorld components (#15745) 2024-10-13 20:58:46 +00:00
deferred Type safe retained render world (#15756) 2024-10-10 18:47:04 +00:00
dof Remove components if not extracted (#15948) 2024-10-19 15:13:39 +00:00
fullscreen_vertex_shader Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
fxaa Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
motion_blur Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
oit Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090) 2024-10-27 19:08:34 +00:00
post_process Start a built-in postprocessing stack, and implement chromatic aberration in it. (#13695) 2024-07-15 13:59:02 +00:00
prepass Type safe retained render world (#15756) 2024-10-10 18:47:04 +00:00
skybox Allow to expect (adopted) (#15301) 2024-09-20 19:16:42 +00:00
smaa Rename rendering components for improved consistency and clarity (#15035) 2024-09-10 01:11:46 +00:00
taa Remove components if not extracted (#15948) 2024-10-19 15:13:39 +00:00
tonemapping Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
upscaling Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
lib.rs Fix oit webgl (#15728) 2024-10-08 14:50:35 +00:00
msaa_writeback.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00