mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
82e416dc48
Adopted PR from dmlary, all credit to them! https://github.com/bevyengine/bevy/pull/9915 Original description: # Objective The default value for `near` in `OrthographicProjection` should be different for 2d & 3d. For 2d using `near = -1000` allows bevy users to build up scenes using background `z = 0`, and foreground elements `z > 0` similar to css. However in 3d `near = -1000` results in objects behind the camera being rendered. Using `near = 0` works for 3d, but forces 2d users to assign `z <= 0` for rendered elements, putting the background at some arbitrary negative value. There is no common value for `near` that doesn't result in a footgun or usability issue for either 2d or 3d, so they should have separate values. There was discussion about other options in the discord [0](https://discord.com/channels/691052431525675048/1154114310042292325), but splitting `default()` into `default_2d()` and `default_3d()` seemed like the lowest cost approach. Related/past work https://github.com/bevyengine/bevy/issues/9138, https://github.com/bevyengine/bevy/pull/9214, https://github.com/bevyengine/bevy/pull/9310, https://github.com/bevyengine/bevy/pull/9537 (thanks to @Selene-Amanita for the list) ## Solution This commit splits `OrthographicProjection::default` into `default_2d` and `default_3d`. ## Migration Guide - In initialization of `OrthographicProjection`, change `..default()` to `..OrthographicProjection::default_2d()` or `..OrthographicProjection::default_3d()` Example: ```diff --- a/examples/3d/orthographic.rs +++ b/examples/3d/orthographic.rs @@ -20,7 +20,7 @@ fn setup( projection: OrthographicProjection { scale: 3.0, scaling_mode: ScalingMode::FixedVertical(2.0), - ..default() + ..OrthographicProjection::default_3d() } .into(), transform: Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y), ``` --------- Co-authored-by: David M. Lary <dmlary@gmail.com> Co-authored-by: Jan Hohenheim <jan@hohenheim.ch> |
||
---|---|---|
.. | ||
3d_scene.rs | ||
3d_shapes.rs | ||
3d_viewport_to_world.rs | ||
animated_material.rs | ||
anisotropy.rs | ||
anti_aliasing.rs | ||
atmospheric_fog.rs | ||
auto_exposure.rs | ||
blend_modes.rs | ||
bloom_3d.rs | ||
clearcoat.rs | ||
color_grading.rs | ||
deferred_rendering.rs | ||
depth_of_field.rs | ||
fog.rs | ||
fog_volumes.rs | ||
generate_custom_mesh.rs | ||
irradiance_volumes.rs | ||
lighting.rs | ||
lightmaps.rs | ||
lines.rs | ||
load_gltf.rs | ||
load_gltf_extras.rs | ||
meshlet.rs | ||
motion_blur.rs | ||
orthographic.rs | ||
parallax_mapping.rs | ||
parenting.rs | ||
pbr.rs | ||
post_processing.rs | ||
reflection_probes.rs | ||
render_to_texture.rs | ||
rotate_environment_map.rs | ||
scrolling_fog.rs | ||
shadow_biases.rs | ||
shadow_caster_receiver.rs | ||
skybox.rs | ||
spherical_area_lights.rs | ||
split_screen.rs | ||
spotlight.rs | ||
ssao.rs | ||
ssr.rs | ||
texture.rs | ||
tonemapping.rs | ||
transmission.rs | ||
transparency_3d.rs | ||
two_passes.rs | ||
update_gltf_scene.rs | ||
vertex_colors.rs | ||
visibility_range.rs | ||
volumetric_fog.rs | ||
wireframe.rs |