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

[3D] Use QGIS material for the terrain #58134

Merged
merged 10 commits into from
Aug 19, 2024

Conversation

ptitjano
Copy link
Contributor

Description

This is factored out from #57899

It allows to use QGIS material for the terrain instead of native qt3D ones. It will make it possible to customize those shaders. There are 3 different cases to handle:

  • no texture: there is a drop-in replacement with QgsPhongMaterialSettings
  • texture, no shading: QgsPhongTexturedMaterialSettings is extended to handle both textures and textures from a path
  • texture, shading. A new material is introduced: QgsTextureMaterial

This PR needs #58114 to be merged first and thus it includes it.

@github-actions github-actions bot added this to the 3.40.0 milestone Jul 16, 2024
@ptitjano ptitjano self-assigned this Jul 16, 2024
@ptitjano ptitjano added the 3D Relates to QGIS' 3D engine or rendering label Jul 16, 2024
Copy link

github-actions bot commented Jul 16, 2024

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 50baf0a)

Copy link

github-actions bot commented Jul 16, 2024

Tests failed for Qt 5

One or more tests failed using the build from commit 5a80cbe

flat_terrain_1 (testFlatTerrain)

flat_terrain_1

Test failed at testFlatTerrain at tests/src/3d/testqgs3drendering.cpp:293

dem_terrain_1 (testDemTerrain)

dem_terrain_1

Test failed at testDemTerrain at tests/src/3d/testqgs3drendering.cpp:345

Rendered image did not match tests/testdata/control_images/3d/expected_dem_terrain_1/expected_dem_terrain_1.png (found 210358 pixels different)

polygon3d_extrusion (testExtrudedPolygons)

polygon3d_extrusion

Test failed at testExtrudedPolygons at tests/src/3d/testqgs3drendering.cpp:421

Rendered image did not match tests/testdata/control_images/3d/expected_polygon3d_extrusion/expected_polygon3d_extrusion.png (found 270865 pixels different)

polygon3d_extrusion_data_defined_phong (testExtrudedPolygonsDataDefinedPhong)

polygon3d_extrusion_data_defined_phong

Test failed at testExtrudedPolygonsDataDefinedPhong at tests/src/3d/testqgs3drendering.cpp:539

Rendered image did not match tests/testdata/control_images/3d/expected_polygon3d_extrusion_data_defined_phong/expected_polygon3d_extrusion_data_defined_phong.png (found 270870 pixels different)

polygon3d_extrusion_data_defined_gooch (testExtrudedPolygonsDataDefinedGooch)

polygon3d_extrusion_data_defined_gooch

Test failed at testExtrudedPolygonsDataDefinedGooch at tests/src/3d/testqgs3drendering.cpp:595

Rendered image did not match tests/testdata/control_images/3d/expected_polygon3d_extrusion_data_defined_gooch/expected_polygon3d_extrusion_data_defined_gooch.png (found 270886 pixels different)

polygon3d_extrusion_gooch_shading (testExtrudedPolygonsGoochShading)

polygon3d_extrusion_gooch_shading

Test failed at testExtrudedPolygonsGoochShading at tests/src/3d/testqgs3drendering.cpp:641

terrain_theme (testMapTheme)

terrain_theme

Test failed at testMapTheme at tests/src/3d/testqgs3drendering.cpp:1041

flat_terrain_filtered_1 (testFilteredFlatTerrain)

flat_terrain_filtered_1

Test failed at testFilteredFlatTerrain at tests/src/3d/testqgs3drendering.cpp:1423

dem_terrain_filtered_1 (testFilteredDemTerrain)

dem_terrain_filtered_1

Test failed at testFilteredDemTerrain at tests/src/3d/testqgs3drendering.cpp:1468

Rendered image did not match tests/testdata/control_images/3d/expected_dem_terrain_filtered_1/expected_dem_terrain_filtered_1.png (found 52451 pixels different)

polygon3d_extrusion_filtered (testFilteredExtrudedPolygons)

polygon3d_extrusion_filtered

Test failed at testFilteredExtrudedPolygons at tests/src/3d/testqgs3drendering.cpp:1525

Rendered image did not match tests/testdata/control_images/3d/expected_polygon3d_extrusion_filtered/expected_polygon3d_extrusion_filtered.png (found 53882 pixels different)

ambient_occlusion_1 (testAmbientOcclusion)

ambient_occlusion_1

Test failed at testAmbientOcclusion at tests/src/3d/testqgs3drendering.cpp:1576

Rendered image did not match tests/testdata/control_images/3d/expected_ambient_occlusion_1/expected_ambient_occlusion_1.png (found 23975 pixels different)

debug_map_1 (testDebugMap)

debug_map_1

Test failed at testDebugMap at tests/src/3d/testqgs3drendering.cpp:1779

Rendered image did not match tests/testdata/control_images/3d/expected_debug_map_1/expected_debug_map_1.png (found 239452 pixels different)

composer3d_basic_qt5 (testBasic)

composer3d_basic_qt5

Test failed at testBasic at tests/src/3d/testqgslayout3dmap.cpp:107

Rendered image did not match tests/testdata/control_images/composer_3d/expected_composer3d_basic_qt5/expected_composer3d_basic_qt5.png (found 443995 pixels different)

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

Copy link

github-actions bot commented Jul 16, 2024

Tests failed for Qt 6

One or more tests failed using the build from commit 5a80cbe

flat_terrain_1 (testFlatTerrain)

flat_terrain_1

Test failed at testFlatTerrain at tests/src/3d/testqgs3drendering.cpp:293

dem_terrain_1 (testDemTerrain)

dem_terrain_1

Test failed at testDemTerrain at tests/src/3d/testqgs3drendering.cpp:345

Rendered image did not match tests/testdata/control_images/3d/expected_dem_terrain_1/expected_dem_terrain_1.png (found 210364 pixels different)

polygon3d_extrusion (testExtrudedPolygons)

polygon3d_extrusion

Test failed at testExtrudedPolygons at tests/src/3d/testqgs3drendering.cpp:421

Rendered image did not match tests/testdata/control_images/3d/expected_polygon3d_extrusion/expected_polygon3d_extrusion.png (found 270867 pixels different)

polygon3d_extrusion_data_defined_phong (testExtrudedPolygonsDataDefinedPhong)

polygon3d_extrusion_data_defined_phong

Test failed at testExtrudedPolygonsDataDefinedPhong at tests/src/3d/testqgs3drendering.cpp:539

Rendered image did not match tests/testdata/control_images/3d/expected_polygon3d_extrusion_data_defined_phong/expected_polygon3d_extrusion_data_defined_phong.png (found 270856 pixels different)

polygon3d_extrusion_data_defined_gooch (testExtrudedPolygonsDataDefinedGooch)

polygon3d_extrusion_data_defined_gooch

Test failed at testExtrudedPolygonsDataDefinedGooch at tests/src/3d/testqgs3drendering.cpp:595

Rendered image did not match tests/testdata/control_images/3d/expected_polygon3d_extrusion_data_defined_gooch/expected_polygon3d_extrusion_data_defined_gooch.png (found 270876 pixels different)

polygon3d_extrusion_gooch_shading (testExtrudedPolygonsGoochShading)

polygon3d_extrusion_gooch_shading

Test failed at testExtrudedPolygonsGoochShading at tests/src/3d/testqgs3drendering.cpp:641

terrain_theme (testMapTheme)

terrain_theme

Test failed at testMapTheme at tests/src/3d/testqgs3drendering.cpp:1041

flat_terrain_filtered_1 (testFilteredFlatTerrain)

flat_terrain_filtered_1

Test failed at testFilteredFlatTerrain at tests/src/3d/testqgs3drendering.cpp:1423

dem_terrain_filtered_1 (testFilteredDemTerrain)

dem_terrain_filtered_1

Test failed at testFilteredDemTerrain at tests/src/3d/testqgs3drendering.cpp:1468

Rendered image did not match tests/testdata/control_images/3d/expected_dem_terrain_filtered_1/expected_dem_terrain_filtered_1.png (found 52451 pixels different)

polygon3d_extrusion_filtered (testFilteredExtrudedPolygons)

polygon3d_extrusion_filtered

Test failed at testFilteredExtrudedPolygons at tests/src/3d/testqgs3drendering.cpp:1525

Rendered image did not match tests/testdata/control_images/3d/expected_polygon3d_extrusion_filtered/expected_polygon3d_extrusion_filtered.png (found 53882 pixels different)

ambient_occlusion_1 (testAmbientOcclusion)

ambient_occlusion_1

Test failed at testAmbientOcclusion at tests/src/3d/testqgs3drendering.cpp:1576

Rendered image did not match tests/testdata/control_images/3d/expected_ambient_occlusion_1/expected_ambient_occlusion_1.png (found 23978 pixels different)

debug_map_1 (testDebugMap)

debug_map_1

Test failed at testDebugMap at tests/src/3d/testqgs3drendering.cpp:1779

Rendered image did not match tests/testdata/control_images/3d/expected_debug_map_1/expected_debug_map_1.png (found 239471 pixels different)

composer3d_basic_qt6 (testBasic)

composer3d_basic_qt6

Test failed at testBasic at tests/src/3d/testqgslayout3dmap.cpp:109

Rendered image did not match tests/testdata/control_images/composer_3d/expected_composer3d_basic_qt6/expected_composer3d_basic_qt6.png (found 444131 pixels different)

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

@ptitjano ptitjano force-pushed the terrain-qgis-shaders branch 3 times, most recently from 6494e5d to 9664e26 Compare July 19, 2024 13:19
There is no functional change. With this change, the terrain uses a
material defined by QGIS instead of a default Qt3D. This will make it
easier to customize the shader in the future.
This is already waht QgsPhongTexturedMaterialSettings does. The reason
for this change is to avoid the user-set values changing for them when
saving/restoring projects.
This is already waht QgsPhongTexturedMaterialSettings does. The reason
for this change is to avoid the user-set values changing for them when
saving/restoring projects.
@ptitjano ptitjano force-pushed the terrain-qgis-shaders branch 2 times, most recently from 14446d6 to f192260 Compare July 19, 2024 13:30
@ptitjano ptitjano force-pushed the terrain-qgis-shaders branch 3 times, most recently from 5f4552d to 4655e3a Compare July 20, 2024 09:53
This introduces a new class `QgsPhongTexturedMaterial` which is
similar to Qt3D `QDiffuseSpecularMaterial`.
`QgsPhongTexturedMaterial::toMaterial()` now calls
`QgsPhongTexturedMaterial` to create the material. This has no
functional change.

This will make it possible to directly use `QgsPhongTexturedMaterial`
for the terrain in the next commit. Indeed, the texture case needs to
use a `QTexture2D` which cannot be stored in a settings class. This
issue is avoided by directly creating the material instead of using
`QgsPhongTexturedMaterial::toMaterial()`.
There is no functional change. With this change, the terrain uses a
material defined by QGIS instead of a default Qt3D. This will make it
easier to customize the shader in the future.
This is the same material as the qt3d one:
`Qt3DExtras::QTextureMaterial`. It will also be used in the following
commit by the terrain.
There is no functional change. With this change, the terrain uses a
material defined by QGIS instead of a default Qt3D. This will make it
easier to customize the shader in the future.
Copy link
Member

@wonder-sk wonder-sk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looks good to me, thanks for the updates!

@wonder-sk wonder-sk merged commit 8dab246 into qgis:master Aug 19, 2024
28 checks passed
@ptitjano
Copy link
Contributor Author

👍 looks good to me, thanks for the updates!

Thanks for the review.

@ptitjano ptitjano deleted the terrain-qgis-shaders branch August 20, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3D Relates to QGIS' 3D engine or rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants