http://simoncblyth.bitbucket.io/env/presentation/g4dae_geometry_exporter.html http://simoncblyth.bitbucket.io/env/presentation/gpu_optical_photon_simulation.html
Why export into DAE ?
Ubiquitous geometry visualization for Geant4 users and outreach. Facilitate innovative use of geometry data.
Exports Geant4 Geometry into COLLADA/DAE standard 3D files, based on GDML writer code, same XercesC dependency for XML handling. Export includes:
Export validation:
- Comparison of all vertices/faces reveals boolean solids are discrepant.
- Perfect [1] DAE WRL agreement achieved by cheating : perform triangulation once and reuse.
- Boolean solid triangulation sensitivity must be kept in mind as a potential systematic for computational uses
- DAE not much bigger than GDML, despite including all triangles/vertices [2]
Qty | DayaBay | Lingao | Far | Juno x0.5 |
---|---|---|---|---|
Volumes | 12,229 | 12,229 | 18,903 | 25,000 |
Triangles | 2,448,064 | 2,448,064 | 4,189,680 | 21,886,158 |
Vertices | 1,245,996 | 1,245,996 | 2,128,208 | 10,993,079 |
DAE/GDML/WRL (MB) | 6.9/4.0/98 | 6.9/4.0/96 | 8.6/6.0/167 | 6.1/-/- |
VGDX_20140414 counts using g4daeview.py -g 0: --with-chroma, Juno geometry truncated
[1] | Maximum DAE WRL offset < 0.13 mm, after patching VRML2 export precision bug (fixed in current G4). Details: http://simoncblyth.bitbucket.io/env/notes/geant4/geometry/collada/dae_cf_wrl/ |
[2] | Geometry is not repeated, instead the COLLADA format uses geometry instancing and a tree of transforms, just like GDML |
G4DAE Usage
Many commercial, open source apps/libs can view/edit G4DAE files.
Commercial:
Open source:
Frameworks:
Many more applications and frameworks listed http://en.wikipedia.org/wiki/COLLADA
http://meshlab.sourceforge.net https://bitbucket.org/simoncblyth/meshlab (fork improves COLLADA loading speed)
Coverflow through geometries:
Rotate/Pan/Zoom in the Finder:
Deep tree makes choice of default appearance problematic. Useful editing.
Bialkali PMT cathode highlighted by Xcode effect edit.
Available for Windows too.
Custom Benefits
General purpose OS/app support useful, but custom development needed to really benefit. Availability of frameworks allows high level approach.
g4daenode.py pycollada based G4DAE parser
g4daeserver.py threejs/WebGL (client) and pycollada/webpy (server) based webapp:
g4daeview.py pyopengl/pycollada/numpy based 3D viewer app
https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daenode.py https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/g4daeserver/ https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daeview/g4daeview.py
G4DAE visualization [3] implemented with PyCollada, PyOpenGL and Glumpy
Also used for testing GPU photon propagation with Chroma project
[3] | http://simoncblyth.bitbucket.io/env/notes/geant4/geometry/collada/g4daeview/g4daeview_usage/ |
[4] | Implemented with single OpenGL Vertex Buffer Object (VBO) for entire geometry |
[5] | https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daeview/ |
Initial photon positions of a Geant4 simulated muon that crosses between the Dayabay Near hall ADs. Colors represent photon wavelengths. Optical photons: collected in G4 StackAction, serialized, sent over ZeroMQ, deserialized, presented using OpenGL GLSL shaders.
Based on glumpy [6] and pyopengl [7]
started from .obj viewer [8]
added vertices, triangles from G4DAE export
- entire geometry in single VBO
- only one OpenGL command needed to draw
immediately (few hrs): shockingly fast graphics
- smoothly slinging around ~2.5M triangles, no stuttering
[6] | https://code.google.com/p/glumpy/ many useful examples of pyopengl usage |
[7] | http://pyopengl.sourceforge.net cross platform Python binding to OpenGL and related APIs |
[8] | http://bitbucket.org/simoncblyth/env/src/tip/graphics/glumpy/glumpy_examples/obj-viewer-structured.py |
Photon data flow:
CUDA/OpenGL interop
Same GPU resident data structure accessible to computation and presentation
When visualizing/debugging:
[9] | Would be more efficient to collect OP inside Cerenkov and Scintillation processes, avoiding creating and stacking only to immediately kill. |
[10] | ROOT TObject (de)serialization, network message queue ZeroMQ |
Not mature, but intend to facilitate usage anyhow.
Plan:
Chroma tracks photons through a triangle-mesh detector geometry, simulating processes like diffuse and specular reflections, refraction, Rayleigh scattering and absorption. Using triangle meshes eliminate geometry code as just one code path.
Original Motivation for G4DAE exporter
Allow use of Chroma GPU accelerated optical photon propagation with existing DayaBay Geant4 geometry.
200x performance claim:
With a CUDA GPU Chroma has propagated 2.5M photons per second in a detector with 29k photomultiplier tubes. This is 200x faster than GEANT4.
BUT Chroma needs : triangles + inside/outside materials
http://on-demand.gputechconf.com/gtc/2013/presentations/S3304-Particle-Physics-With-PyCUDA.pdf
Raycasting exercises slowest part of optical photon propagation: geometry intersection.
[11] | Boundary Volume Heirarchy, a tree of bounding boxes with triangles inside leaf nodes |
Render Split into 3x3 CUDA kernel launches, 1 thread per pixel, ~1.8s for 1.23M pixels, 2.4M tris (with [12])
[12] | MacBook Pro (2013), NVIDIA GeForce GT 750M 2048 MB ; Workstation GPUs such as NVIDIA Kepler K20 expected at least ~3x faster |
Chroma GPU photon propagation at 12 nanoseconds. The photons are generated by Geant4 simulation of a 100 GeV muon travelling from right to left. Photon colors indicate reemission (green), absorption(red), specular reflection (magenta), scattering(blue), no history (white).
Chroma GPU photon propagation at 14 nanoseconds. The interface provides interactive control of the propagation time allowing any stage of the propagation to be viewed by scrubbing time backwards/forwards. The speed of this visualization is achieved by interoperation of CUDA kernels and OpenGL shaders accessing the same GPU resident photon propagation data.
Development started with GDML from geant4.10.00.p01
Remaining tasks:
I propose to contribute the COLLADA/DAE geometry exporter to the Geant4 collaboration, as I believe this can be useful for facilitating:
Links for this presentation and another on GPU optical photon propagation:
Instant web access to any volume
Very useful for single volume debugging, did not pursue as prefer Python development over Javascript.
Select volume subtree by name or index and recursion depth
Client in browser based on:
Server:
Command line access to DAE subtrees:
curl -O http://belle7.nuu.edu.tw/g4dae/tree/3155___2.dae
http://threejs.org http://pycollada.github.io http://webpy.org https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/g4daeserver/ https://bitbucket.org/simoncblyth/env/src/tip/geant4/geometry/collada/g4daenode.py
Propagation steps OR photons can be selected by materials, propagation history, or special selection by photon identifier. Photons can be selected by clicking their 3D representations allowing inspection of the propagation history of individual photons.
Photon propagation steps with material pair GdDopedLS,Acrylic. The larger squares represent selected photons, providing access to numerical details of propagation history.