bevy/examples/3d
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
..
3d_scene.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
3d_shapes.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
3d_viewport_to_world.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
animated_material.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
anisotropy.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
anti_aliasing.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
atmospheric_fog.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
auto_exposure.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
blend_modes.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
bloom_3d.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
camera_sub_view.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
clearcoat.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
color_grading.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
deferred_rendering.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
depth_of_field.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
fog_volumes.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
fog.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
generate_custom_mesh.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
irradiance_volumes.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
lighting.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
lightmaps.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
lines.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
load_gltf_extras.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
load_gltf.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
meshlet.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
motion_blur.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
order_independent_transparency.rs Add Order Independent Transparency (#14876) 2024-10-07 23:50:28 +00:00
orthographic.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
parallax_mapping.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
parenting.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
pbr.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
pcss.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
post_processing.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
query_gltf_primitives.rs Fix query_gltf_primitives example (#15715) 2024-10-07 23:03:16 +00:00
reflection_probes.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
render_to_texture.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
rotate_environment_map.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
scrolling_fog.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
shadow_biases.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
shadow_caster_receiver.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
skybox.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
spherical_area_lights.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
split_screen.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
spotlight.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
ssao.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
ssr.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
texture.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
tonemapping.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
transmission.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
transparency_3d.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
two_passes.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
update_gltf_scene.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
vertex_colors.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
visibility_range.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
volumetric_fog.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
wireframe.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00