Projects / HEPBlenderFusion
Local Research Project

⚛️ HEPBlenderFusion

Bridging High-Energy Physics with High-Fidelity 3D Visualisation — a real-time gRPC bridge between Geant4 particle physics simulations and Blender's rendering engine.

<100msLatency
10-50xViewport Perf
8Physics Lists
v1.0Production Ready
C++17Python 3.8+gRPC Protocol BuffersGeant4Blender APIBMesh
← All Projects

TL;DR — Quick Summary

The Bridge-First Architecture

The defining architectural decision is language-agnostic API design using Protocol Buffers and gRPC over HTTP/2. Instead of tightly coupling two very different systems (C++ Geant4 and Python Blender), the project defines a clean contract in hep.proto and implements it independently in both languages.

C++ Geant4 Daemon — The Engine

A persistent background server managing the Geant4 run manager, GDML geometry loading, and physics processes. Implements a custom G4SteppingAction to capture track data at every simulation step. Serves as the gRPC server, streaming TrackFrame messages to the client. Thread-safe state machine governs run control.

gRPC Bridge — The Nervous System

Bidirectional streaming over HTTP/2: the client sends commands (Start, Pause, Stop, Step) while simultaneously receiving a stream of track data. TrackFrame objects group particle steps into chunks to minimise latency. CRC32 checksums on every frame ensure data integrity during high-speed streaming.

Blender Python Addon — The Interface

Context-aware Blender UI panel for simulation configuration. Background thread for non-blocking gRPC communication (prevents Blender UI freeze during streaming). BMesh-based Single-Mesh Architecture for ultra-fast rendering. Geometry Nodes for energy-dependent track thickness.

Interactive State Machine

IDLE → RUNNING → PAUSED → FINISHED. C++ std::condition_variable suspends the Geant4 event loop without consuming CPU cycles. "Step Event" mode processes exactly one physics event then pauses — ideal for debugging complex shower topologies.

Technical Innovations

🚀 Single-Mesh BMesh Architecture

Traditional Blender addons create one object per particle track. In a HEP event with 1,000+ tracks, this causes thousands of draw calls and materials — freezing the viewport. The solution: all tracks consolidated into a single Blender Mesh object using the low-level BMesh API. Vertices and edges are added dynamically as data streams in. Result: 10-50x viewport performance improvement, maintaining 30-60 FPS even with 10,000+ track segments.

🎨 Vertex Colour Particle Identification

Instead of thousands of materials (one per particle type), each particle species is encoded as a specific RGB value in the vertex colour layer (Electrons = Green, Photons = Yellow, Muons = Blue, etc.). A single material renders all 20+ particle types with clear visual distinction. The alpha channel is reserved for energy encoding.

⚡ Geometry Nodes Energy Modulation — "Bragg Peak" Visualisation

The energy deposited at each simulation step is stored in the alpha channel of the vertex colour. A Geometry Nodes modifier reads this alpha value and modulates the track thickness in real-time — thicker tracks where more energy is deposited. This creates an immediate, intuitive visual representation of the Bragg Peak (the characteristic energy loss spike as charged particles slow to a stop), requiring zero post-processing.

Scientific Foundation

HEPBlenderFusion supports 8 industry-standard Geant4 physics lists via the G4PhysListFactory, covering the full range of HEP use cases:

FTFP_BERT — Recommended default for HEP (balanced)
QGSP_BERT — Standard for LHC experiments
QGSP_BIC — Proton & ion therapy simulations
QBBC — Fast & accurate for medical physics
Shielding — Radiation protection studies
QGSP_BERT_HP — High-precision neutron transport
LBE — Low-background experiment optimisation
G4EmStandardPhysics — Pure EM for fast testing

Particle support: e⁻, e⁺, γ, proton, neutron, μ⁺/⁻, π⁺/⁻, and more. Energy ranges from MeV to TeV.

Outcomes

<100ms Physics-to-Render Latency
From Geant4 physics event to 3D visualisation in Blender — zero perceptible delay
🛡️
17 Error Recovery Paths
Zero known crash scenarios after 11 major development patches and production stability testing
🔬
Scientific Validation
Energy conservation and particle identification verified across all 8 supported physics lists
🌍
Community Accessibility
Non-C++ experts can access full Geant4 power through a user-friendly Blender UI — democratising HEP visualisation
← All Projects