bevy/crates/bevy_pbr/src/render
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
..
clustered_forward.wgsl Fix incorrect function calls to hsv_to_rgb in render debug code. (#14260) 2024-07-22 18:25:54 +00:00
fog.rs Rename rendering components for improved consistency and clarity (#15035) 2024-09-10 01:11:46 +00:00
fog.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
forward_io.wgsl Add UV channel selection to StandardMaterial (#13200) 2024-05-13 18:23:09 +00:00
gpu_preprocess.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
light.rs Deprecate get_or_spawn (#15652) 2024-10-07 16:08:22 +00:00
mesh.rs Add Order Independent Transparency (#14876) 2024-10-07 23:50:28 +00:00
mesh.wgsl Fix the example regressions from packed growable buffers. (#14375) 2024-07-22 18:55:51 +00:00
mesh_bindings.rs simplify std::mem references (#15315) 2024-09-19 21:28:16 +00:00
mesh_bindings.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
mesh_functions.wgsl Fix meshlet vertex attribute interpolation (#13775) 2024-06-10 20:18:43 +00:00
mesh_preprocess.wgsl Fix the example regressions from packed growable buffers. (#14375) 2024-07-22 18:55:51 +00:00
mesh_types.wgsl Fix the example regressions from packed growable buffers. (#14375) 2024-07-22 18:55:51 +00:00
mesh_view_bindings.rs Add Order Independent Transparency (#14876) 2024-10-07 23:50:28 +00:00
mesh_view_bindings.wgsl Add Order Independent Transparency (#14876) 2024-10-07 23:50:28 +00:00
mesh_view_types.wgsl Implement volumetric fog support for both point lights and spotlights (#15361) 2024-09-29 21:30:53 +00:00
mod.rs Implement motion vectors and TAA for skinned meshes and meshes with morph targets. (#13572) 2024-05-31 17:02:28 +00:00
morph.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
morph.wgsl Implement motion vectors and TAA for skinned meshes and meshes with morph targets. (#13572) 2024-05-31 17:02:28 +00:00
parallax_mapping.wgsl Fix a few "repeated word" typos (#13955) 2024-06-20 21:35:20 +00:00
pbr.wgsl Add Order Independent Transparency (#14876) 2024-10-07 23:50:28 +00:00
pbr_ambient.wgsl Use “specular occlusion” term to consistently extinguish fresnel on Ambient and Environment Map lights (#10182) 2023-10-23 03:26:20 +00:00
pbr_bindings.wgsl Added feature switch to default Standard Material's new anisotropy texture to off (#14048) 2024-07-02 18:02:05 +00:00
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 Rename "point light" to "clusterable object" in cluster contexts. (#13654) 2024-06-04 11:01:13 +00:00
pbr_prepass.wgsl Meshlet screenspace-derived tangents (#15084) 2024-09-29 18:39:25 +00:00
pbr_prepass_functions.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
pbr_transmission.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
pbr_types.wgsl Revert "Make FOG_ENABLED a shader_def instead of material flag (#13783)" (#13803) 2024-06-10 23:25:16 +00:00
rgb9e5.wgsl Deferred Renderer (#9258) 2023-10-12 22:10:38 +00:00
shadow_sampling.wgsl Implement percentage-closer soft shadows (PCSS). (#13497) 2024-09-18 18:07:17 +00:00
shadows.wgsl Implement percentage-closer soft shadows (PCSS). (#13497) 2024-09-18 18:07:17 +00:00
skin.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
skinning.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
utils.wgsl move wgsl color operations from bevy_pbr to bevy_render (#13209) 2024-05-04 10:30:23 +00:00
view_transformations.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
wireframe.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00