197 Commits

Author SHA1 Message Date
Martin Dobias
859a851e39 Allow GPU memory limit configuration + show a warning when limit got hit 2023-09-29 05:41:59 +10:00
Jean Felder
d8508b1132 qgs3dmapscene: Fix sip file
This fixes commit b9f770210c03201a5d81324ac3b1523f57bc2bd8.
2023-09-25 09:53:13 +10:00
Nyall Dawson
0a04a64413 QString fixup 2023-08-18 11:45:29 +10:00
Martin Dobias
e8a24b0f96 Fixed note + added convert to subclass code 2023-08-16 13:19:44 +10:00
Martin Dobias
9eb35537e7 Add Python bindings for tiled scene 3D renderer 2023-08-16 13:19:44 +10:00
bdm-oslandia
ecd7212e6c fix(3D): replace geometry renderer identification (main/selected) by property
3D geometry renderer identification in QgsChunkedEntity was made according to the object name and can be prone to error. Now we used a property (prop name is defined in a const) with values from enum.
2023-06-14 10:31:02 +02: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
Stefanos Natsis
b371267fbe
Improved 3d measure tool (#52208)
* cleanup 3d measure tool class from pickers

* update qgs3dmapscene and identify tool

* remove pickers from chunked entity and terrain entity

* add QgsRay3d::intersects( QgsBox3d );

* demterrain and tesselated polygon geometry intersection checks

* Add vertex markers to 3d rubber bands
Add moveLastPoint() support for 3d rubber bands

* Forward keyEvents to 3d map tools

* proof of concept, needs refactoring

* move intersection logic to ChunkedEntities

* move ray casting logic to Qgs3DUtils

* cleanup map tools

* rename intersectEntity to rayIntersection, further cleanup

* cleanup

* move RayCastContext param
fix last rubberband marker
use singleResult for pointclouds
cleanup

* replace autos

* fix FID fetching logic
fix rule based rendering hits
fix selected feature hits

* fix clearing identify results, startDrag tolerance

* use doubles when dealing with map coordinates
return world coords in point cloud RayHits

* dosctrings and method rename

* use raycastingtools::ray3d

* move RayHit and Context to raycastingutils

* sip skip new methods

* fix build

* remove unused

* added docstring

* fix forward declarations

* fix qt6 build

* Use anti-aliasing for better looking billboards

* Slightly improve styling of 3D rubber band

* Make it possible to have 3D rubber band always on top

Also adds some docs to the frame graph implementation

* Do not leave the final rubber band segment when measuring is done

* address review comments

* spelling typo

* make cppcheck happy

* address benoit and loic review comments

* remove previous bool QgsTerrainEntity::rayIntersection() implementation

* add consts, update test mask

---------

Co-authored-by: Martin Dobias <wonder.sk@gmail.com>
2023-03-21 22:01:45 +01:00
Mathieu Pellerin
22a46d9988 Oh clang 2023-02-27 11:32:38 +10:00
Mathieu Pellerin
16c087f4ab [3d] Expose the 3D map settings for a given scene to python API 2023-02-27 11:32:38 +10:00
Mathieu Pellerin
f188a00df5 [3d] Expose QgsCameraController's rotateCamera() function to API 2023-02-27 11:32:38 +10:00
Mathieu Pellerin
27e2e324ca [3d] Add a walkView() function to QgsCameraController 2023-02-27 11:32:38 +10:00
Nyall Dawson
2aa484ca23 Move QgsCameraController enums to Qgis, promote to enum class 2023-02-23 13:53:34 +10:00
Nyall Dawson
176807bc35 Provide a basic way to access open 3d scenes via PyQGIS
Qgs3DMapScene.openScenes() will now return a map of
open Qgs3DMapScene objects (by name) visible in the app. Various
basic properties of the scene are exposed, including
the camera controller, allowing access to navigate 3d
scenes via python
2023-02-23 13:53:34 +10:00
Nyall Dawson
046883fa9c Promote QgsWkbTypes enums to enum class, move to Qgis 2023-02-22 12:39:21 +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
Jean Felder
5d14d84bde
symbols: rename material to material settings (#50977)
* qgspoint3dsymbol: Rename mMaterial attribute to mMaterialSettings

mMaterial is not a material but an attribute to handle material
settings. Renaming it makes it easier to understand its usage.

* qgspoint3dsymbol: Rename materialSettings getter and setter

See previous commit.

* qgsline3dsymbol: Rename mMaterial attribute to mMaterialSettings

mMaterial is not a material but an attribute to handle material
settings. Renaming it makes it easier to understand its usage.

* qgsline3dsymbol: Rename materialSettings getter and setter

See previous commit.

* qgspolygon3dsymbol: Rename mMaterial attribute to mMaterialSettings

mMaterial is not a material but an attribute to handle material
settings. Renaming it makes it easier to understand its usage.

* qgspolygon3dsymbol: Rename materialSettings getter and setter

See previous commit.

* qgsmesh3dsymbol: Rename mMaterial attribute to mMaterialSettings

mMaterial is not a material but an attribute to handle material
settings. Renaming it makes it easier to understand its usage.

* qgsmesh3dsymbol: Rename materialSettings getter and setter

See previous commit.

* qgsgoochmaterialsettings: fix indentation
2022-11-30 16:45:32 +01: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
Nyall Dawson
ab2c55aac4 [qt6] Deal with the move of QBuffer/QGeometry/QAttribute from Qt3DRender to
Qt3DCore
2022-08-18 13:23:55 +10:00
Jean Felder
b69feb0817 qgsphongtexturedmaterialsettings: Add support for opacity
Qt3DRender::QTexture2D does not handle opacity. Therefore, it is not
possible to use the default Qt3DExtras::QDiffuseSpecularMaterial
implementation. This problem is solved by using
Qt3DRender::QMaterial and copying the
Qt3DExtras::QDiffuseSpecularMaterial shaders from Qt3D source
code. Then, the texture color needs to be changed to set the correct
opacity. This is achieved in the fragement shader:

```
vec4 diffuseTextureColor = vec4(texture(diffuseTexture, texCoord).rgb,
opacity);
```

instead of the default:

```
vec4 diffuseTextureColor = vec4(texture(diffuseTexture, texCoord));
```

As far as the FrameGraph is concerned, this is already handled in
Qgs3DMapScene::finalizeNewEntity which checks for all material which
have an effect with an opacity parameter.
2022-07-25 07:38:12 -07:00
Jean Felder
11bb812f7d qgsphongmaterialsettings: Fix setOpacity documentation 2022-07-19 08:04:39 -07: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
NEDJIMAbelgacem
e24f5cbbef Add transparency support for phong materials 2022-05-13 08:00:08 +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
8520d7ed27 Move some methods to lighting classes 2022-04-27 11:50:13 +10:00
Nyall Dawson
9803439f5e Add a base class for light sources 2022-04-27 11:50:13 +10:00
Nyall Dawson
d42f2792d2 Move lighting classes to subfolder 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
uclaros
df740b4d0b address review 2022-04-04 02:57:00 -07:00
uclaros
c16e9a204c Sync pointcloud layer's 3d renderer style with 2d renderer 2022-04-04 02:57:00 -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
vcloarec
bfbc62d613 add direction in shader for classification 2022-03-08 07:53:50 -08:00
vcloarec
c8ff57b8d0 sipify 2022-03-08 07:53:50 -08:00
vcloarec
475b82bcef fix spelling and doc 2022-03-08 07:53:50 -08:00
vcloarec
fe64784e93 filter by height 2022-03-08 07:53:50 -08:00
vcloarec
bbd2f579ee fix point cloud triangulation with classification
sipify
2022-03-08 07:53:50 -08:00
vcloarec
434e7028dc filter before triangulation
no vertical filter before and remove exterior triangles


finalize


leftover


typo, const and other leftovers


fix big triangles filter


Stefanos review
2022-03-08 07:53:50 -08:00
Nyall Dawson
63e2d1ec16 Newly created 3d symbols for a vector layer default to inheriting
appropriate parameters from the layer's elevation settings
2022-03-03 06:15:10 +10:00
Nyall Dawson
5395d87d7f Move altitude clamping/binding enums to Qgis namespace, promote to enum
class
2022-03-03 06:15:10 +10:00
Vincent Cloarec
9965eccdce
Template parameter {usage} for XYZ raster and vector tiles (#46731) 2022-01-13 15:11:31 +01:00