Skip to content

Add Depth Fade Point visualisation style for PointCloud rendering#1648

Open
ksuszka wants to merge 2 commits intoros2:rollingfrom
AutonomousSystemsPL:depth-fade-point-cloud-rendering-rolling
Open

Add Depth Fade Point visualisation style for PointCloud rendering#1648
ksuszka wants to merge 2 commits intoros2:rollingfrom
AutonomousSystemsPL:depth-fade-point-cloud-rendering-rolling

Conversation

@ksuszka
Copy link

@ksuszka ksuszka commented Dec 19, 2025

Description

This PR adds new point cloud visualization style "Depth Fade Points" which uses custom vertex shader to simulate depth without creating additional vertices. The effect is similar to what "Flat Squares" style does, however VRAM consumption is 4 times smaller.
For 10,000,000 point cloud "Flat Squares" takes 0.9GB of VRAM on my card and "Depth Fade Points" takes 0.2GB of VRAM.

This new vertex shader employs three techniques to simulate depth fading:

First, it calculates the size of the rendered point shape required to simulate depth based on set world size and distance to the camera.
If the calculated size is smaller than 1px (which cannot be render) then it keeps the point size at 1px and tries to reduce point alpha value to simulate depth.
If the calculated alpha value is too small (which would cause rendering artifacts) than it uses stochastic point removal to achieve required perceived depth.

Did you use Generative AI?

The hash function in the vertex shader was generated using ChatGPT.

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

I testes this new feature with

ros2 run point_cloud_transport_tutorial publisher_test

I can see that sometimes the point cloud is blinking.

Image

@ksuszka ksuszka force-pushed the depth-fade-point-cloud-rendering-rolling branch from fdd2cdb to 427788a Compare December 19, 2025 22:17
@ksuszka
Copy link
Author

ksuszka commented Dec 19, 2025

@ahcorde I think I fixed it by adding missing condition in the PointCloud::getRenderOperationType() function. Now it behaves the same as in Flat Square mode on ROS Rolling inside WSL2 on Windows 11 with RTX 3090.

What is interesting - I developed this on ROS Humble inside a docker container running on Ubuntu 24 host with RTX 3060 with a huge static point cloud and I didn't observe any issues. However when I tested it on ROS Rolling inside WSL2 on Windows 11 with point_cloud_transport_tutorial the issue appeared immediately - it is enough to move mouse over rendered point cloud during playback and cloud disappears. Looking on the missing condition in the PointCloud::getRenderOperationType() function I wonder why it worked in the first place.

What is worth mentioning - with this fix it behaves the same as Flat Square mode but it doesn't mean it behaves correctly. When I set alpha on the point cloud to 0.1 and I hover with my mouse over the point cloud it switches between transparent/opaque mode, but it does so for every other mode and only for dynamic point clouds. It doesn't happen for a static point cloud.

UPDATE: I've modified my answer after finding that the difference in behavior is not releated to WSL/Ubuntu but to testing it with dynamic/static point clouds.

@ksuszka ksuszka force-pushed the depth-fade-point-cloud-rendering-rolling branch from 61f8369 to fbe830f Compare December 22, 2025 14:19
@ksuszka
Copy link
Author

ksuszka commented Dec 23, 2025

@ahcorde I wonder if naming chosen here is the best. I think we can easily modify this code to use the same technique to render points as circles not squares and probably some folks would prefer that. So we can add two modes instead of one. So maybe something like "Square Points" and "Round Points" or "Fading Square Points" and "Fading Round Points" would be better? (I keep using "fading" in the name to signal possible dropping of points in the distance, but maybe it is superfluous)

What do you think?

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.

2 participants