bevy/examples/3d
Stepan Koltsov 06bf928927
Option to enable deterministic rendering (#11248)
# Objective

Issue #10243: rendering multiple triangles in the same place results in
flickering.

## Solution

Considered these alternatives:
- `depth_bias` may not work, because of high number of entities, so
creating a material per entity is practically not possible
- rendering at slightly different positions does not work, because when
camera is far, float rounding causes the same issues (edit: assuming we
have to use the same `depth_bias`)
- considered implementing deterministic operation like
`query.par_iter().flat_map(...).collect()` to be used in
`check_visibility` system (which would solve the issue since query is
deterministic), and could not figure out how to make it as cheap as
current approach with thread-local collectors (#11249)

So adding an option to sort entities after `check_visibility` system
run.

Should not be too bad, because after visibility check, only a handful
entities remain.

This is probably not the only source of non-determinism in Bevy, but
this is one I could find so far. At least it fixes the repro example.

## Changelog

- `DeterministicRenderingConfig` option to enable deterministic
rendering

## Test

<img width="1392" alt="image"
src="https://github.com/bevyengine/bevy/assets/28969/c735bce1-3a71-44cd-8677-c19f6c0ee6bd">

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-01-09 00:46:01 +00:00
..
3d_gizmos.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
3d_scene.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
3d_shapes.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
3d_viewport_to_world.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
anti_aliasing.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
atmospheric_fog.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
blend_modes.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
bloom_3d.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
deferred_rendering.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
deterministic.rs Option to enable deterministic rendering (#11248) 2024-01-09 00:46:01 +00:00
fog.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
generate_custom_mesh.rs Unload render assets from RAM (#10520) 2024-01-03 03:31:04 +00:00
lighting.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
lightmaps.rs Implement lightmaps. (#10231) 2024-01-02 20:38:47 +00:00
lines.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
load_gltf.rs Update default ClearColor to better match Bevy's branding (#10339) 2023-11-03 12:57:38 +00:00
orthographic.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
parallax_mapping.rs Update glam, encase and hexasphere (#11082) 2024-01-08 22:58:45 +00:00
parenting.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
pbr.rs Update default ClearColor to better match Bevy's branding (#10339) 2023-11-03 12:57:38 +00:00
reflection_probes.rs Implement minimal reflection probes. (#10057) 2024-01-08 22:09:17 +00:00
render_to_texture.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
shadow_biases.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
shadow_caster_receiver.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
skybox.rs Update winit dependency to 0.29 (#10702) 2023-12-21 07:40:47 +00:00
spherical_area_lights.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
split_screen.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
spotlight.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
ssao.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
texture.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
tonemapping.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
transmission.rs Fix missed explicit conversions in examples (#11261) 2024-01-09 00:44:24 +00:00
transparency_3d.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
two_passes.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
update_gltf_scene.rs Update default ClearColor to better match Bevy's branding (#10339) 2023-11-03 12:57:38 +00:00
vertex_colors.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00
wireframe.rs Use impl Into<A> for Assets::add (#10878) 2024-01-08 22:14:43 +00:00