32
Open Scene Graph Open Scene Graph Visualization II Visualization II MSIM 842, CS 795/895 MSIM 842, CS 795/895 Instructor: Instructor: Jessica Crouch Jessica Crouch

Open Scene Graph Visualization II MSIM 842, CS 795/895

  • Upload
    asis

  • View
    40

  • Download
    0

Embed Size (px)

DESCRIPTION

Open Scene Graph Visualization II MSIM 842, CS 795/895. Instructor: Jessica Crouch. Implementation work. Time constraints and algorithmic complexity make it impractical to implement very many of the algorithms we’ll discuss We’ll introduce OpenSceneGraph and do a little programming - PowerPoint PPT Presentation

Citation preview

Page 1: Open Scene Graph Visualization II MSIM 842, CS 795/895

Open Scene GraphOpen Scene Graph

Visualization IIVisualization IIMSIM 842, CS 795/895MSIM 842, CS 795/895Instructor:Instructor:Jessica CrouchJessica Crouch

Page 2: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 3: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 4: Open Scene Graph Visualization II MSIM 842, CS 795/895

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…

Page 5: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 6: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 7: Open Scene Graph Visualization II MSIM 842, CS 795/895

Scene graph exampleScene graph examplecircles=BVs

scene graph

root

Page 8: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 9: Open Scene Graph Visualization II MSIM 842, CS 795/895

View-Frustum CullingView-Frustum Culling If a bounding volume (BV) is If a bounding volume (BV) is

outside the view frustum, then the outside the view frustum, then the entire contents of that BV is also entire contents of that BV is also outside (not visible)outside (not visible)

Avoid further processing of such Avoid further processing of such BV’s and their containing geometryBV’s and their containing geometry

Page 10: Open Scene Graph Visualization II MSIM 842, CS 795/895

Example of Hierarchical Example of Hierarchical View Frustum CullingView Frustum Culling

root

camera

Page 11: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 12: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 13: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 14: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 15: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 16: Open Scene Graph Visualization II MSIM 842, CS 795/895

Scene graph with LODsScene graph with LODsCar chair

Page 17: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 18: Open Scene Graph Visualization II MSIM 842, CS 795/895

Ideally, a scene would be drawn with the Ideally, a scene would be drawn with the fewest possible state changesfewest possible state changes

Most expensive state changes would be Most expensive state changes would be minimized at the expense of faster state minimized at the expense of faster state changeschanges

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

Page 19: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 20: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 21: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 22: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 23: Open Scene Graph Visualization II MSIM 842, CS 795/895

Core OSGCore OSG

osg::Node - Base class for all nodes in the scene graph.

Page 24: Open Scene Graph Visualization II MSIM 842, CS 795/895

osg::Group - General group node which maintains a list of children.

Page 25: Open Scene Graph Visualization II MSIM 842, CS 795/895

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.

Page 27: Open Scene Graph Visualization II MSIM 842, CS 795/895

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.

Page 28: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 29: Open Scene Graph Visualization II MSIM 842, CS 795/895

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/

Page 30: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 31: Open Scene Graph Visualization II MSIM 842, CS 795/895

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

Page 32: Open Scene Graph Visualization II MSIM 842, CS 795/895

Your To-Do ListYour To-Do List1.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.