Hi, I got stuck on pretty trivial problem
When I see my scene on 1920x1080 display I see it like that:
But if I change window size little bit my sphere disappear
So my question is what’s the proper way to make it always visible and make scene looks maximally similar for any window size?
Is the screenshot from the same camera angle (ie: Your camera hasn’t moved)?
You can change the rendering settings so that it always maintains the same aspect ratio with borders:
An alternative is to choose whether height or width should be preserved no matter the what the size of the window is: https://developer.playcanvas.com/en/api/pc.CameraComponent.html#horizontalFov
Set that to true or false pending on which axis you deem more important.
No, camera wasn’t moved, only window’s size was changed.
I set this option to Keep aspect ratio and got border around my scene.
I’ve played with Resolution, Fog and it was unsuccessful.
So anyway, I tested my scene on the most popular screen sizes and result is OK, but I still worry about 1280x1024 guys. I think their eyes are like (-) (-) to see it. I have no idea how I used it 10 yeas ago.
The main problem of Keep aspect ratio is mobile devices.
Keep aspect ratio VS Fill window
This behavior is okay for my case, even proper, but I still don’t understand how Tanks works around of this, for example.
Tanks doesn’t worry about the what’s on the edges of screen as long as the player can see the tank in the center.
What are you trying to do? It will be impossible to keep everything in frame going from one aspect ratio to another without losing something in the frame. Is the width of the view more important? Is the height? Both?
What’s doubly confusing is that only changing the size a little bit in your first post completely changes the view which is suspect.
Would it be possible to share the project or a published build to look at?
Depends on frame. Some objects are attached to left edge, some to bottom.
Yes, I understand it’s pretty stupid to expect the same screen with diff aspect ratio.
I resized it as much as need to make sphere disappear, about a 1/3 of initial size.
Your answer really helped me, I appreciate it. The last piece of this puzzle it my head was a Tanx, so now I’m totally understand it.
What might help further: what I have done in the model view is to change the
camera.horizontalfov setting depending if the window has been resized to a portrait or landscape view so the box is always in frame: https://playcanvas.com/project/446385/overview/starter-kit-model-viewer
In BMW i8 demo we’ve done adaptive switch between field of view. https://playcanv.as/p/RqJJ9oU9/?overlay=false
Using a custom frustum function that can gradually switch between horizontal and vertical lock on fov.
You can simply switch to horizontal when your aspect ratio goes below 1.0 and vice-versa. Then ensure you testing visuals with square window - everything in a square is guaranteed to be visible always.
It is pretty unique case to case, so combination of things you need to determine:
- Safe visible area
- Fixed of flexible aspect ratio
- Fully flexible or till some limits flexible aspect ratio, this project does something like that: https://playcanv.as/p/2OlkUaxF/
- How to switch FoV based on aspect ratio.