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

Camera3D.UnprojectPosition not accurate on higher resolutions #55255

Closed
Byteron opened this issue Nov 23, 2021 · 5 comments
Closed

Camera3D.UnprojectPosition not accurate on higher resolutions #55255

Byteron opened this issue Nov 23, 2021 · 5 comments

Comments

@Byteron
Copy link
Contributor

Byteron commented Nov 23, 2021

Godot version

4.0.dev

System information

Windows 11, AMD CPU & GPU

Issue description

Camera3D.UnprojectPosition() is not accurate with higher resolutions.

the below images how unit plates that are placed on a canvas layer where the units are, using Camera3D.UnprojectPosition.

default res
image

2560x1440
image

The relevant code snippet:

if (camera.IsPositionBehind(Position))
        {
            Hide();
        }
        else
        {
            Show();
            RectPosition = camera.UnprojectPosition(Position);
        }

Steps to reproduce

  1. create empty project, place a cube onto some world position, and a label onto the same world position via Camera3D.UnprojectPosition. Also add Camera3D, naturally.
  2. change resolution to something bigger than 1920x1080 (at 1080 I found this both work and not work depending on being borderless or not)
  3. Label should be offset.

Minimal reproduction project

No response

@Calinou
Copy link
Member

Calinou commented Nov 23, 2021

Related to #52295 and #34805.

Which stretch mode are you using in the project? You most likely need to multiply/divide the coordinates by the scale factor (which you can determine by dividing the current window height with the base window height, 1080 in your case).

@Calinou Calinou added this to the 4.0 milestone Nov 23, 2021
@Byteron
Copy link
Contributor Author

Byteron commented Nov 24, 2021

I have stretch mode set to ignore.

@Byteron
Copy link
Contributor Author

Byteron commented Nov 24, 2021

note that I don't use resizing.
the 1440p image is with that resolution set in the project settings, so it IS the base resolution.

@madmiraal
Copy link
Contributor

Probably fixed with #57082; although it's impossible to verify without an MRP, and I'm unable to reproduce the problem with the instructions provided.

@KoBeWi
Copy link
Member

KoBeWi commented Apr 10, 2022

Closing based on the above comment (and lack of activity since then). Comment if you can still reproduce in newest master.

@KoBeWi KoBeWi closed this as completed Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants