Rendering pipeline for pointcloud interactions

Godot Version

4.3-stable

Some context

I’ve been working on a pointcloud renderer in OpenGL and I’m now looking to rebuild it in Godot to add more features.

One key advantage of my OpenGL renderer is its ability to efficiently query the indices of visible points without relying on either:

  • Rebuilding a spatial search data structure every time the pointcloud is modified.
  • Casting rays against millions of small bounding boxes.

This is useful because it enables:

  • Point Selection: Click on a displayed point and retrieve its index to access metadata (e.g., position, intensity, color, time, source).
  • Intuitive Navigation Controls:
    • Zoom: Zooming in/out focuses on the hovered point.
    • Pan: The hovered point “locks” to the mouse.
    • Rotate: Rotation orbits around the initial hovered point.

Here’s a short animated example of the renderer and the controls

OpenGL rendering pipeline

To be able to quickly query displayed point indices, my current implementation uses a deferred shading approach which boils down to two main shaders:

  • First Shader (MRT - Multiple Render Targets): Writes to a set of viewport-sized textures:
    • PointColor
    • DistanceFromCamera (used for Eye-Dome Lighting)
    • PointIndex (using gl_PrimitiveID)
  • Second Shader: Renders the PointColor texture to a fullscreen quad. Optionally, it uses DistanceFromCamera for EDL shading

Using this pipeline, I can use glReadPixels on the PointIndex texture with the clicked viewport coordinate. This approach returns the point index very efficiently, even with very large pointclouds. The DistanceFromCamera texture ensures the closest point to the camera is selected in ambiguous regions.

Question

I understand that implementing this approach in Godot will likely require compute shaders. However, I’m struggling to get started with the limited examples available.

  • Is such a pipeline feasible in Godot 4?
  • Alternatively, is there a more efficient way to achieve point selection and interaction in Godot (e.g., via ray casting techniques for point clouds)?

Any insights, pointers, or relevant resources would be greatly appreciated!