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

Add "Render as a surface" option to 2D point cloud renderers #55332

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

wonder-sk
Copy link
Member

When enabled, we will do Delaunay triangulation of the points in the current map view, and then render triangles instead of points. For each point we keep its color for interpolation in the triangle.

Global map shading is also supported with the new option, when enabled, we also keep elevation of each point, and then rasterize triangles with interpolated elevations to the provided elevation map.

When "Render as a surface" is enabled, drawing order is ignored, because points do not obscure other points anymore - all input points participate in the triangulation.

There is also an option to filter large triangles (given by the maximum length of edge of a triangle), which is useful when one wants to see the actual holes in the data. Compared to the implementation for 3D rendering, the 2D rendering only provides filtering based on horizontal length of triangles. Filtering based on triangle size on the vertical axis seems irrelevant because the 2D view is always from the top.

Funded by: National Resources Canada

GUI

There's a new group in 2D styling tab - similar to the one that already exists in the 3D styling tab:

pc-2d-surface-gui

Screenshots

As expected, triangulation covers holes between points when zoomed in, but subjectively also gives nicer rendering when zoomed out.

Trencin castle

Disabled Enabled
pc-2d-surface-trencin-full-1 pc-2d-surface-trencin-full-2
pc-2d-surface-trencin-zoom-1 pc-2d-surface-trencin-zoom-2

Global map shading when render as a surface is enabled:

With map shading With map shading, only ground, filtering large triangles
pc-2d-surface-trencin-full-2-shading pc-2d-surface-trencin-full-2-ground-shading-filter

Helsinki train station (RGB)

Disabled Enabled
pc-2d-surface-helsinki-1 pc-2d-surface-helsinki-2
pc-2d-surface-helsinki-full-1 pc-2d-surface-helsinki-full-2

When enabled, we will do Delaunay triangulation of the points in the current
map view, and then render triangles instead of points. For each point we keep
its color for interpolation in the triangle.

Global map shading is also supported with the new option, when enabled, we also
keep elevation of each point, and then rasterize triangles with interpolated
elevations to the provided elevation map.

When "Render as a surface" is enabled, drawing order is ignored, because points
do not obscure other points anymore - all input points participate in the triangulation.

There is also an option to filter large triangles (given by the maximum length of
edge of a triangle), which is useful when one wants to see the actual holes in the data.
Compared to the implementation for 3D rendering, the 2D rendering only provides
filtering based on horizontal length of triangles. Filtering based on triangle size
on the vertical axis seems irrelevant because the 2D view is always from the top.

int red0 = qRed( c0 ), green0 = qGreen( c0 ), blue0 = qBlue( c0 );
int red1 = qRed( c1 ), green1 = qGreen( c1 ), blue1 = qBlue( c1 );
int red2 = qRed( c2 ), green2 = qGreen( c2 ), blue2 = qBlue( c2 );
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's an opportunity here for an optimisation -- we could check if c0 == c1 == c2 (and not elevation map), and if so then just use the QPainter renderPolygon method to draw a filled solid color triangle.

It's a situation that WILL arise frequently, eg for classified point clouds.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have tried this, but unfortunately it leaves ugly artifacts at the edges between barycentric-based and QPainter-based triangles - even when I use 1px solid pen in addition to the brush fill for QPainter, and I would prefer not to use thicker pens. After this initial work, I would like to do a bit of profiling, so if possible I would prefer to leave optimisation for later (moreover, for attribute by ramp or RGB, the QPainter solid triangle path would not get triggered often)

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, fair enough!

src/core/pointcloud/qgspointcloudrenderer.h Outdated Show resolved Hide resolved
@nyalldawson nyalldawson merged commit fbc2082 into qgis:master Nov 22, 2023
30 checks passed
@zacharlie zacharlie added the Changelog Items that are queued to appear in the visual changelog - remove after harvesting label Jan 21, 2024
@qgis-bot
Copy link
Collaborator

@wonder-sk

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@zacharlie zacharlie added ChangelogHarvested This PR description has been harvested in the Changelog already. and removed Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Jan 21, 2024
@DelazJ DelazJ added the Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. label Apr 16, 2024
@qgis-bot
Copy link
Collaborator

@wonder-sk
A documentation ticket has been opened at qgis/QGIS-Documentation#9024
It is your responsibility to visit this ticket and add as much detail as possible for the documentation team to correctly document this change.
Thank you!

@qgis-bot
Copy link
Collaborator

@wonder-sk
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ChangelogHarvested This PR description has been harvested in the Changelog already. Feature Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Point Clouds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants