Skip to content

Remove lines geom shader - #67356

Open
ViperMiniQ wants to merge 4 commits into
qgis:masterfrom
ViperMiniQ:remove-lines-geom-shader
Open

ViperMiniQ wants to merge 4 commits into
qgis:masterfrom
ViperMiniQ:remove-lines-geom-shader

Conversation

@ViperMiniQ

Copy link
Copy Markdown
Contributor

This PR removes the geometry shader for lines (part 3 of qgis/QGIS-Enhancement-Proposals#381).

Lines are now instanced.
Two render passes are done. One is for the segments themselves, the other is for segment joins.

For multisegment lines, the part where the lines touch is “cut”.
The cut empty space is then filled with the join.

Screenshot_20260903_094925 Screenshot_20260903_100347
Screencast_20260909_090205.webm

The above screencast shows the semi-transparent lines. We do not officially support them in QGIS, this is just to showcase how there is no overlap between join-lines and line-line. The overlap visible at one point between the lines when looking back is because of the order of the lines, that is something to consider if opacity would be supported (again, not planed for here).

Supported join types are miter and bevel.

MITER_LIMIT has been set to never create MITER joins.
That was made because the old code also never created miters, always bevels.
If that were to change at any point, test cases will have to be updated (also one of the reasons I did not do it here).

Implementation taken from:

(first part instancing of the lines)
https://wwwtyro.net/2019/11/18/instanced-lines.html
(second part, joins)
https://wwwtyro.net/2021/10/01/instanced-lines-part-2.html

AI tool usage

  • AI tool(s) (Copilot, Claude, or something similar) supported my development of this PR. See our policy about AI tool use. Use of AI tools must be indicated. Failure to be honest might result in banning.

- build line segments using pointA and pointB attributes
- pass additional pointC to line_joins shader for calculating the joins
- render joins as a separate instances (second pass)
- handle duplicates in cpp, rather than in shaders
- introduce enum to distinguish between segments and joins
- clip away the segments at joins, two segments should not overlap at joins and joins are also clipped to fill the space between the segments, but not to overlap them
- rename shader
- fix joins not showing from certain angles
@github-actions github-actions Bot added this to the 4.4.0 milestone Sep 9, 2026
@github-actions github-actions Bot added the 3D Relates to QGIS' 3D engine or rendering label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Tests failed for Qt 6 (ALL_BUT_PROVIDERS - fedora)

One or more tests failed using the build from commit b4566b5

4978_line_rendering_1 (testEpsg4978LineRendering)

4978_line_rendering_1

Test failed at testEpsg4978LineRendering at tests/src/3d/testqgs3drendering.cpp:1973

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

polygon_edges_height (testPolygonsEdges)

polygon_edges_height

Test failed at testPolygonsEdges at tests/src/3d/testqgs3drendering.cpp:609

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

line_rendering_1 (testLineRendering)

line_rendering_1

Test failed at testLineRendering at tests/src/3d/testqgs3drendering.cpp:657

line_rendering_1 (testLineRenderingClipping)

line_rendering_1

Test failed at testLineRenderingClipping at tests/src/3d/testqgs3drendering.cpp:714

line_rendering_1 (testLineRenderingCurved)

line_rendering_1

Test failed at testLineRenderingCurved at tests/src/3d/testqgs3drendering.cpp:800

rubberband_3d_hidden_last_marker (testRubberBandHiddenLastMarker)

rubberband_3d_hidden_last_marker

Test failed at testRubberBandHiddenLastMarker at tests/src/3d/testqgsrubberband3drendering.cpp:249

Rendered image did not match tests/testdata/control_images/3d/expected_rubberband_3d_hidden_last_marker/default/expected_rubberband_3d_hidden_last_marker.png (found 85 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.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Tests failed for Qt 6 (ALL_BUT_PROVIDERS - ubuntu)

One or more tests failed using the build from commit b4566b5

4978_line_rendering_1 (testEpsg4978LineRendering)

4978_line_rendering_1

Test failed at testEpsg4978LineRendering at tests/src/3d/testqgs3drendering.cpp:1973

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

polygon_edges_height (testPolygonsEdges)

polygon_edges_height

Test failed at testPolygonsEdges at tests/src/3d/testqgs3drendering.cpp:609

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

line_rendering_1 (testLineRendering)

line_rendering_1

Test failed at testLineRendering at tests/src/3d/testqgs3drendering.cpp:657

line_rendering_1 (testLineRenderingClipping)

line_rendering_1

Test failed at testLineRenderingClipping at tests/src/3d/testqgs3drendering.cpp:714

line_rendering_1 (testLineRenderingCurved)

line_rendering_1

Test failed at testLineRenderingCurved at tests/src/3d/testqgs3drendering.cpp:800

rubberband_3d_hidden_last_marker (testRubberBandHiddenLastMarker)

rubberband_3d_hidden_last_marker

Test failed at testRubberBandHiddenLastMarker at tests/src/3d/testqgsrubberband3drendering.cpp:249

Rendered image did not match tests/testdata/control_images/3d/expected_rubberband_3d_hidden_last_marker/default/expected_rubberband_3d_hidden_last_marker.png (found 85 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.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
To execute locally, unzip the downloaded zip file and run bin\qgis-bin.exe in the extracted directory.
You might be prompted by Windows Defender click "Run anyway"
(Built from commit b4566b5)

🍎 MacOS Qt6 builds

Download MacOS Qt6 builds of this PR for testing.
This app is not notarized, run sudo xattr -d com.apple.quarantine /Applications/QGIS*.app to avoid the warning
(Built from commit b4566b5)

- if we filter in 2d only, we miss points that are behind/on top of one another
- fix assert
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.

1 participant