bevy/examples/3d
Robert Swain 045f324e97 Use the infinite reverse right-handed perspective projection (#2543)
# Objective

Forward perspective projections have poor floating point precision distribution over the depth range. Reverse projections fair much better, and instead of having to have a far plane, with the reverse projection, using an infinite far plane is not a problem. The infinite reverse perspective projection has become the industry standard. The renderer rework is a great time to migrate to it.

## Solution

All perspective projections, including point lights, have been moved to using `glam::Mat4::perspective_infinite_reverse_rh()` and so have no far plane. As various depth textures are shared between orthographic and perspective projections, a quirk of this PR is that the near and far planes of the orthographic projection are swapped when the Mat4 is computed. This has no impact on 2D/3D orthographic projection usage, and provides consistency in shaders, texture clear values, etc. throughout the codebase.

## Known issues

For some reason, when looking along -Z, all geometry is black. The camera can be translated up/down / strafed left/right and geometry will still be black. Moving forward/backward or rotating the camera away from looking exactly along -Z causes everything to work as expected.

I have tried to debug this issue but both in macOS and Windows I get crashes when doing pixel debugging. If anyone could reproduce this and debug it I would be very grateful. Otherwise I will have to try to debug it further without pixel debugging, though the projections and such all looked fine to me.
2021-08-27 20:15:09 +00:00
..
3d_scene.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
3d_scene_pipelined.rs Use the infinite reverse right-handed perspective projection (#2543) 2021-08-27 20:15:09 +00:00
cornell_box_pipelined.rs remove .system from pipelined code (#2538) 2021-07-26 23:44:23 +00:00
load_gltf.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
load_gltf_pipelined.rs Port bevy_gltf to pipelined-rendering (#2537) 2021-07-30 03:37:34 +00:00
msaa.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
orthographic.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
orthographic_pipelined.rs Use the infinite reverse right-handed perspective projection (#2543) 2021-08-27 20:15:09 +00:00
parenting.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
pbr.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
pbr_pipelined.rs omni light -> point light 2021-07-24 16:43:37 -07:00
render_to_texture.rs SubGraphs, Views, Shadows, and more 2021-07-24 16:43:37 -07:00
shadow_biases_pipelined.rs remove .system from pipelined code (#2538) 2021-07-26 23:44:23 +00:00
shadow_caster_receiver_pipelined.rs bevy_pbr2: Add support for not casting/receiving shadows (#2726) 2021-08-25 19:44:20 +00:00
spawner.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
texture.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
texture_pipelined.rs remove .system from pipelined code (#2538) 2021-07-26 23:44:23 +00:00
update_gltf_scene.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
wireframe.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00
z_sort_debug.rs pipelined rendering proof of concept 2021-07-24 16:43:37 -07:00