WorksPhysics and Astronomy
A virtual reality extension for the Geant4 toolkit
Abstract
Geant4 is a toolkit for simulating particle interactions in matter that is widely used in particle physics, nuclear physics, medical imaging, and astrophysics. At present, Geant4 visualizations are generally viewed on a conventional, two-dimensional computer display. To enhance immersion, we have developed G4VR, a virtual reality (VR) application that extends Geant4 with VR capabilities, providing a more intuitive and comprehensive way to understand these interactions. The user running G4VR in a headset can get detailed information about individual tracks, interactions, and energy depositions by selecting them with the hand controllers. G4VR also allows the user to examine the chronology of interactions, and includes animations of entire events as immersive movies. G4VR includes built-in event displays of several types that allow a first-time user to easily explore its various functionalities. To interface with Geant4, we have developed a new visualization driver called G4XR that allows direct integration with the Geant4 source code. This enables any Geant4 experiment to be loaded and experienced in VR seamlessly.
Introduction
Versatile event display systems are a core component of modern physics experiments. Specialized tools have been developed to enable dynamic visualization of experimental geometries and event data, such as those used in the ATLAS [1] and CMS [2, 3, 4] experiments. These advancements are in line with a broader community vision of developing visualization tools for experiments [5]. 3D visualization is widely used for MRI and CT data, with recent work exploring interactive visualization of these data in augmented and extended reality environments [6, 7, 8]. However, the majority of these tools are restricted to desktop-based environments, offering primarily 2D or 3D visualizations with interactions limited to mouse and keyboard input, such as zooming and rotation.
While effective, these approaches impose several limitations, including restricted field of view, limited mobility, frequent reliance on panning and zooming, and issues with occlusion. Recent advances in visual computing, particularly virtual reality (VR), offer a promising alternative that remains relatively under-explored in this context. VR enables immersive interaction with event data, providing users with more intuitive navigation through complex scenes, more natural gesture-based controls, and a wider field of view. These capabilities have the potential to enhance a user’s understanding of experimental data beyond what is achievable with traditional desktop displays.
Some progress has been made toward integrating event displays with VR, demonstrating growing interest within the HEP community [9, 10, 11, 12, 13]. However, existing approaches are typically tailored to specific experiments and thus remain limited in scope. A general-purpose platform for integrating event displays with VR is still lacking. As a widely used Monte Carlo simulation toolkit, Geant4 serves as a common foundation for experiments in particle physics, astrophysics, and medical imaging [14, 15, 16]. Within this framework, users define experimental geometries and particle sources, and the toolkit simulates particle interactions in matter.
Given its broad adoption, a VR visualization framework built around Geant4 could significantly expand access to immersive event displays across multiple domains. To address this, we have developed G4VR, a VR-based application for Geant4 simulations. In addition, we introduce a new XR visualization driver that integrates directly with the toolkit [17], enabling experiment-agnostic access to VR-based visualization.
The remainder of the paper is organized as follows: Section 2 discusses the development of the novel XR visualization driver in Geant4 for VR integration. Section 3 describes the 3D asset processing in G4VR and the various features available to users. Section 4 demonstrates the example event displays built into G4VR. Section 5 presents the computational performance of the example scenes in G4VR. In Section 6, we discuss conclusions and outlook. Appendix A discusses installing the G4XR driver and G4VR application and using them.
G4XR Driver
XR Driver Functionality
The native Geant4 visualization framework supports many graphics systems, both built-in and third-party. These include OpenGL, Qt3D, and VTK, among others [17, 18]. Each of these visualization systems is supported by visualization, or vis, drivers, which interface with the Geant4 kernel to render event displays. Users are given the option to configure Geant4 graphics support as desired through CMake when building the toolkit from source.
For a generic vis driver, the Geant4 scene is composed of models such as G4PhysicalVolumeModel, G4TrajectoriesModel, and G4HitsModel. Each wraps a different type of Geant4 kernel object. When a scene is drawn, these models traverse their underlying objects and pass visualization primitives to the active G4VSceneHandler through the appropriate AddPrimitive() overload. The scene handler then converts these primitives into driver-specific representations used by the G4VViewer to display the scene. This forms the basis of several current vis drivers in Geant4, and we leverage this principle in developing the associated driver for VR purposes. Here, the primitives supplied by the models must be translated to VR-compatible formats, as detailed below. Furthermore, the driver is implemented such that it can be
class G4XrSceneHandler : public G4VSceneHandler
{
public:
G4XrSceneHandler(G4VGraphicsSystem& system, const G4String& name);
virtual ~G4XrSceneHandler() override;
using G4VSceneHandler::AddPrimitive;
void AddPrimitive(const G4Polyline&) override;
void AddPrimitive(const G4Circle&) override;
void AddPrimitive(const G4Square&) override;
void AddPrimitive(const G4Polyhedron&) override;
void EndModeling() override;
void ConvertMeshToGLB(const std::string& outputFile);
void CollectTrackData(const G4VTrajectory* traj, G4double r, G4double g,
G4double b);
void CollectHitData(const G4VHit* hit);
void WriteTrackBinary(const TrackData& t);
void FinalizeBinary();
std::vector<MeshData> GetCollectedMeshes(){return collectedMeshes;}
std::vector<TrackData> GetCollectedTracks(){return collectedTracks;}
};
readily built and used directly from source. We call this the vis XR or G4XR driver. The name G4XR is chosen to accommodate both the current G4VR support and potential future Augmented Reality (AR) developments. We leave the integration of AR functionality to future investigations.
The vis XR driver consists of three extended classes:
G4Xr: the central class that is invoked by the user when the driver is launched. It coordinates the other classes in the driver during each run. It inherits from the
G4VGraphicsSystemclass.G4XrSceneHandler: receives the primitives supplied by the scene’s models and writes the corresponding geometry and particle trajectory assets to be used by G4VR on a per-run basis. In particular, it creates binary track files and binary Graphics Library Transmission Format (glTF) files detailed below. The class inherits from
G4VSceneHandler.G4XrViewer: controls the asset transfer to G4VR through a local server and manages produced files when the driver is deactivated. It inherits from the
G4VViewerclass.
A low-level interface for the G4XrSceneHandler class is shown in Figure 1, written in C++. When the driver is launched, the scene’s models (G4TrajectoriesModel, G4HitsModel, and G4PhysicalVolumeModel) invoke the primitive functions of the G4XrSceneHandler class as they traverse their underlying kernel objects. The track data is collected using the AddPrimitive ( const G4Polyline &) function and the hit data is collected using the void AddPrimitive ( const G4Circle &) and void AddPrimitive ( const G4Square &) functions. The resulting track and hit data are simultaneously written to the track binary files. The physical volumes of the scene are represented as polygonal meshes and accessed via void AddPrimitive(const G4Polyhedron &). From this interface, mesh data—vertices, indices, color, and transformations—are extracted for each G4Polyhedron instance.

Figure 1. The G4XrSceneHandler interface.
When working with complex experiments involving many volumes, representing each one as a separate glTF node can become resource-intensive. Using an aggregation strategy that incorporates mesh instancing into the G4XrSceneHandler workflow, we can reduce overall asset size and improve asset transfer and deployment efficiency. Once geometry construction is complete, EndModeling triggers a single export step that gathers the accumulated unique meshes and their recorded placements and serializes them into a compact GLB asset using the tinygltf library1. Rather than duplicating geometry for each volume, the workflow separates mesh definitions from their instances: each distinct solid is written once as a glTF mesh, while repeated placements are represented as lightweight scene nodes referencing that shared mesh with their corresponding transforms.
class G4XrViewer : public G4VViewer
{
public:
G4XrViewer(G4VSceneHandler&, const G4String& name);
void Initialise() override;
~G4XrViewer() override;
void SetView() override;
void ClearView() override;
void DrawView() override;
void ShowView() override;
void FinishView() override;
protected:
httplib::Server svr;
std::thread svr_thread;
std::vector<std::string> pushedFiles;
const std::string UPLOAD_DIR = "./uploads";
const int PORT = 2535;
std::string URL;
static std::string get_local_ip();
void push_file(const std::string& dirname = "/GLTF");
int server_init();
};
During export, vertex and index data for each unique mesh are consolidated into buffers per the glTF 2.0 specification2. Basic physically based rendering (PBR) materials are generated automatically from the Geant4 visual attributes, preserving the user-defined color and transparency in the rendered scene. The resulting scene graph therefore consists of a compact set of reusable mesh assets and a collection of transformed instances assembled under a single glTF scene, which is finally written to a GLB file.
A custom binary export format was developed to store trajectory information of the event display. For especially complex event topologies, the track information available to the Geant4 kernel is extensive, so there is a need for a fast and memory-efficient storage format. Writing to binary format is handled by the WriteTrackBinary function. The format consists of a 16-byte header, followed by sequentially stored variable-length track records and a string table. Each track record begins with a fixed metadata block (track ID, event ID, particle name, charge, and RGB color values), followed by a 32-bit integer specifying the number of recorded steps . The particle positions, times, energy depositions, and momentum components are then written as contiguous arrays of length in single-precision floating point format. Process identifiers are stored as 16-bit integers. Particle names are stored in the trailing string table, and they are referenced by 16-bit indices within the associated track records. The overall G4XrSceneHandler workflow is summarized in Figure 2.

Figure 2. A summary of the G4XrSceneHandler workflow. The G4Scene holds three models - G4HitsModel, G4TrajectoriesModel, and G4PhysicalVolumeModel - which wrap underlying kernel objects. Each model invokes the corresponding AddPrimitive() overload on the scene handler, which records the resulting primitives to a custom binary format for track and hit data and GLB format for experimental geometry.
It is important to distinguish between simulated runs and simulated events in Geant4 terminology. In Geant4, a single simulated event produces a set of particle trajectories and associated step data, but events are aggregated within the same file while remaining distinguishable with unique identifiers assigned to each track record. In G4VR, these events are visualized together as a single display. On the other hand, Geant4 runs are completely independent and visualized separately.
A similar low-level interface for the G4XrViewer class is shown in Figure 3. The G4XrViewer class primarily manages the asset transfer after all the calls to the G4XrSceneHandler class have been completed. The assets produced for each Geant4 scene are stored temporarily in a GLTF directory. The G4XrViewer’s Initialise() method initializes the local server at a specified local URL. The DrawView() call searches the GLTF directory and posts the prepared asset files to the local server address while also informing the user of the URL to be passed to G4VR for the custom scene. Once the XR driver instance is closed, the temporarily created GLTF directory is destroyed.

Figure 3. Interface definition of the G4XrViewer class, including embedded HTTP server functionality. The server is always launched from port 2535 of the device.
The vis XR driver can be launched from the built-in Geant4 console prior to running the simulation simply with /vis/open Xr, and the user is given the URL to be entered into G4VR to view the associated event display. Through this URL, the posted assets can be received by G4VR through its custom scene functionality, discussed in further detail in Section 3. The motivation for a server-based asset transfer workflow is to avoid wired connections between the headset and the user’s device running Geant4. Additionally, this approach allows multiple G4VR users to view the same experiment from the same host, which is otherwise difficult to achieve.
Data Persistence
To enable the use of XR driver–generated assets beyond a Geant4 simulation session, we implement a data persistence mechanism that allows users to record and reuse VR assets produced at runtime. This functionality facilitates the decoupling of visualization from simulation, thereby improving workflow efficiency and enabling broader accessibility. In particular, persisted assets may be consumed independently of the original simulation environment, allowing users without a local Geant4 installation to interact with the generated content through G4VR. Additionally, for event displays containing a large number of tracks, simulations may be executed in batch mode while the XR driver operates alongside a built-in Geant4 vis driver, such as OpenGL. A dedicated macro can therefore be used to run the simulation, generate the XR assets, and persist them to disk without launching or interacting with the Geant4 graphical user interface.
Prior to initializing the XR driver within the Geant4 session, the user may specify a session identifier using the command /Xr/session <session-name>, where <session-name> uniquely identifies the simulation instance. If the command is invoked without a name, a default session name is generated automatically using the default filename format session_DD_MM_YY_<index>.zip. If the command is never invoked, no session is persisted. Once the session is defined, the XR driver may be invoked as described in Section 2.1. Upon termination of the simulation, the persistence system automatically serializes and stores all relevant XR assets into a compressed archive named <session-name>.zip, located in the local project directory. In addition, a corresponding Python-based launcher script, g4xr_launcher.py, is generated alongside the archive.
The launcher script provides a lightweight and simulation-independent mechanism for serving the persisted assets. It requires no external dependencies and may be executed with Python 3.3-3.12 as follows:
python3 g4xr_launch.py --zip <session-name>.zip
Given the compressed assets as input, the script hosts the asset data on a local server through a port on the user’s device. The script outputs the corresponding network address, which can then be accessed by the G4VR instance, effectively reproducing the workflow outlined in Section 2.1 without requiring re-execution of the original simulation. Because the launcher operates solely on the archived asset bundle, the visualization pipeline becomes portable across devices and platforms. This design enables flexible deployment scenarios, such as remote visualization, collaborative sharing of simulation outputs, and the distribution of precomputed XR environments.
G4VR Application
Unity and Virtual Reality
A general VR setup consists of a headset and two handheld controllers. The user navigates the virtual environment using these controllers. To develop the VR application, we chose the Unity platform. Unity is a cross-platform engine for developing interactive 2D and 3D applications, widely used in video games, simulations, and AR/VR. Applications are built as Android Package Kits (APKs) for Meta Quest 2+ headsets. The integration with the Meta Quest headsets is achieved with the Meta All-In-One Software Development Kit (SDK)3. This SDK enables user mobility and interaction with scene objects, among other core VR features. It supports the programming of controllers to accommodate a wide variety of input actions.
A Unity APK consists of several “scenes,” or self-contained environments containing GameObjects. In Unity, a GameObject is the fundamental entity representing objects in a scene, serving as a container to which components are attached to define behavior, appearance, and interactions. Inside the scene, users can move horizontally (forward, backward, sideways) and vertically using the controllers. Users are also able to interact with scene objects using a ray interactor. The ray interactor allows GameObject interaction from a distance through a projected virtual ray from the controllers that intersects with the GameObject’s collider if one exists. These interactions can be programmed to trigger specific actions. For example, interacting with a cube can trigger predefined tasks. This flexibility facilitates the development of in-game features similar to those in current desktop-display visualization methods.
Analogous to a standard event display, the scene represents the display, while experiment geometries and particle trajectories correspond to GameObjects which populate the scene. This mapping is used in the replication of event displays in virtual reality. In particular, experimental geometries and particle trajectories are loaded separately into the scene to create a complete event display. As such, both assets must be exported from Geant4 in a format that can be received and parsed by the VR APK. To ensure fast runtime loading and minimal overhead, the glTF file format is used to represent and import experimental geometries. Though glTF is not native to Unity, glTF models can be imported and loaded into the scene using the glTFast library as a .gltf file or .glb binary.4 Additionally, particle trajectories are exported as binary files containing step-level information of tracks. The following information must be stored in the track binary:
Track information: Track ID, Event ID, Particle Name, Charge, Trajectory Color
Kinematics: Position and Momentum vectors, Time
Step information: step index, energy deposition (Edep), process
Trajectories are then constructed and displayed using a single mesh instance in Unity. Such high-granularity information enables precise track reconstruction in the event display and provides users with a richer level of detail. The creation of the event display, therefore, requires two well-defined assets to be served to G4VR. The following section details the creation and delivery of these assets.
Asset Import
Once the XR driver is launched in the local Geant4 instance, a local server URL is given to the user, which can then be entered into G4VR through the Browse Experiments option in the main screen of G4VR, as shown in Figure 4. The user is given the choice between three built-in experiments and an option to load their own experiment. Figure 4 also shows an example of an experiment found in a specified URL given by the G4XR driver. The user’s scene can be launched by selecting the corresponding experiment.

(a)

(b)
Figure 4. (a) The main menu screen of G4VR. Users can choose three built-in example event displays (Example B3a, Example B4a, and Example B5) or load their own experiment (Browse Experiments). (b) The Browse Experiments menu, where users can enter the URL provided by the G4XR driver, and the experiments found are listed.
If the given URL does not contain any files or the URL query fails for any reason, an error is thrown and the user is informed within G4VR. Since the server launched by the XR driver is local, it is necessary that the VR headset is connected to the same network as the device hosting the experiment.
Once the assets are imported from the server, the GLB binary is instantiated in the scene using the glTFast library which casts the file into a GameObject. The binary file is read and tracks are drawn within a single mesh instance. The particle tracks are colored following the standard Geant4 coloring scheme: neutral charge particles have green tracks, negatively charged particles have red tracks, and positively charged particles have blue tracks. However, in the case that the user implements their own trajectory coloring scheme in the Geant4 viewer, this is overridden by the coloring values stored in the binary track file.
Since all VR interactions require a collider instance, capsule collider instances are added for each step of each track to allow the user to interact with the track steps and display the associated information. This allows the implementation of the features discussed in Section 3.3. In practice, since a simple event display can contain many hundreds of thousands of steps, activating all capsule colliders at once is inefficient and degrades app performance since each scene update would look for interactions or overlaps in every collider. To reduce the impact of this, as depicted in Figure 5, we implement a nearest-neighbors algorithm where only the closest 1000 colliders to the user’s position (camera) are active. The list of closest colliders is recomputed at fixed five-second intervals.

Figure 5. Illustration of the nearest-neighbors collider activation scheme. To maintain interactive performance in VR event displays containing hundreds of track-step colliders, only the 1000 colliders closest to the user’s camera position are kept active at any time. The set of active colliders is recomputed at fixed five-second intervals.
G4VR Features
Within a general G4VR scene, the user is able to access a wide variety of features from the trajectory information written to the binary track file, namely:
Track Features: Users can interact with the tracks shown in the event display to get step-level track data.
Energy Deposition: The energy deposited in detector volumes can be accessed in a dedicated Edep mode by interacting with the geometries the user is interested in.
Time Control: Users can vary the lab time across the interaction window and examine an event chronologically from the first interaction to the last.
Movie: An animation of the event display through animated particles that trace their respective trajectories in lab time. This is the VR-based implementation of the Geant4 Movie feature.
Figure 6a shows the track information displayed when interacting with a trajectory in the scene, where the energy, momentum, and initiating process of the track can be accessed. At a higher level, hovering over the track with the ray interactor shows both the track energy and particle name in an accompanying display, as shown in Figure 6b. Often, event displays can be dense with several tracks that may obscure primary interactions and make it more challenging to understand event topologies. To alleviate this, users are allowed to configure track displays in the display settings to, for example, start or stop displaying tracks of a certain particle type.
The energy deposition feature is demonstrated in Figure 7a. The user is given an option in the scene settings to switch to the Edep mode, where the energy depositions of each experimental volume are shown. The Edep for each volume is computed by summing the energy deposited by all steps occurring within the volume. A logarithmic gradient scale is created, and each volume with a non-zero Edep value is colored accordingly, with redder volumes recording higher Edep and blue volumes recording lower Edep. Objects with no Edep are colored gray. The user is allowed to move and interact with each volume using the ray interactor and access the Edep value, as shown in Figure 7b.

(a)

(b)
Figure 7. (a) Energy deposition (Edep) in the Edep modality of the event display. A logarithmic color scale indicates the energy deposition in each volume. (b) Interacting with an experiment volume displays the name of the volume as well as the total energy deposition for that run (Example B3a).
In addition to the above features, users are allowed to examine event displays chronologically. In particular, a time slider feature can be used to vary the lab time of the full event from start to stop in individual time steps. Each time step represents a physically significant lab time when a process of some type occurs as defined in the Geant4 simulation. If set to a particular time step T, only tracks until that time T are rendered in the scene. An example of the display for different time steps is shown in Figure 8. If the user prefers to move from one time step to the next dynamically, a Play button is also added that moves through each time step from start to stop.

Figure 8. Time evolution of an event display in G4VR at ps (left), ps (middle), and ps (right) in the lab (Example B4a).
An alternative mode to investigate the chronology of the event display is the movie feature, where particles are animated to move through their trajectories at scaled down speeds such that the event fits into a thirty-second-long animation. An example of this feature with a built-in example scene is shown in Figure 9.

Figure 9. Movie frames, from left to right, depicting the start, middle, and end of the event (Example B5).
G4VR Scene Options
Figure 6-Figure 9 demonstrate the features in G4VR for various example projects in Geant4 that were implemented in VR5. In this section, each of the built-in example event displays of G4VR is discussed.

(a)

(b)
Figure 6. (a) Interaction with a track in the scene displays the properties such as the initiating process, momentum, and energy associated with the track at that step. (b) Hovering over a track with a controller displays the energy and particle type for a quick reference (Example B5).
Example B3a, shown in Figure 7a, is a Positron Emission Tomography (PET) system. It consists of a cylinder of crystals surrounding a smaller coaxial cylinder made of brain tissue, intended to simulate the human brain. The particle source is an ion at rest placed within the human brain volume. The ion undergoes decay to , emitting a positron and an electron neutrino. The example scene in G4VR consists of a single run with 100 such nuclei for a denser event topology, as opposed to the usual Primary Generator configuration of one radioactive ion per run.
Example B4a, shown in detail in Figure 8 and in Figure 10, is a basic sampling calorimeter setup. It is composed of three layers, where each layer is composed of an absorber and collector region. The absorber region is made of lead, and the collector region is made of liquid argon. The event display in G4VR consists of a single run with an electron of 300 MeV energy incident on the calorimeter surface.

Figure 10. Example B4a in G4VR. The event is shown in Edep mode.
Example B5, shown in Figure 9 and Figure 11, is a double-arm spectrometry system. It consists of two arms serving distinct purposes. The first arm contains a 15-strip hodoscope made of plastic scintillator and a drift chamber made of five layers of liquid argon. After the first arm, the charged particle enters a magnetic field contained in a cylindrical region that deflects it into the second arm of the spectrometer. The second arm contains the same drift chamber as in the first arm as well as a 25-strip hodoscope made of plastic scintillator. After the drift chamber and hodoscope, the particle deposits its energy into an electromagnetic calorimeter made of CsI and a hadronic calorimeter made primarily of lead. The first arm and the magnetic field therefore contribute to measuring the position and momentum of the particle, respectively. The second arm produces an electromagnetic shower in the electromagnetic calorimeter to measure the energy of the incident particle. The energies of secondary particles and particles not involved in the initial shower are recorded in the hadronic calorimeter. The example in G4VR consists of a single run of a positron entering the first arm of the spectrometer. Figure 9 shows the electromagnetic shower from this positron in the second arm of the spectrometer.

Figure 11. Example B5 in G4VR. The incident positron enters from the bottom left.
In addition to the above example scenes, as detailed in Section 3.1, the user may also import custom experiments into G4VR. A key distinction introduced at this level from the example scenes discussed above is the option to switch between multiple runs within G4VR. In particular, the user is offered an array of run numbers found in the simulation URL that they can choose to display in G4VR.
Performance
The computational performance of G4VR on a headset can be evaluated using the OVR Metrics tool, which offers dynamic monitoring capabilities of GPU and CPU levels as well as frame rates, measured in frames per second (FPS)6. The performance presented uses the Meta Quest 3S headset and records the variation with time of four metrics in each of the three example scenes: stale-frame count, CPU utilization, GPU utilization, and averaged frame rate. During each recording, the user moves throughout the scene to gauge overheads thoroughly.
FPS directly determines visual comfort in VR: sustained rates below the headset’s native refresh rate or frequent stale frames caused by delayed frame updates can produce perceptible lag and a degraded VR experience. CPU and GPU utilization are also tracked in parallel to distinguish whether performance is limited by scene rendering (GPU) or by application-side logic such as collider updates (CPU, see Section 3.2). The results of the test across these metrics are shown in fig:12. In general, the example event displays have high, stable average frame rates above 60 FPS, and suffer from low stale-frame counts. The GPU (CPU) utilization also lies in a reasonable range of 20-95% (20-70%), indicating that rendering loads and collider updates are handled well for the tested scenes. The spikes in low frame rate and associated reduction in GPU utilization, for example in Example B3a, occur during transitions from the “Movie” mode to the static event display.
To further investigate the effect of event complexity on rendering, multiple Geant4 simulations of various track numbers, and various display complexities, are loaded into G4VR, and the average frame rate in each scene is monitored. Figure 13 shows the variation found from this test. For up to 40,000 tracks, G4VR records a favorable average frame rate above 60 FPS with relatively small fluctuations. For large displays, a longer initial setup time is required to generate the mesh as well as to instantiate the experiment geometries. Additionally, such displays are accompanied by very large binary track files, i.e. at least 10 MB per file in practice, sometimes causing G4VR to consume too much memory and shut down in the Meta Quest headset. The memory consumed by G4VR to display an experiment scales with the number of steps in the experiment display, since each step is accompanied not only by visual

Figure 13. (a) Variation of average FPS in the G4VR scene against the number of tracks in the event display. (b) Variation of average FPS in the G4VR scene against the number of recorded steps in the event display.
caption: Variation with time of key runtime performance metrics in the three example G4VR scenes, measured on the Meta Quest 3S using the OVR Metrics Tool. The plots show stale-frame count (top-left), CPU utilization (top-right), GPU utilization (bottom-left), and average FPS (bottom-right) as the user navigates each scene. Overall, the application maintains stable performance above 60 FPS with low stale-frame counts, while brief FPS drops coincide with transitions between Movie mode and static event visualization.
components but also the associated physics tracked by Geant4. The negative correlation is demonstrated in Figure 14. Thus, beyond a certain threshold, the headset becomes memory-bound, leading to forced termination of the application. While G4VR performs reliably for moderately sized datasets, we note that optimization and reduction strategies are still required to ensure stable performance when visualizing large-scale experiments.

Figure 14. Variation of available app memory (in MB) in the headset with the number of visualized steps. A clear negative correlation is observed, indicating an upper limit on the complexity of experiments that can be visualized in G4VR.
Conclusions and Outlook
Most conventional scientific event-display systems are designed primarily for desktop displays. Motivated by a growing interest in the community in VR-based event displays, we have developed G4VR - the VR event display for Geant4 simulations. Due to the wide use of Geant4 in many scientific applications from medicine to particle physics, the development of a standardized VR visualization framework for Geant4 addresses the need for VR displays of experiments in a range of applications.
The VR implementation we have proposed and implemented is divided into two separate entities: the standalone G4VR application developed for Meta Quest 2+ headsets and the G4XR vis driver for Geant4. The standalone application is made available in the Meta App Lab and contains three example scenes of projects within the Geant4 toolkit installation as well as a custom scene that interfaces with user experiments. These examples are designed to highlight the scope of features available to users within the custom scene.
For a user to load their Geant4 experiment into G4VR, we developed a novel vis driver for Geant4 called G4XR which uses a server-based transfer protocol to load scene data - specifically, geometries and tracks - into the custom scene via a local URL. Such a transfer protocol allows multiple users to load the same experiment into different G4VR instances, enabling collaborative viewing locally. Similar to the example scenes, the custom scenes are fully rendered once the assets are retrieved, with additional features to switch between different runs if the Geant4 project simulates more than one run. The use of the G4XR driver is simplified for the user with only one command to launch it which also yields the URL of the experiment instance that must be passed to G4VR.
We conducted performance tests on the example scenes for the Meta Quest 3S headset, noting a consistent average frame rate with low fluctuations for up to 40,000 tracks. However, for much larger event displays, the assets produced by the XR driver will likely consume too much memory in the Quest headset, and therefore limit the scalability of the driver to these cases. Future work will focus on optimizing the memory usage of the XR driver and G4VR to support more complex event displays more efficiently.
The current G4XR driver is developed for version 11.3.2 of the Geant4 toolkit. As a future effort, we plan to synchronize this with future releases of the Geant4 software as an optional plugin to ensure compatibility.
The integration of glTF support into the XR driver in Geant4 presents several promising directions for future visualization development within the toolkit. As a lightweight and efficient scene description standard, glTF provides a foundation for extending the XR driver toward web-based visualization workflows. In particular, because glTF is natively supported by modern WebGL-based rendering frameworks such as Three.js and Babylon.js, experiment geometries and detector volumes generated in Geant4 could be rendered directly within web browsers without requiring dedicated visualization software. Such a capability would substantially improve accessibility, portability, and collaborative development via platform-independent remote visualization environments.
Beyond browser-based rendering, the XR driver also opens a pathway toward augmented reality (AR) support, allowing users to overlay Geant4 detector geometries and particle trajectories onto physical environments. Importantly, some forms of AR can be implemented on mobile devices without requiring a dedicated headset and can be more accessible to Geant4 users. This significantly lowers the barrier to adoption and enables broader accessibility for educational demonstrations and collaboration. Although glTF currently lacks the universality of older formats such as OBJ, its compatibility with modern real-time rendering systems makes it a strong choice for future visualization frameworks. As a result, glTF integration within the XR driver positions Geant4 for broader integration with emerging web-based and interactive visualization environments.
An important long-term goal is the distribution of the XR driver as an official Geant4 plugin and separate codebase within the broader Geant4 software organization. This would allow the driver to remain modular and independently maintained while still being closely integrated with Geant4. Integration could be handled through the existing CMake build system using external dependency tools, allowing users to optionally build the driver through specific configuration flags. Under this approach, the build system would automatically retrieve and compile the plugin during installation, simplifying deployment and reducing manual setup. Organizing the XR driver as an official plugin would additionally improve its visibility and accessibility within the Geant4 community.
The G4VR application can be downloaded from the Meta App Lab to a user Meta account from the UCLA Physics VR website https://vr.physics.ucla.edu/g4vr.html. The Geant4 release with the XR driver can be installed from https://github.com/bjobilal/g4xr.git.
Acknowledgements
We would like to thank Stewart Boogert, John Allison and the rest of the Geant4 visualization group for their support and valuable feedback. We thank Nathan Joshua, Andrew Su, Milo Kris, Nicholas Farhadian, and Trevor Waltersdorf for helpful discussions and feedback in developing G4VR. This work was partially supported by the U.S. Department of Energy under Award Number DE-SC0009937.
Installing and Running G4VR and G4XR
G4VR Application
Use of the G4VR application requires a Meta account, a compatible Meta Quest headset (e.g., Quest 2 or newer), and tracked controllers. The application is distributed via Meta App Lab and can be accessed through the UCLA Physics VR website:
https://vr.physics.ucla.edu/g4vr.html
Selecting “Get G4VR” redirects users to an App Lab page, where the application can be added to their Meta account via an invite link. Once accepted, the application becomes available for installation on the headset and can be launched directly within the standalone VR environment.
As detailed in the main text, the G4VR application contains three example scenes built from standard Geant4 example projects. It additionally includes the option to visualize custom Geant4 simulations served at a specific (local) address.
G4XR Driver
The G4XR driver provides XR (Extended Reality) visualization support for Geant4 by working directly with the G4VR application. Currently, it is available as an extended Geant4 version 11.3.2 source tree, with future work to synchronize this with newer Geant4 releases (as detailed in Section 6):
https://github.com/bjobilal/g4xr
Integration of G4XR requires building Geant4 with XR driver support enabled. This is achieved by setting the GEANT4_USE_XR flag during the CMake configuration stage (e.g. -DGEANT4_USE_XR=ON). This driver additionally depends on Qt3D, so Qt support must also be enabled and discoverable by CMake (e.g. -DGEANT4_USE_QT=ON, with -DGEANT4_USE_QT_QT6=ON and an appropriate CMAKE_PREFIX_PATH when using Qt6). Once configured, Geant4 can be compiled and installed following standard procedures7. The resulting installation includes the G4VisXR visualization driver, which integrates with the Geant4 toolkit as an additional graphics system available to Geant4-based applications.
At runtime, the /vis/open XR command initializes the G4XR visualization driver and starts its local server. It creates two temporary directories locally: uploads/ and GLTF/, where the former contains the assets served in the local server and the latter contains the created assets. On execution of the command in the Geant4 console, the GLB geometry file is then created and posted to the server. The user is also informed of the URL through the Geant4 console to be entered into G4VR. Subsequent simulations of runs are transferred to the server one-by-one at the end of each visualization call. Finally, once the Geant4 instance is destroyed, all created directories and assets are also destroyed. Sessions can also be persisted to disk for later or offline use with the /Xr/session command, as detailed in Section 2.2, and simulations with many tracks can be run in batch mode alongside a conventional vis driver (e.g. OpenGL) to generate these persisted assets without launching the Geant4 GUI.
The creation of and access to the local server will generally succeed, unless port 2535 (see Figure 3) is already in use or Geant4 lacks permissions. To connect to the server, the headset running G4VR must be on the same local network as the device running Geant4. A potential obstacle is a firewall on the user’s device, which may block incoming connections to the local server from other devices on the same network, including the Meta Quest headset running G4VR. Although the G4XR driver makes the server available at a local network address, firewall settings may prevent other devices from accessing this address. Users should therefore ensure that local-network connections to the default port 2535 are permitted by the firewall.
References
- [1]T. Kittelmann et al., The Virtual Point 1 event display for the ATLAS experiment. J. Phys.: Conf. Ser. 219(3), 032012 (2010). https://doi.org/10.1088/1742-6596/219/3/032012
- [2]T. McAuley, A browser-based event display for the CMS Experiment at the LHC using WebGL. J. Phys.: Conf. Ser. 898(7), 072030 (2017). https://doi.org/10.1088/1742-6596/898/7/072030
- [3]D. Kovalskyi et al., Fireworks: A physics event display for CMS. J. Phys.: Conf. Ser. 219(3), 032014 (2010). https://doi.org/10.1088/1742-6596/219/3/032014
- [4]CMS Collaboration, Leveraging virtual reality for visualising the CMS detector. in Proceedings of the 2024 International Conference on High Energy Physics (ICHEP2024) (2025), p. 1171. URL https://pos.sissa.it/476/1171/
- [5]M. Bellis, et al., HEP Software Foundation Community White Paper Working Group – Visualization (2018). arXiv:1811.10309 [physics.comp-ph]arxiv.org/abs/1811.10309
- [6]T. Heinonen et al., 3D visualization library for multimodal medical images. Computerized Medical Imaging and Graphics 22(4), 267–273 (1998). https://doi.org/10.1016/S0895-6111(98)00031-7
- [7]B. Sveinsson, N. Koonjoo, M.S. Rosen, ARmedViewer, an augmented-reality-based fast 3D reslicer for medical image data on mobile devices: A feasibility study. Computer Methods and Programs in Biomedicine 200, 105836 (2021). https://doi.org/10.1016/j.cmpb.2020.105836
- [8]M. Zhang et al., A DirectX-Based DICOM Viewer for Multi-user Surgical Planning in Augmented Reality, in Advances in Visual Computing, ed. by G. Bebis et al. (Springer Nature Switzerland, Cham, 2022), pp. 217–228. https://doi.org/10.1007/978-3-031-20716-7_17
- [9]K.X. Huang et al., Unity-based virtual reality for detector and event visualization in JUNO experiment. Nuclear Science and Techniques 37(4), 74 (2026). https://doi.org/10.1007/s41365-026-01900-x
- [10]Z. Duer, L. Piilonen, G. Glasson, Belle2VR: a virtual-reality visualization of subatomic particle physics in the belle II experiment. IEEE Computer Graphics and Applications 38(03), 33–43 (2018). https://doi.org/10.1109/MCG.2018.032421652
- [11]M. Bender, T. Kuhr, L. Piilonen, Belle II virtual reality projects. EPJ Web of Conferences 214, 02028 (2019). https://doi.org/10.1051/epjconf/201921402028
- [12]B. Izatt, K. Scholberg, R.P. McMahan, Super-KAVE: An Immersive Visualization Tool for Neutrino Physics, in 2013 IEEE Virtual Reality (VR) (2013), pp. 75–76. https://doi.org/10.1109/VR.2013.6549370
- [13]E. Izatt, K. Scholberg, R. Kopper, Neutrino-KAVE: An Immersive Visualization and Fitting Tool for Neutrino Physics Education, in 2014 IEEE Virtual Reality (VR) (2014), pp. 83–84. https://doi.org/10.1109/VR.2014.6802062
- [14]S. Agostinelli, et al., GEANT4 - A Simulation Toolkit. Nucl. Instrum. Meth. A 506, 250–303 (2003). https://doi.org/10.1016/S0168-9002(03)01368-8
- [15]J. Allison, et al., Geant4 developments and applications. IEEE Trans. Nucl. Sci. 53, 270 (2006). https://doi.org/10.1109/TNS.2006.869826
- [16]J. Allison, et al., Recent developments in Geant4. Nucl. Instrum. Meth. A 835, 186–225 (2016). https://doi.org/10.1016/j.nima.2016.06.125
- [17]J. Allison et al., The GEANT4 Visualisation System. Comput. Phys. Commun. 178, 331–365 (2008). https://doi.org/10.1016/j.cpc.2007.09.010
- [18]W. Schroeder, K. Martin, B. Lorensen, The Visualization Toolkit (4th ed.) (Kitware, 2006)