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

Fixing terrain and camera issues in 3D #215

Open
wonder-sk opened this issue Mar 18, 2021 · 4 comments
Open

Fixing terrain and camera issues in 3D #215

wonder-sk opened this issue Mar 18, 2021 · 4 comments
Labels
Grant-2021 QEP for 2021 Grant Program Implemented

Comments

@wonder-sk
Copy link
Member

QGIS Enhancement: Fixing terrain and camera issues in 3D

Date 2021/03/18

Author Martin Dobias (@wonder-sk)

Contact wonder dot sk at gmail dot com

Maintainer @wonder-sk

Version QGIS 3.20 / 3.22

Summary

3D map views in QGIS have a couple of issues related to terrain and camera handling that make the use of 3D views more difficult than it should be. What this QEP aims to solve are the following issues:

  • Unintuitive camera rotation
  • Terrain entity is always present (even if not needed)
  • Wrong center point when zooming in/out and rotating
  • Data in 3D view appearing twice (“flat” in terrain and in 3D)

Fixing all of the issues above should greatly improve the ease of use for the 3D map views in QGIS.

Proposed Solution

Unintuitive camera rotation

Most commonly users are having problems when trying to adjust camera view. This is because the camera's pivot point is always set to be on the terrain surface - which is fine when all data is displayed on the right top of the terrain surface, but things do not work well if that’s not the case and camera rotation behavior is confusing. The idea is to decouple the camera controller from the terrain entity. Camera view center calculation (used as the pivot point for rotation) should involve all 3D entities, not just terrain. This may also require updates to how near/far planes are calculated.

Terrain entity is always present

Solving the previous point should give us more flexibility and allow different terrain rendering modes (e.g. wireframe) or no terrain at all. Having no terrain (with a draped 2D map) is quite useful in many cases, for example if the terrain is provided by some other means (e.g. a triangulated vector layer, mesh or a point cloud) or when the terrain entity is only eating up resources without actually adding useful visual information. Therefore a checkbox should be added to allow turning off the terrain entity altogether, and all the related under the hood changes to make that possible.

Wrong center point when zooming in/out and rotating

This issue is best explained on the equivalent behavior in 2D map canvas: when zooming in/out, the location at which the mouse cursor is pointing stays in place - i.e. it is used as the center point for zoom in/out. In 3D map canvas, zoom in/out and rotation is always using the point in the very center of the 3D map canvas, ignoring the mouse position. This leads to suboptimal UX as users need more time to move the camera to the intended position. The plan is to change the behavior to follow the same approach as 2D map canvas.

Data in 3D view appearing twice

Users find it confusing that by default data from map layers appear twice when 3D renderer is enabled - once rendered as true 3D entity and the other time “flattened” on the 2D map draped on terrain. Users then need to use workarounds to remove the “flattened” version (e.g. setting no 2D renderer for vector layers, setting “extent only” 2D renderer for point cloud layers). It would make more sense to change the default behavior - if a map layer has 3D renderer assigned, it should not be rendered on the terrain’s 2D map in 3D map view. For some cases where it makes sense to have map layer also rendered for terrain texture in 3D map view, there should be a checkbox to allow it (in 3D renderer styling widget).

Bonus bugs to fix

If time will allow depending on how long it takes to fix the previous issues, there are various pending bugs with 3D label worth tackling in the QGIS bug queue: https://github.com/qgis/QGIS/labels/3D

Alternatively, it would be good to address the issue of correct alignment of 3D data to terrain (aka altitude clamping) - currently for DEM-based terrain we only use a low-resolution version of the DEM, and for “online” terrain (elevation tiles hosted on AWS) the altitude clamping is not working at all (using zero elevation).

@wonder-sk
Copy link
Member Author

Pull requests addressing the issues:

wonder-sk pushed a commit to qgis/QGIS that referenced this issue Jan 5, 2022
Fixes two issues in camera navigation:
- Unintuitive camera rotation
- Wrong center point when zooming in/out and rotating

See qgis/QGIS-Enhancement-Proposals#215

This PR employs the following changes:
- The zoom in functionality will zoom in towards the real 3D position of an object in the scene instead the camera view center point used previously.
- The rotation will use the real clicked 3D position of a pixel as well instead of the camera view center point.
- The press and drag behaviour is improved to shift the map in real 3D coordinates instead of some arbitrary measurement (you can see the clicked pixel following the cursor instead of drifting away).
@anitagraser
Copy link
Member

Hi @wonder-sk, have you already sent a final report for this funded enhancement? It would be great if you could add a link in qgis/PSC#56.

@wonder-sk
Copy link
Member Author

Ahh not yet, thanks for the reminder Anita!

@wonder-sk
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Grant-2021 QEP for 2021 Grant Program Implemented
Projects
None yet
Development

No branches or pull requests

2 participants