Upload
brice-dennis-whitehead
View
230
Download
0
Tags:
Embed Size (px)
Citation preview
Open Scene GraphOpen Scene Graph
Visualization IIVisualization IIMSIM 842, CS 795/895MSIM 842, CS 795/895
Instructor:Instructor:Jessica CrouchJessica Crouch
Implementation workImplementation work
Time constraints and algorithmic complexity Time constraints and algorithmic complexity make it impractical to implement very many make it impractical to implement very many of the algorithms we’ll discussof the algorithms we’ll discuss
We’ll introduce OpenSceneGraph and do a We’ll introduce OpenSceneGraph and do a little programminglittle programming– It’s a useful skillIt’s a useful skill– Good to learn after OpenGLGood to learn after OpenGL– We’ll do enough to prepare you to pursue it further We’ll do enough to prepare you to pursue it further
on your ownon your own
Our primary focus in class will remain on the Our primary focus in class will remain on the readingsreadings
VTK AlternativeVTK Alternative
VTK was another strong VTK was another strong possibilitypossibility
– OSG implements more graphics and OSG implements more graphics and simulation oriented featuressimulation oriented features
– VTK Implements more visualization, VTK Implements more visualization,
2D & 3D data processing algorithms2D & 3D data processing algorithms
Scene GraphsScene Graphs Datastructure: Directed Acyclic Graph Datastructure: Directed Acyclic Graph
(DAG)(DAG)• Usually a tree (only one parent per node) Usually a tree (only one parent per node) • Represents object-based Represents object-based hierarchyhierarchy of geometry of geometry
Leaves contains geometry (triangles, etc.)Leaves contains geometry (triangles, etc.) Each node holds pointers to childrenEach node holds pointers to children Children can beChildren can be
GroupGroup GeometryGeometry Matrix transformMatrix transform Others…Others…
Scene GraphsScene Graphs Spatial transforms represented as graph Spatial transforms represented as graph
nodesnodes (rotation, translation, scaling, (rotation, translation, scaling, etc.)etc.) tricycle
Back wheels
Front Group
Left wheel
Right wheel
T TSeat
Handle bars
Front Wheel
T
Scene Graphs & Bounding Scene Graphs & Bounding VolumesVolumes Basic idea:Basic idea:
– Augment scene graphs with bounding volume Augment scene graphs with bounding volume data (spheres or blocks) data (spheres or blocks) at each nodeat each node
Sometimes called “Bounding Volume Hierarchy” Sometimes called “Bounding Volume Hierarchy” (BVH)(BVH)
– By applying clipping/culling tests to the By applying clipping/culling tests to the bounding volumes, prune entire branches of bounding volumes, prune entire branches of the tree and possibly avoid processing many the tree and possibly avoid processing many trianglestriangles
Culling: OverviewCulling: Overview
Hierarchical view-frustum cullingHierarchical view-frustum culling– Use bounding volumesUse bounding volumes
Detail cullingDetail culling– Choose resolution of rendering based on Choose resolution of rendering based on object’sobject’s
distace to cameradistace to camera
View-Frustum CullingView-Frustum Culling
If a bounding volume (BV) is If a bounding volume (BV) is outside the view frustum, then outside the view frustum, then the entire contents of that BV is the entire contents of that BV is also outside (not visible)also outside (not visible)
Avoid further processing of such Avoid further processing of such BV’s and their containing BV’s and their containing geometrygeometry
Example of Hierarchical Example of Hierarchical View Frustum CullingView Frustum Culling
root
camera
Scene Graphs & Detail Scene Graphs & Detail ControlControl In complex scenes, a large percentage In complex scenes, a large percentage
of time is wasted drawing tiny of time is wasted drawing tiny trianglestriangles
What happens if a triangle projects to What happens if a triangle projects to one pixel or less?one pixel or less?
Goal: Use scene graph to reduce Goal: Use scene graph to reduce workload of insignificant trianglesworkload of insignificant triangles
Detail CullingDetail Culling
Idea: Objects whose projected BV Idea: Objects whose projected BV occupy less than N pixels are culledoccupy less than N pixels are culled
This is an approximating algorithm This is an approximating algorithm since the triangles you cull may actually since the triangles you cull may actually contribute to the final imagecontribute to the final image
Advantage: trade-off quality/speedAdvantage: trade-off quality/speed
Example of Detail Example of Detail CullingCulling
detail culling OFF Not much difference, but 80-400% fasterNot much difference, but 80-400% faster Good when movingGood when moving
detail culling ON
Images courtesy of ABB Robotics Products, created by Ulf Assarsson
Level-of-Detail Level-of-Detail RenderingRendering
Use different levels of detail at different Use different levels of detail at different distances from the viewerdistances from the viewer
More triangles closer to the viewerMore triangles closer to the viewer
LOD renderingLOD rendering Not much visual difference, but a lot fasterNot much visual difference, but a lot faster
Use area of projection of BV to select appropriate LOD
Scene Graphs:Scene Graphs:State ChangesState Changes State changes affect the way the State changes affect the way the
graphics pipeline executegraphics pipeline execute– Recall pipelining from your architecture Recall pipelining from your architecture
classclass– A change in state may require A change in state may require
flushing the pipelineflushing the pipeline flushing the cache (on the graphics card)flushing the cache (on the graphics card)
– Binding to a texture is one of the most Binding to a texture is one of the most expensive state changes expensive state changes
Ideally, a scene would be drawn with Ideally, a scene would be drawn with the fewest possible state changesthe fewest possible state changes
Most expensive state changes would Most expensive state changes would be minimized at the expense of faster be minimized at the expense of faster state changesstate changes
How to accomplish this?How to accomplish this?– Must sort triangles according to their stateMust sort triangles according to their state– Manually?Manually?– Automatically?Automatically?
Scene Graphs:Scene Graphs:State ChangesState Changes
Scene graphs are used for Scene graphs are used for state sortingstate sorting
State information is stored with the nodesState information is stored with the nodes
Optimized rendering algorithms take Optimized rendering algorithms take advantage of groupings of same-state advantage of groupings of same-state primitivesprimitives
Scene graph hierarchy can be (algorithmically) Scene graph hierarchy can be (algorithmically) rearranged for rendering into a rearranged for rendering into a state graphstate graph– Branchings represent state changesBranchings represent state changes– State tends to be staticState tends to be static
Scene Graphs:Scene Graphs:State ChangesState Changes
Open Scene GraphOpen Scene Graph
Library for scene graphsLibrary for scene graphs Built on top of OpenGLBuilt on top of OpenGL C++ APIC++ API Object orientedObject oriented Open sourceOpen source Growing popularity in graphics communityGrowing popularity in graphics community Commercially used (Boeing, NASA, …)Commercially used (Boeing, NASA, …) Web site:Web site:
– http://www.openscenegraph.orghttp://www.openscenegraph.org
Open Scene GraphOpen Scene Graph
Supports:Supports:– View frustum cullingView frustum culling– Occlusion cullingOcclusion culling– Small feature cullingSmall feature culling– Level Of Detail nodesLevel Of Detail nodes– State sortingState sorting– Many other featuresMany other features
OSG Distribution OSG Distribution ContainsContains Core OSGCore OSG – Focus on understanding – Focus on understanding
this firstthis first
NodeKits – implements more node NodeKits – implements more node types than available in the coretypes than available in the core
Plugins – I/O for different file typesPlugins – I/O for different file types
Interoperability libs – for using OSG Interoperability libs – for using OSG with various packages, languageswith various packages, languages
ExamplesExamples
Transform NodesTransform Nodes
osg::Transform - A Transform is a group node for which all children are transformed by a 4x4 matrix. It is often used for positioning objects within a scene, producing trackball functionality or for animation.
Geometry NodesGeometry Nodes
osg::Geode - A Geode is a "geometry node", that is, a leaf node on the scene graph that can have "renderable things" attached to it.
Renderable things are represented by objects from the Drawable class, so a Geode is a Node whose purpose is grouping Drawables.
DrawablesDrawables Pure virtual base class for drawable geometry.
Everything that can be rendered is implemented as a class derived from Drawable.
A Drawable is not a Node, and therefore it cannot be directly added to a scene graph. Instead, Drawables are attached to Geodes, which are scene graph nodes.
The OpenGL state that must be used when rendering a Drawable is represented by a StateSet.
Drawables can also be shared between different Geodes, so that the same geometry (loaded to memory just once) can be used in different parts of the scene graph.
Plugins for file I/OPlugins for file I/O Has plugins to support reading/writing lots of graphics file formats and Has plugins to support reading/writing lots of graphics file formats and
3D models:3D models:
– 3D database loaders include 3D database loaders include OpenFlightOpenFlight (.flt) (.flt) TerraPageTerraPage (.txp) (.txp) LightWaveLightWave (.lwo) (.lwo) Alias Wavefront (.obj)Alias Wavefront (.obj) Carbon Graphics GEO (.geo)Carbon Graphics GEO (.geo) 3D Studio MAX (.3ds)3D Studio MAX (.3ds) Peformer (.pfb)Peformer (.pfb) Quake Character Models (.md2)Quake Character Models (.md2) Direct X (.x)Direct X (.x) Inventor Ascii 2.0 (.iv)/ VRML 1.0 (.wrl)Inventor Ascii 2.0 (.iv)/ VRML 1.0 (.wrl) Designer Workshop (.dw) Designer Workshop (.dw) AC3D (.ac) AC3D (.ac) native .osg ASCII format. native .osg ASCII format.
– Image loaders include Image loaders include .rgb.rgb .gif.gif .jpg.jpg .png.png .tiff.tiff .pic.pic .bmp.bmp .dds.dds .tga.tga
OSGEditOSGEdit
Helps you Helps you compose compose scenes for OSGscenes for OSG
Open sourceOpen source
Import models Import models created with created with other other programs, programs, arrange your arrange your tree structure tree structure and transformsand transforms
http://osgedit.sourceforge.net/
Open Scene GraphOpen Scene Graph
OSG documentation is incompleteOSG documentation is incomplete– No textbookNo textbook– Doxygen code documentationDoxygen code documentation– Some online tutorials and example programsSome online tutorials and example programs
Takes time to learn your way aroundTakes time to learn your way around
Useful As-Is, development work continuesUseful As-Is, development work continues
ReferencesReferences
www.openscenegraph.orgwww.openscenegraph.org
http://www.nps.navy.mil/cs/sullivan/osgTutorials/Schttp://www.nps.navy.mil/cs/sullivan/osgTutorials/SceneGraphOverview.htmeneGraphOverview.htm
http://http://www.realityprime.com/scenegraph.phpwww.realityprime.com/scenegraph.php
Your To-Do ListYour To-Do List
1.1. Email me ([email protected]) your paper Email me ([email protected]) your paper preferences by Sunday night.preferences by Sunday night.
2.2. Download and build OSG. See instructions on Download and build OSG. See instructions on course web site.course web site.
3.3. Read through and run the Example osgAnimate. Read through and run the Example osgAnimate. Draw the scene graph tree constructed in Draw the scene graph tree constructed in osgAnimate.cpp and bring to the next class. osgAnimate.cpp and bring to the next class. For each node, list object name and type.For each node, list object name and type.
4.4. Read the two assigned papers for the next Read the two assigned papers for the next class.class.