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

Pointcloud improvement #732

Merged
merged 2 commits into from
Apr 27, 2018
Merged

Pointcloud improvement #732

merged 2 commits into from
Apr 27, 2018

Conversation

peppsac
Copy link
Contributor

@peppsac peppsac commented Apr 16, 2018

2 commits improving pointcloud support for itowns.

The first one fixes the point budget handling for .bin format.

The second reworks SSE: it's similar to #674 but simpler and only for pointclouds.

Full commits message:

  • refactor(pointcloud): rework point budget implementation
Since .bin and .cin have different repartitions of the points inside a node,
they must use different algorithms.
For .cin we want to draw a %-age of each node because points are evenly
distributed.
For .bin, we sort the nodes by 'importance', and stop drawing nodes when we
have enoug points.
  • refactor(pointcloud): simplify SSE computation for pointcloud
Project average point spacing on screen and compare to sse threshold.
It's a simplification of the approach proposed in #674.

This allows to drop a dependency (convexhull) and brings the SSE
computation for pointcloud closer to what is done for other geometries.

Edit:
The SSE value computed here is the estimation of the maximum distance between 2 points in a given node.
PotreeConverter guarantees that the distance between each pair of points is >= metadata.spacing / node.level in all nodes. This is easy to visualize if you display successive children (using the 'sticky' debug tool):
distances

The SSE is the estimation of this distance projected on the screen.

@peppsac peppsac force-pushed the pointcloud_improvment branch 2 times, most recently from 279a857 to 181d1ee Compare April 16, 2018 16:02
@peppsac peppsac changed the title Pointcloud improvment Pointcloud improvement Apr 17, 2018
@peppsac peppsac force-pushed the pointcloud_improvment branch from 181d1ee to e4592df Compare April 20, 2018 09:54
@peppsac
Copy link
Contributor Author

peppsac commented Apr 20, 2018

Edited description + added image

Copy link
Collaborator

@mbredif mbredif 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 and simplifies things, thanks !
I added a few comments to improve it even further :)
(I have not tested it though)

@@ -155,7 +78,7 @@ function markForDeletion(elt) {

if (!elt.notVisibleSince) {
elt.notVisibleSince = Date.now();
elt.shouldBeLoaded = -1;
elt.sse = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe you could add a comment here stating what -1 means

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -169,6 +92,11 @@ export default {
return [];
}

context.camera.preSSE =
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could link here to an existing technical paper to explain the derivation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

} else if (!elt.promise) {
const distance = Math.max(0.001, bbox.distanceToPoint(context.camera.camera3D.position));
const priority = computeScreenSpaceError(context, layer, elt, distance) / distance;
elt.promise = context.scheduler.execute({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you divide by distance ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To load closest node first.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I understand correctly, minimizing SSE is what you want eventually (as things settle), but you prefer to bias the ordering of the fetches towards closer nodes, even if those have a smaller SSE. Is that correct ? I think a comment should be placed here for future reference (eg, we might want to enable the customization of this strategy)

const count = Math.max(1.0, Math.floor(pts.geometry.drawRange.count * reduction));
pts.geometry.setDrawRange(0, count);
// 2 different point count limit implementation, depending on the pointcloud source
if (layer.metadata.customBinFormat) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would rather have the processing be agnostic of formats, nut depend rather on format properties or strategies. Could not you have reordered bin files as in cin files, or the other way around?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about renaming customBinFormat to something like prefixSubsampling ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a layer.supportsProgressiveDisplay property. (Note that the rest of the file relies on the potreeconverter format, there's more work to do to be able to use this processing code on any pointcloud source)

@gchoqueux
Copy link
Contributor

this commit : refactor(pointcloud): rework point budget implementation
Does it allow PointCloud to be fully compliant with the data potree (from potree converter)? Especially in the organization of points in the data structure

@peppsac
Copy link
Contributor Author

peppsac commented Apr 26, 2018

this commit : refactor(pointcloud): rework point budget implementation
Does it allow PointCloud to be fully compliant with the data potree (from potree converter)? Especially in the organization of points in the data structure

Yes.

Copy link
Collaborator

@mbredif mbredif left a comment

Choose a reason for hiding this comment

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

LGTM

} else if (!elt.promise) {
const distance = Math.max(0.001, bbox.distanceToPoint(context.camera.camera3D.position));
const priority = computeScreenSpaceError(context, layer, elt, distance) / distance;
elt.promise = context.scheduler.execute({
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I understand correctly, minimizing SSE is what you want eventually (as things settle), but you prefer to bias the ordering of the fetches towards closer nodes, even if those have a smaller SSE. Is that correct ? I think a comment should be placed here for future reference (eg, we might want to enable the customization of this strategy)

return { shouldBeLoaded, surfaceOnScreen: 0 };
function computeScreenSpaceError(context, layer, elt, distance) {
if (distance <= 0) {
return layer.sseThreshold;
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it equivalent to returning Infinity ? (which would be parameterless and thus more explicit)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. I addressed both comments.

@gchoqueux
Copy link
Contributor

Ok thanks, it's good to be completely compliant with Potree data

peppsac added 2 commits April 27, 2018 11:31
Since .bin and .cin have different repartitions of the points inside a node,
they must use different algorithms.
For .cin we want to draw a %-age of each node because points are evenly
distributed.
For .bin, we sort the nodes by 'importance', and stop drawing nodes when we
have enoug points.
Project average point spacing on screen and compare to sse threshold.
It's a simplification of the approach proposed in #674.

This allows to drop a dependency (convexhull) and brings the SSE
compuation for pointcloud closer to what is done for other geometries.
@peppsac peppsac force-pushed the pointcloud_improvment branch from 9af92a7 to 24c618b Compare April 27, 2018 09:36
Copy link
Collaborator

@mbredif mbredif left a comment

Choose a reason for hiding this comment

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

LGTM

@peppsac peppsac merged commit 739f053 into master Apr 27, 2018
@peppsac
Copy link
Contributor Author

peppsac commented Apr 27, 2018

Thanks for the review @mbredif - and welcome to the @iTowns/reviewers team !

@peppsac peppsac deleted the pointcloud_improvment branch April 27, 2018 12:02
@autra
Copy link
Contributor

autra commented Apr 27, 2018

Thanks for the review @mbredif - and welcome to the @iTowns/reviewers team !

actually he just has write access. The convention is : a review from someone from itowns-reviewers group.

Nevermind, I'll make some comments on this if needed and we'll do a followup, ok for you?

@peppsac
Copy link
Contributor Author

peppsac commented Apr 27, 2018

Oops my bad. I'm reverting this PR then, until your approval.

@peppsac peppsac restored the pointcloud_improvment branch April 27, 2018 12:20
@peppsac peppsac deleted the pointcloud_improvment branch April 27, 2018 12:20
@peppsac peppsac restored the pointcloud_improvment branch April 27, 2018 12:20
@peppsac peppsac mentioned this pull request Apr 27, 2018
@peppsac
Copy link
Contributor Author

peppsac commented Apr 27, 2018

PR reverted in #745 and reopened as #746.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants