Open wonder-sk opened 3 years ago
Pull requests addressing the issues:
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 https://github.com/qgis/PSC/issues/56.
Ahh not yet, thanks for the reminder Anita!
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:
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).