Skip to content

Conversation

@lucido-simon
Copy link
Contributor

On scaled target, calculations based on the camera viewport's size were off, due to taking into account the scaling factor. Scaling factor should be taken into account when rendering UI elements, not when placing them into the world, since the world uses logical units.

Example of the bug:
The systems defines a scaling factor of 2. This means that when rendering at 1000x500, the camera is going to upscale that to 2000x1000. If we place a UiLayout that is of size Rl(100.), it's going to take viewport's physical size: 2000x1000. When rendering, it's going to be upscaled by the scale factor, so it'll end up taking 4000x2000.

The fix is to use the camera's viewport logical size, to use world's coordinates.

I'm new to this stuff, the fix might have side effects that I'm not aware of.

On scaled target, calculations based on the camera viewport's size were
off, due to taking into account the scaling factor. Scaling factor
should be taken into account when rendering UI elements, not when
placing them into the world, since the world uses logical units.

Example of the bug:
The systems defines a scaling factor of 2. This means that when
rendering at 1000x500, the camera is going to upscale that to 2000x1000.
If we place a UiLayout that is of size Rl(100.), it's going to take
viewport's physical size: 2000x1000. When rendering, it's going to be
upscaled by the scale factor, so it'll end up taking 4000x2000.

The fix is to use the camera's viewport logical size, to use world's
coordinates.

Signed-off-by: Simon Lucido <simon34280@gmail.com>
@IDEDARY IDEDARY merged commit 519864d into bytestring-net:main Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants