Useful scripts for rendering CMS event displays exported from iSpy WebGL
(.gltf / .glb) with the Blender Python API.
Requires Blender 5.x (tested with Blender 5.2.2). EEVEE is the recommended render engine.
fix_objects.py
Draws tracks, muons, electrons, photons, and the MET arrow as tubes so that they
are visible when rendered. Photons are dashed. Tubes keep the flat (unlit)
colors from the glb file until principled_materials.py is run.
principled_materials.py
Converts the flat materials in the scene to lit Principled BSDF materials, so that objects respond to lights and shading. ECAL and HCAL towers and jets get their own materials; the towers glow slightly.
rechit_outlines.py
Adds white outlines along the edges of the ECAL and HCAL rec hits.
ecal_tower_outlines.py,hcal_tower_outlines.py
Add white outlines along the edges of the ECAL and HCAL towers.
fix_geometry.py
Makes imported detector geometry (such as muon-2.glb) opaque and non-metallic,
so that it renders cleanly with lights. Set the root object names in ROOTS.
clean_scene.py
Removes the lights that come with the iSpy WebGL export and Blender's default cube and light.
add_lights.py
Adds three-point lighting (key, fill, and rim Sun lights) placed relative to the active camera. Run it again after moving the camera.
render_look.py
Makes renders crisp and saturated: uses the Standard view transform and makes the detector more transparent so it doesn't look hazy.
change_background.py
Changes the background color (to 0x202020).
bloom.py
Adds a glow (bloom) to photons, electrons, muons, and jets using the compositor. To see it in the viewport, use Rendered shading with Viewport Shading > Compositor set to Always.
-
Open Blender
-
Import a
.gltfor.glbfile exported from iSpy WebGL -
Select "Scripting" from the main menu
-
Select "Open Text" and select a python script
-
Then run using the "Run Script" button (or the "Alt P" shortcut)
Each script can be run on its own and is safe to run more than once. For a full event display, a suggested order is:
clean_scene.pychange_background.pyfix_objects.pyprincipled_materials.pyrechit_outlines.py,ecal_tower_outlines.py,hcal_tower_outlines.pyfix_geometry.py(only for detector geometry files)add_lights.pyrender_look.pybloom.py(last, sincefix_objects.pyandprincipled_materials.pyrebuild materials)