CHEP06, Mumbai, India February 2006 ROOT 3 D Graphics René Brun, Olivier Couet, Richard Maunder, Timur Pocheptsov * CERN, Geneva, Switzerland * JINR, Dubna, Russia
ROOT 3D Graphics CHEP06, Mumbai, India February Context ROOT (root.cern.ch) is an object-orientated framework for large scale data analysis.root.cern.ch ROOT includes 2-d and 3-d visualization classes 2-d: histograms, graphs (see poster) 3-d: this talk Users need to visualize…..
ROOT 3D Graphics CHEP06, Mumbai, India February Detector Geometries Alice LHCb Atlas CMS
ROOT 3D Graphics CHEP06, Mumbai, India February Events
5 Requirements A viewer which can handle: Static geometry – simple boxes to complex boolean solids – up 10s millions objects. Animated particles, tracks + activated detector parts (energy deposits etc.) Lines, simple shapes spheres etc - 10 – 100,000 objects. Combination - events placed in context of (simplified) cut detector geometries. Viewer must have: High performance, high quality, interactive viewing – lighting, transparency etc. Support for wide variety of geometric shapes and markers, including custom external ones. Variety of projections – perspective, orthographic, special fisheye / non-linear. Self-selection – viewer can choose subset of geometry/events and rebuild this as required. Impossible to load (let alone draw) full collection of objects. Support across all ROOT platforms – Win32, Linux, MacOS, Solaris, etc Take advantage of hardware where available, with software rendering if not. Output to screen, bitmap and vector files (pdf/eps), video (animation). OpenGL base is obvious choice…..
ROOT 3D Graphics CHEP06, Mumbai, India February General Architecture I External client uses non-viewer specific architecture, which can support: Simple ‘legacy’ X3D (simple 3D) + 2D GDI viewers. New OpenGL based viewer. Future viewers – DirectX etc? Consists of: TVirtualViewer3D interface: Test viewer preferences and capabilities. Adding objects – including composite operations. TBuffer3D class hierarchy: Describe 3D objects ("shapes"). Split into sections - filled “by negotiation” – only what the viewer requires. Base class sufficient for any object in raw tessellation form Subclasses for abstract shapes (spheres/tubes etc).
ROOT 3D Graphics CHEP06, Mumbai, India February General Architecture – GL Use TGeo classes TPolyLine3D TPolyMarker3D THelix, etc
ROOT 3D Graphics CHEP06, Mumbai, India February GL Architecture Common scene object for sharing/syncing across viewers. Repeated ‘physical’ (placement) of shared ‘logicals’ Lazy caching of logicals (with expensive tessellation) and physicals. Connect to clients with very large (millions) of objects Client sends all objects – viewer accepts those considered ‘of interest’ at present. Viewer can prompt client to republish e.g. camera setup changed significantly. Viewer can terminate geometry branch publishing (sending contained children). Native drawn shapes: TBuffer3DSphere - solid, hollow and cut spheres* TBuffer3DTubeSeg - angle tube segment TBuffer3DCutTube - angle tube segment with plane cut ends. More in future....
ROOT 3D Graphics CHEP06, Mumbai, India February GL Architecture : Scene Rebuilds I
ROOT 3D Graphics CHEP06, Mumbai, India February GL Architecture : Scene Rebuilds II
ROOT 3D Graphics CHEP06, Mumbai, India February GL Architecture : Scene Rebuilds III Large camera perturbation– new geometry pull(end of camera move). Physical shapes inside new expanded frustum retained. Physical shapes outside discarded/recycled. All logical shapes retained– even if all referencing physicals discarded. TGeoPainter Discard Accept Retain Reject Physical Logical Accept(No Logical)
ROOT 3D Graphics CHEP06, Mumbai, India February GL Features : Rendering 3 draw styles High quality (vector) pdf and eps output. Support composite (CSG) shapes Wireframe Filled polygons Outline +=+=
ROOT 3D Graphics CHEP06, Mumbai, India February GL Features : Cameras 3 Perspective Cameras: Keep ‘floor’ (plane of two global axes e.g. X/Y) level. 3 Orthographic Cameras: Project two global axes (e.g. Y/Z) onto horz./vert. More in future – non-linear fisheye projections etc.
ROOT 3D Graphics CHEP06, Mumbai, India February GL Features : Cameras Comprehensive interactions: Sensitivity modifiers: Orbit rotate round scene center Left Mouse + Drag Dolly move camera in/out along eye line Right Mouse + Horizontal Drag Truck pan parallel to film plane Middle Mouse + Drag arrow keys Zoom adjust lens field of view Mouse Wheel j / k keys Shift: x 10Ctrl: x 0.1Shift+Ctrl: x 0.01Double click reset
ROOT 3D Graphics CHEP06, Mumbai, India February GL Features : Manipulators All shapes (normal / clip ) can be manipulated around local axes. Translate Scale Rotate
ROOT 3D Graphics CHEP06, Mumbai, India February GL Features : Guides Axes (edge or origin) & Reference Marker Zero Value Positive Negative
ROOT 3D Graphics CHEP06, Mumbai, India February GL Features : Clipping
ROOT 3D Graphics CHEP06, Mumbai, India February GL Features : Clipping Two techniques Fast: OpenGL® Clip Planes Multiple renders, each with one or more clip planes, combine together ++ = + Fast and simple, interactive (few planes)- Accurate only for shapes described by planes - Clipped solids not capped –hollow. Quality: CSG Operation Add all object meshes (o1..on), subtract clipping object mesh (c) o1 + o2 + …… + on – c + Any arbitrary clipping shape possible - Costly - cannot adjust interactively + Proper capping of solids Interactive (OpenGL) done – CSG in future.
ROOT 3D Graphics CHEP06, Mumbai, India February GL Performance : I GL Viewer provides generic support for: Frustum Culling: Discard objects outside camera. Test scene bounding first – if visible, all objects visible. Otherwise test each shape BB - skip drawing those outside. Display List Cache: Only raw draw once. ‘Compile’ draw commands into GL display list. If list resident on card (up to memory limit) – cost of one fn call. If list off-card (main mem) cost of transfer+fn call – but commands already efficiently compiled for GL. Singleton DL cache – based on object ID and draw flags. Simple auto capture of any shape (TGLDrawable) by setting flags.
ROOT 3D Graphics CHEP06, Mumbai, India February GL Performance : II Level of Detail (LOD): Tessellation suitable for projected size + GL performance. Distribute GPU power better: 5-10 x speed up for ‘same quality’ Draw() methods takes quality factor 0 – 100% LOD found from object bounding box projected onto screen Combined with Global LOD to factor in overall GL performance/scene. Only native GL Viewer shapes (solid spheres and various tubes) at present. Multi-pass Scene Renders Interactive – speed Lower Global LOD – fixed 50% presently. Time limited – 100msec (10 fps) – rest discarded. Sorted draw list: large -> small – dropouts less noticable. Supports wide range of hardware / software GL performance. Final – quality Done after timeout (user pause). Unlimited time, everything drawn, Global LOD = 100% Combination gives: Typical speed ups 10 – 20+ times c.f. naive direct, fixed quality drawing. Manipulate 10,000 shapes in realtime on quite modest GL setups. Reliable interaction response.
ROOT 3D Graphics CHEP06, Mumbai, India February GL in Pad: I Currently, the 3D representation of data sets is done using dedicated ROOT classes (TView, TPaint3dAlgorithms …). These classes are based on the 2D low level graphics engines (TVirtualX, TVirtualPS …) Therefore, evolving to modern 3D graphics techniques is very difficult.
ROOT 3D Graphics CHEP06, Mumbai, India February GL in Pad: II In order to combine high quality of ROOT 2D graphics and the great 3D possibilities offered by OpenGL, the “GL in Pad” project has been launched.
ROOT 3D Graphics CHEP06, Mumbai, India February GL in Pad: III OpenGL drawing and ROOT 2D graphics are mixed in common bitmap. Enable with gStyle->SetCanvasPreferGL(kTRUE) Advantages: Gain all the features of the standalone GL viewer. Only minor modifications in existing TPad /TCanvas code. No need to duplicate 2D drawing in OpenGL. Fast – can take advantage of hardware acceleration. Simple solution. Vector PostScript output has been implemented using gl2ps. TPostScript output and gl2ps output are mixed in a single file.
ROOT 3D Graphics CHEP06, Mumbai, India February Future Work Complete 3D GL + 2D GDI merge with standalone viewer. More native (LOD supporting) shapes. Animation manager – for animated cameras and objects (particles moving on tracks, detector activation). Specific collections for animated particles/tracks for event display. Improved performance.