Extend the default render range of 2D camera#9310
Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom Jul 31, 2023
opstic:negative-z-default
Merged
Extend the default render range of 2D camera#9310alice-i-cecile merged 1 commit intobevyengine:mainfrom opstic:negative-z-default
alice-i-cecile merged 1 commit intobevyengine:mainfrom
opstic:negative-z-default
Conversation
Selene-Amanita
approved these changes
Jul 30, 2023
Member
Selene-Amanita
left a comment
There was a problem hiding this comment.
For context, point 1 of #9214 (comment) (calling new_with_far then setting the near) could lead to a problem if someone tries to read the Frustum after calling default from the Bundle directly (before insertion), and changing the behavior of new_with_far would be a problem if someone relies on it.
I talked with @opstic and we agreed that duplicating the code of new_with_far might be the best course of action for 0.11.1, and then we can clean-up code for 0.12.0 as explained in the previous comment.
jnhyatt
approved these changes
Jul 31, 2023
alice-i-cecile
approved these changes
Jul 31, 2023
cart
pushed a commit
that referenced
this pull request
Aug 10, 2023
# Objective - Fixes #9138 ## Solution - Calling `Camera2dBundle::default()` will now result in a `Camera2dBundle` with `Vec3::ZERO` transform, `far` value of `1000.` and `near` value of `-1000.`. - This will enable the rendering of 2d entities in negative z space by default. - I did not modify `new_with_far` as moving the camera to `Vec3::ZERO` in that function will cause entities in the positive z space to become hidden without further changes. And the further changes cannot be applied without it being a breaking change.
drakmaniso
pushed a commit
to drakmaniso/bevy_pixel_camera
that referenced
this pull request
Sep 8, 2023
Done in order to match similar change in Bevy's camera (see bevyengine/bevy#9310)
drakmaniso
added a commit
to drakmaniso/bevy_pixel_camera
that referenced
this pull request
Sep 8, 2023
Done in order to match similar change in Bevy's camera (see bevyengine/bevy#9310)
43 tasks
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 9, 2024
Adopted PR from dmlary, all credit to them! #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 #9138, #9214, #9310, #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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Solution
Camera2dBundle::default()will now result in aCamera2dBundlewithVec3::ZEROtransform,farvalue of1000.andnearvalue of-1000..new_with_faras moving the camera toVec3::ZEROin that function will cause entities in the positive z space to become hidden without further changes. And the further changes cannot be applied without it being a breaking change.