extend_without_forking.mp4
This example demonstrates how to extend the Rerun Viewer with custom visualization capabilities without needing to fork the internal codebase.
Specifically, it implements a Signed Distance Field (SDF) visualizer. The example defines a custom archetype, a visualizer to handle the data, and a custom GPU renderer to draw the SDF in a 3D spatial view.
The code for this example was generated by the prompt:
Using Rerun 0.30.0 it is possible to "extend existing
views without forking" which you can read about here:
https://github.com/rerun-io/rerun/releases/tag/0.30.0.
There is also an example of how this can be done here:
https://github.com/rerun-io/rerun/tree/latest/examples/rust/custom_visualizer.
I want you to make something similar to the
custom_visualizer in the second link. However, instead
of showing a height field, I would like you to create a
custom signed distance field visualizer. Other than that,
keep it similar to the custom_visualizer.
Later, the prompt was changed to fix a bug and add animation. The video above shows the process of how the custom SDF visualizer was created.
- Custom Archetype:
SignedDistanceField, which stores a 2D grid off32values. - Custom Visualizer: Interprets the SDF data and prepares it for rendering.
- Custom GPU Renderer: A specialized shader-based renderer that draws:
- Blue: Inside the shape (negative SDF).
- Red: Outside the shape (positive SDF).
- Yellow: The zero-level boundary (the isosurface).
- Dark Lines: Equidistant isocurves for visual depth.
- Live Animation: Continuously streams SDF frames to show real-time updates.
- Archetype (
sdf_archetype.rs): Defines the data structure that Rerun's SDK and Viewer understand. - Visualizer (
sdf_visualizer.rs): Acts as the bridge between the logged data and the renderer. It queries theSignedDistanceFielddata from the Rerun database. - Renderer (
sdf_renderer.rs): Uses WGPU to implement a custom rendering pass that draws the SDF on a mesh. - Extension (
main.rs): Registers the custom visualizer into the standardSpatial3DViewusingapp.extend_view_class.
Make sure you have Rust installed.
cargo runThis will launch a custom Rerun Viewer and immediately start playing a live SDF animation of blending circles and shapes.