69 Commits

Author SHA1 Message Date
Nyall Dawson
8af23b1002 Initial framework for terrain settings refactoring 2024-12-13 14:21:51 +10:00
Denis Rouzaud
30ea619861
sipify 2024-12-10 14:52:35 +01:00
Martin Dobias
60554195dc Add possibility to shift origin of 3D map scenes
This introduces a new class QgsGeoTransform (derived from QTransform)
that keeps chunk's translation vector as a QgsVector3D (i.e. in double
coordinates) and if there is a shift of the origin, 3D map scene and
chunk entities react to it by adjusting the underlying QTransform.
2024-11-25 17:16:28 +01:00
Withalion
5f6259ac10 Fix issues found in review 2024-11-21 09:30:45 +01:00
Withalion
1551449df3 Move debug panel icon from toolbar
Debug panel in 3d map view can be set in advanced settings or by
keyboard shortcut CTRL + SHIFT + d
2024-11-21 09:30:45 +01:00
Withalion
c76455bcc6 Add stop updates checkbox in 3D View options 2024-11-21 09:30:45 +01:00
Nyall Dawson
0f1daa11f3 Fix formatting of some \see links 2024-09-04 06:32:03 +10:00
Nyall Dawson
e161d0bd60 Enforce thread safety for Qgs3DMapSettings 2024-08-28 12:38:16 +10:00
Nyall Dawson
1f94f9bc4e Rework to use Qgs3DRenderContext instead 2024-08-28 12:38:16 +10:00
Nyall Dawson
5e33ee4a57 Add some thread safety to Qgs3DMapSettings usage
Create a small, cheap to copy (non-qobject) class
Qgs3DMapSettingsSnapshot which is designed to store
just cheap properties of Qgs3DMapSettings. Then use this
object wherever possible to avoid accessing the (non-thread
safe) Qgs3DMapSettings object for retrieval of simple
map properties (eg crs, extent, ...)

Refs https://github.com/qgis/QGIS-Enhancement-Proposals/issues/301
2024-08-28 12:38:16 +10:00
Nyall Dawson
3a578d6712 Header update 2024-08-13 20:28:55 +10:00
Nyall Dawson
6f652d251b Drop no-value copy constructor dox 2024-07-25 04:02:55 +10:00
Jean Felder
2682a2ee2d qgs3dmapsettings: Fix extent methods documention
The 3D scene's CRS is not necessarily the same as the project's
CRS. For example, it can be "EPSG:3857" if the project's CRS is
geographic.

The stored extent in the settings is always the 3D scene's extent.

See:
b0d1a4f8b1
2024-05-30 05:28:33 +10:00
Even Rouault
15ea5c46bc
Header files: remove all mentions of '\since QGIS 3.0' 2024-02-18 20:57:23 +01:00
Jean Felder
70debe9787 qgs3dmapcanvaswidget: Allow to draw the extent on the 2D map canvas
This adds a QgsRubberband in the 2D map canvas similar to the one used
to display the Frustum.

The option can be enabled in the General section of the 3D
configuration widget.
2023-03-24 07:09:55 +10:00
Jean Felder
2ba0ca9122 qgs3dmapsettings: remove the unused renderers logic
This is never used. The set or update renderer logic is handled in
Qgs3DMapScene by listening to the `onLayersChanged` and
`onLayerRenderer3DChanged` signals (see the previous commit).
2023-03-22 15:39:46 +01:00
Nyall Dawson
2aa484ca23 Move QgsCameraController enums to Qgis, promote to enum class 2023-02-23 13:53:34 +10:00
uclaros
1f9276d59d code layout tests 2023-01-23 14:38:10 +10:00
uclaros
bd4c595cac Add widget to set 3d scene's 2d extent 2023-01-23 14:38:10 +10:00
uclaros
f2067aba1e Limit 3d scenes' 2d extent 2023-01-23 14:38:10 +10:00
Martin Dobias
91100f816b
[3d] Ambient Occlusion (reworked) (#49702)
* Initial implementation

* - Add disabling of blur pass
- Change default parameter for shading factor
- fix some tests

* - Implement bilateral filtering
- Optimize textures
- Fix layout test

* rename SSAO to ambient occlusion
fix ssao settings widget margin

* Remove unused variable

* fix naming and add tooltips

* - Refactor quad entities
- Address Stefanos's suggestions

* Rework SSAO implementation

Previously we based the code on CloudCompare's implementation,
however that did not work too well for us for a couple of reasons:
- the code does not deal well with perspective projection, causing incorrect shading (CC uses orthographic projection)
- there was no range check, so we would be getting false ambient occlusion on larger depth discontinuities (silhouttes)
- banding artifacts as the sampling kernel was not getting rotated
- parameters (shading radius, distance attenuation) that are difficult to understand

The new implementation is based on John Chapman's tutorial and LearnOpenGL page (derived from the original tutorial):
https://john-chapman-graphics.blogspot.com/2013/01/ssao-tutorial.html
https://learnopengl.com/Advanced-Lighting/SSAO

The general approach of the SSAO is the following:
- for each pixel, we pick a couple of random points nearby (64 samples currently)
  and check with the depth buffer whether they are visible from the camera or not.
  The nearby points that are occluded contribute to darkening of the pixel,
  this is saved to a texture
- in the next rendering pass, we blur the texture using 4x4 box. This is because
  in the first step we use 4x4 random noise pattern and it leaves a noticeable noise
  pattern on the screen. This pass gets rid of that noise
- in the post-processing step, the blurred texture is blended with the rendered scene

There are few differences to J.C.'s tutorial and LearnOpenGL page:
- the approches above use normal maps (a texture with a normal vector for each pixel),
  but we don't because we also want to support point clouds that do not have normals
  (at least not by default)
- we use full sphere for sampling instead of hemisphere (which is possible when you
  have normals), so maybe we are getting a bit lower quality / performance
- LearnOpenGL also uses a texture with positions of all pixels - we only use depth map
  to get the original positions (like JC's original code does)

* Clean up ssao parameters and GUI, add intensity parameter

* Add missing Q_OBJECT macro

* Add more missing Q_OBJECT macros

* Add occlusion threshold parameter to control the darkening

With the default threshold of 50%, pixels only start to get darker
when more than half of the neighborhood samples are occluded. That
means flat surfaces should not get any darker. (What we had previously
is an equivalent of having threshold set at 0%)

The downside is that with increased threshold, more subtle occlusions get lost.

* Review from Stefanos

* More review and better defaults

* Clear button fix

Co-authored-by: NEDJIMAbelgacem <gb_nedjima@esi.dz>
2022-08-31 16:36:14 +03:00
pathmapper
4344d083ec Make sipify_all.sh happy
This change was made when running sipify_all.sh .
2022-06-16 08:21:05 +10:00
Jean Felder
a72dcb33fd
qgs3dmapsettings: Store debug overlay enabled flag
This stores the debug overlay visibility flag (mIsDebugOverlayEnabled)
even if it cannot be used (it needs at least Qt version 5.15). Its
default value is set to false to prevent any issue if the debug
overlay cannot be enabled.
This parameter is transient: it is not saved in the project
parameters.

The next commit will allow to this change this setting with
Qgs3DMapConfigWidget.
2022-06-08 17:29:27 +02:00
bdm-oslandia
faa8877160 add new 3Daxis option page in 3d settings
* add Qgs3DAxisSettings class to handle 3d axis parameters
* remove 3daxis configuration from 3d navigation widget
2022-06-02 16:58:30 +02:00
Nyall Dawson
e15b458f64 Remove deprecated methods 2022-04-27 11:50:13 +10:00
Nyall Dawson
5e831971cc Cleanup light source handling in API 2022-04-27 11:50:13 +10:00
Nyall Dawson
c555295d89 Fix crash when terrain is disabled in 3d map settings
We were using the Qgs3dMapSettings::terrainGenerator for two different
purposes -- one was to retrieve the settings of the generator, and
the other was as a shortcut to determine if the terrain was enabled
and a generator set.

Disambiguate this and avoid a crash when terrain rendering is disabled
in the 3d map settings
2022-04-22 02:34:46 -07:00
NEDJIMAbelgacem
1577174ffb fix tests 2022-03-21 07:56:39 -07:00
NEDJIMAbelgacem
60144d7645 switch to flag based approach for 2D/3D sync 2022-03-21 07:56:39 -07:00
NEDJIMAbelgacem
9141d05d59 - Change extent to trapezoid shape
- Visualize the viewed area using QgsRubberBand
-  Address reviews
2022-03-21 07:56:39 -07:00
NEDJIMAbelgacem
e38a879378 initial implementation 2022-03-21 07:56:39 -07:00
Nyall Dawson
36d649fa83 When creating a new 3d map, set the initial terrain settings for the
map to match the project's terrain settings
2022-03-19 05:58:37 +10:00
Vincent Cloarec
9965eccdce
Template parameter {usage} for XYZ raster and vector tiles (#46731) 2022-01-13 15:11:31 +01:00
NEDJIMAbelgacem
66b481ac36 use QgsProjectDirtyBlocker instead of connect disconnect dance 2022-01-12 13:46:49 +10:00
NEDJIMAbelgacem
96f7c474bf remove dirtifying the project on hide & show and add proper project dirtyfing when the project changes 2022-01-12 13:46:49 +10:00
Nedjima Belgacem
b88b080777
Camera navigation improvements (#45979)
Fixes two issues in camera navigation:
- Unintuitive camera rotation
- Wrong center point when zooming in/out and rotating

See https://github.com/qgis/QGIS-Enhancement-Proposals/issues/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).
2022-01-05 12:13:25 +01:00
Nedjima Belgacem
826c6a7c36
Disble layer rendering to 3D terrain texture for 3D rendered layers (#44367)
* add optional layer rendering to 3D terrain

* remove terrainLayers from Qgs3DMapSettings

* fix tests

* switch to layer terrain rendering when no 3d renderer is set

* fix mesh tests to handle terrain being disabled
2021-08-11 11:38:59 +02:00
Nedjima Belgacem
298a4514ec
Make 2d terrain rendering optional (#43489)
First part of https://github.com/qgis/QGIS-Enhancement-Proposals/issues/215
2021-07-14 10:09:48 +02:00
Denis Rouzaud
ba8a445850 run sipify 2021-03-22 21:13:52 +01:00
Alessandro Pasotti
7b2fc4c1f8 More doxy nonsense, pt 2 2021-02-19 08:15:29 +10:00
Nyall Dawson
7f3b40772a Fix build 2021-01-14 08:15:57 +10:00
Belgacem
0318ff768d add movement speed combobox 2021-01-14 08:15:57 +10:00
Belgacem
44d39becf3 initial fly mode implementation 2021-01-14 08:15:57 +10:00
NEDJIMAbelgacem
a5329d4f19 Add FPS counter check box 2020-12-08 16:28:49 +01:00
nirvn
9dee613a2a [FEATURE][3d] Orthographic projection support for 3D scenes 2020-11-19 15:30:30 +07:00
NEDJIMAbelgacem
810dc369f1 remove unused mTransform 2020-11-10 15:39:26 +01:00
NEDJIMAbelgacem
23b723e5a0 inital terrain elevation offset implementation 2020-11-08 16:58:57 +01:00
NEDJIMAbelgacem
a25f04641b adress reviews 2020-11-06 09:59:41 +01:00
NEDJIMAbelgacem
6f542e7ea0 moved debug settings to the advanced tab and fixed CI problems 2020-11-06 09:59:41 +01:00
NEDJIMAbelgacem
c3ef5cc324 Added configuration to debug shadow and forward depth textures 2020-11-06 09:59:41 +01:00