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
* 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
* 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.htmlhttps://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>
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.
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.
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
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).
* 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
- Add enums to qgis.h instead of qgscoreenums, so that they belong to
a Qgis namespace
- Split up the various symbol headers into multiple files so that we
can fine-tune their inclusion and forward declare more readily, speeding
up recompilation
- Move QgsSymbol enums to qgis
* fix UI freeze bug
* fix spelling
* fix spelling
* refactor a bit of the code
* rename getPointCloudBlock to pointCloudBlock
* use a feedback object instead of cancelled callback
* do not use QMetaObject::Connection
* Qgs3DRenderContext doesn't need to be QObject
* remove Q_OBJECT