bevy/crates/bevy_pbr/src
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
..
cluster Reduce the clusterable object UBO size below 16384 for WebGL 2. (#16069) 2024-10-24 23:33:24 +02:00
deferred Fix lightmaps break when deferred rendering is enabled (#14599) 2024-10-18 23:18:11 +00:00
light Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
light_probe Implement WorldQuery for MainWorld and RenderWorld components (#15745) 2024-10-13 20:58:46 +00:00
lightmap Type safe retained render world (#15756) 2024-10-10 18:47:04 +00:00
meshlet Meshlet fill cluster buffers rewritten (#15955) 2024-10-24 23:33:23 +02:00
prepass Meshlet fill cluster buffers rewritten (#15955) 2024-10-24 23:33:23 +02:00
render Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090) 2024-10-27 21:18:19 +01:00
ssao Remove components if not extracted (#15948) 2024-10-19 15:13:39 +00:00
ssr
volumetric_fog Remove components if not extracted (#15948) 2024-10-19 15:13:39 +00:00
bundle.rs Type safe retained render world (#15756) 2024-10-10 18:47:04 +00:00
extended_material.rs
fog.rs
lib.rs Remove components if not extracted (#15948) 2024-10-19 15:13:39 +00:00
material.rs Revert default mesh materials (#15930) 2024-10-15 19:47:40 +00:00
mesh_material.rs Revert default mesh materials (#15930) 2024-10-15 19:47:40 +00:00
parallax.rs
pbr_material.rs Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
wireframe.rs