How arthurbrussee/brush works
Project Type and Purpose
• The project is a 3D reconstruction engine (“Brush”) that uses machine learning alongside real-time GPU rendering (utilizing WebGPU) to perform reconstruction via Gaussian splatting.
• It is designed for a range of environments – desktop (macOS/windows/linux), Android, and browsers – and provides interfaces as a CLI, a web demo (using Trunk), and even rerun integration for visualization while training.
• The README emphasizes support for both training (including on mobile/browser) and viewing, with performance benchmarks and a focus on efficient and dependency-free deliverables.
Analyzing the File Structure
• The workspace is organized into multiple “crates” (each one in its own folder under the crates/ directory) such as brush-app (which likely is the web viewer), brush-android (for Android builds), brush-cli (providing the command-line interface), brush-train (for training logic), brush-render (managing rendering operations), and several others (brush-dataset, brush-process, brush-kernel, brush-ui, brush-wgsl, etc).
• Many crates include subdirectories for sources, tests, and even shader files – indicating that GPU code (wgsl shaders) is an important part of the architecture.
• The existence of directories like .github/workflows, Trunk.toml, and examples/ further indicates CI/CD integration, web packaging (via trunk), and example usage.
Components and Their Relationships
a. Main Components/Subsystems:
• Core Libraries: These include the low-level modules that handle GPU kernels (brush-kernel, brush-wgsl), sorting (brush-sort), prefix-sum computations (brush-prefix-sum), and process loops (brush-process).
• Training Module: Crates like brush-train and possibly parts of brush-process and brush-dataset handle the training pipeline from dataset ingestion (supporting COLMAP and Nerfstudio formats) to the running of training loops.
• Rendering & Viewer: brush-render and brush-ui (plus the web-oriented brush-app) form the rendering engine that takes the trained data and displays it using WebGPU. There is also mention of a CLI mode that can launch the viewer.
• Command-Line Interface: brush-cli provides the CLI interface to invoke training, rendering, or debugging sessions. The integration with rerun is another layer here that supports real-time visualization.
• Platform-Specific Frontends: brush-android for Android-specific builds, and the web build using Trunk (configured via Trunk.toml and assets in brush-app) for browser-based demo.
b. Data Flow & Interactions:
• The training component ingests input data (images, COLMAP or Nerfstudio datasets, possibly with masks) and passes it to the training engine, which uses GPU-accelerated kernels (via burn and wgpu) for optimizing the scene representation.
• Once the training is in progress (or complete), rendering components take the gaussian splat data and pass it to the viewer/UI. In the web and CLI versions, this is displayed through interactive controls (orbit, flythrough).
• The CLI and platform-specific apps (Android, Web) use the same underlying libraries but provide tailored frontends using either native widgets or web assets.
• External tools and integrations such as rerun add another visualization stream to the training process.
c. Architectural Patterns & Technologies:
• Modularity: Each key functional area (training, rendering, dataset management) is separated into its own crate, making the system modular and extensible.
• Cross-Platform Abstraction: By abstracting over WebGPU (via wgpu) and using the Burn ML framework, the project achieves portability across different hardware and operating systems.
• Separation of concerns: With clear boundaries in the file tree (e.g., separate folders for Android, CLI, App), the design emphasizes that the core functionality is decoupled from the platform-specific presentation.
Elements
• Clear labels for each component block (e.g., “Brush-Train (Training Logic)”, “Brush-Render (Rendering Pipeline)”, “Brush-App (Web Viewer)”, “Brush-Android (Android UI)”, “Brush-CLI (Command-line Interface)”).
• Input data (images, datasets) flowing into the training module.
• Processed scene representations flowing into the rendering module.
• Viewer inputs (orbit controls, flythrough commands) affecting interactive components.
• Rectangles for core processing modules.
• Parallelograms for interfaces (CLI, Web, Android).