Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub View only projects correctly when aspect ratio of size and full_size match #15600

Open
m-edlund opened this issue Oct 2, 2024 · 1 comment
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled

Comments

@m-edlund
Copy link
Contributor

m-edlund commented Oct 2, 2024

Bevy version

Main branch (c841dd9)

What you did

I attempted to use the newly added sub_camera_view API (#15537 ) to create a subview that overlays a shader effect onto a part of the full image. However this only works when the size and full_size of the sub_camera_view have the same aspect ratio.

I made an example to illustrate this effect in a fork

What went wrong

Regardless of the aspect ratios of size and full_size, the shader effect should cleanly overlap the image of the main camera.

Instead in both orthographic and perspective projection the projection of the sub view is skewed when the aspect ratio of size and full_size differ.

Additional information

Perspective (overlay working correctly when aspect ratio is the same):

Image

Perspective (overlay is skewed when aspect ratios differ):

Image

Analogous in orthographic projection.

To run the example yourself, check out the branch and run cargo run --example camera_sub_view.

Press P to switch projection and A to switch aspect ratios.

Likely cause

The most likely reason is that I made a mistake in the projection calculations here and here.

@m-edlund m-edlund added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 2, 2024
@m-edlund
Copy link
Contributor Author

m-edlund commented Oct 2, 2024

I will attempt to find the fix for this issue myself in the coming days. However I'm very much an amateur when it comes to projection calculations, so if anyone with more experience in the area would like to take a look, the help would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

1 participant