bevy/crates/bevy_pbr/src/render
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
..
clustered_forward.wgsl Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
fog.rs Rename rendering components for improved consistency and clarity (#15035) 2024-09-10 01:11:46 +00:00
fog.wgsl
forward_io.wgsl
gpu_preprocess.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
light.rs Place percentage-closer soft shadows behind a feature gate to save on samplers. (#16068) 2024-10-25 01:49:30 +02:00
mesh_bindings.rs simplify std::mem references (#15315) 2024-09-19 21:28:16 +00:00
mesh_bindings.wgsl
mesh_functions.wgsl
mesh_preprocess.wgsl
mesh_types.wgsl
mesh_view_bindings.rs Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090) 2024-10-27 21:18:19 +01:00
mesh_view_bindings.wgsl Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090) 2024-10-27 21:18:19 +01:00
mesh_view_types.wgsl Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090) 2024-10-27 21:18:19 +01:00
mesh.rs Adding alpha_threshold to OrderIndependentTransparencySettings for user-level optimization (#16090) 2024-10-27 21:18:19 +01:00
mesh.wgsl
mod.rs
morph.rs Type safe retained render world (#15756) 2024-10-10 18:47:04 +00:00
morph.wgsl
parallax_mapping.wgsl
pbr_ambient.wgsl
pbr_bindings.wgsl
pbr_fragment.wgsl Added visibility bitmask as an alternative SSAO method (#13454) 2024-10-02 13:43:35 +00:00
pbr_functions.wgsl Meshlet screenspace-derived tangents (#15084) 2024-09-29 18:39:25 +00:00
pbr_lighting.wgsl
pbr_prepass_functions.wgsl
pbr_prepass.wgsl Meshlet screenspace-derived tangents (#15084) 2024-09-29 18:39:25 +00:00
pbr_transmission.wgsl
pbr_types.wgsl
pbr.wgsl Fix OIT shaders error with DX12 backend (#15782) 2024-10-10 14:17:09 +00:00
rgb9e5.wgsl
shadow_sampling.wgsl Place percentage-closer soft shadows behind a feature gate to save on samplers. (#16068) 2024-10-25 01:49:30 +02:00
shadows.wgsl Implement percentage-closer soft shadows (PCSS). (#13497) 2024-09-18 18:07:17 +00:00
skin.rs Type safe retained render world (#15756) 2024-10-10 18:47:04 +00:00
skinning.wgsl
utils.wgsl Per-meshlet compressed vertex data (#15643) 2024-10-08 18:42:55 +00:00
view_transformations.wgsl
wireframe.wgsl