bevy/crates/bevy_pbr/src
IceSentry 4bf647ff3b
Add Order Independent Transparency (#14876)
# Objective

- Alpha blending can easily fail in many situations and requires sorting
on the cpu

## Solution

- Implement order independent transparency (OIT) as an alternative to
alpha blending
- The implementation uses 2 passes
- The first pass records all the fragments colors and position to a
buffer that is the size of N layers * the render target resolution.
- The second pass sorts the fragments, blends them and draws them to the
screen. It also currently does manual depth testing because early-z
fails in too many cases in the first pass.

## Testing

- We've been using this implementation at foresight in production for
many months now and we haven't had any issues related to OIT.

---

## Showcase


![image](https://github.com/user-attachments/assets/157f3e32-adaf-4782-b25b-c10313b9bc43)

![image](https://github.com/user-attachments/assets/bef23258-0c22-4b67-a0b8-48a9f571c44f)

## Future work

- Add an example showing how to use OIT for a custom material
- Next step would be to implement a per-pixel linked list to reduce
memory use
- I'd also like to investigate using a BinnedRenderPhase instead of a
SortedRenderPhase. If it works, it would make the transparent pass
significantly faster.

---------

Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com>
Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
Co-authored-by: Charlotte McElwain <charlotte.c.mcelwain@gmail.com>
2024-10-07 23:50:28 +00:00
..
cluster Deprecate get_or_spawn (#15652) 2024-10-07 16:08:22 +00:00
deferred Fix deferred rendering (#15656) 2024-10-04 22:51:23 +00:00
light Migrate meshes and materials to required components (#15524) 2024-10-01 21:33:17 +00:00
light_probe Deprecate get_or_spawn (#15652) 2024-10-07 16:08:22 +00:00
lightmap Migrate meshes and materials to required components (#15524) 2024-10-01 21:33:17 +00:00
meshlet Fix Mesh allocator bug and reduce Mesh data copies by two (#15566) 2024-10-01 17:15:57 +00:00
prepass Deprecate get_or_spawn (#15652) 2024-10-07 16:08:22 +00:00
render Add Order Independent Transparency (#14876) 2024-10-07 23:50:28 +00:00
ssao Deprecate get_or_spawn (#15652) 2024-10-07 16:08:22 +00:00
ssr Migrate motion blur, TAA, SSAO, and SSR to required components (#15572) 2024-10-01 22:45:31 +00:00
volumetric_fog Deprecate get_or_spawn (#15652) 2024-10-07 16:08:22 +00:00
bundle.rs Migrate meshes and materials to required components (#15524) 2024-10-01 21:33:17 +00:00
extended_material.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
fog.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
lib.rs Fix deferred rendering (#15656) 2024-10-04 22:51:23 +00:00
material.rs Add Order Independent Transparency (#14876) 2024-10-07 23:50:28 +00:00
mesh_material.rs Migrate meshes and materials to required components (#15524) 2024-10-01 21:33:17 +00:00
parallax.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
pbr_material.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
wireframe.rs Revert "Have EntityCommands methods consume self for easier chaining" (#15523) 2024-10-02 12:47:26 +00:00