# Scene Graphs

Software and s/w Development

Dec 13, 2013 (4 years and 7 months ago)

250 views

Overview

Introduction

Constructing a scene

Rendering

Frustum culling

OpenGL Performer

Introduction

The term ‘scene graph’ is a combination of
cinematography and discrete mathematics.

Scene: ‘the visual percept of a region.’

In cinematography a scene includes camera’s, actors,
background and so forth

Graph: ‘nodes connected by edges.’

In this case a directed acyclic graph

Introduction

A scene graph is a data structure which contains:

(Viewable) objects

Relations of objects to another

Information on the appearance of objects

Why use scene graphs?

Possibly quick elimination of peripheral regions

Easy content management

Hierarchical objects are well supported

Persistence; easy saving and storing

Introduction

Every graphics application uses some form of scene
graph.

Paint photo manipulation programs

Illustration/design programs

Presentation software

Visualization of modeling and simulation

Any program that provides a GUI

etc…

Models are stored in their own local
space.

To be positioned in the right
position in the scene, they must be
transformed from ‘model space’ to
‘world space’.

It is common practice to use a 4x4
transformation matrix for this
purpose.

Positioning objects in a scene

3
-
dimensional coordinates can (amongst other
transformations) be rotated, scaled and translated using 4x4
matrices after the vectors are rewritten in homogeneous
form.

Linear transformations

1
0
0
0
1
0
0
0
1
0
0
0
1
z
y
x
T
A

1
0
0
0
0
0
0
0
0
0
0
0
0
z
y
x
S
A

1
0
0
0
0
cos
sin
0
0
sin
cos
0
0
0
0
1

X
A
Translation

Scaling

Z
-
axis rotation

Y
-
axis rotation

X
-
axis rotation

1
0
0
0
0
cos
0
sin
0
0
1
0
0
sin
0
cos

Y
A

1
0
0
0
0
1
0
0
0
0
cos
sin
0
0
sin
cos

Z
A
Transforming coordinate
v

with a single matrix
A

Linear transformations

Av
v'

Transforming coordinate
v
by matrix
B

after begin
transformed with matrix
A

)
(
'
or

)
(
v
BA
v
Av
B
v'

Green box is placed (A) somewhere in
the scene.

Red prism is placed (B) on top of the
green box

Blue box is scaled down (C) and placed
(D) on top of green box

White prism is rotated (E) and placed on
top of blue box (F)

Positioning objects in a scene

Green box: A

Red prism: AB

Positioning objects in a scene

Scene Root
Green Box
Red Prism
Blue Box
White Prism
A
B
DC
FE
Positioning objects in a scene (2)

Scene Root
Sojourner Body
A
B
Left Suspension
Left Arm Front
Left Front Back
Left Sub Arm
C
D
F
Left Back Wheel Axle
H
J
Left Back Wheel
E
Left Front Wheel Axle
Right Suspension
...
Left Front Wheel
G
Left Middle Wheel
I
Light sources

Directional light

Spot light

Point light

Parameters:

Attenuation

Diffuse color/specular color

Intensity

Rendering states

Material properties

Color

Light reflection

Surface texture

Transparancy/opacity

Reflection/refraction (ray tracing)

More rendering states

Fog

ZBuffer/Stencil buffer settings

Other OpenGL/rasterizer specific settings

Refined scene graph

Scene Root
Box Geometry
Prism Geometry
A
B
DC
FE
Green Material
Red Material
Blue Material
Red Material
Directional
Light
LOD (Level Of Detail) node (1)

High
-
res bunny

Med
-
res bunny

Low
-
res bunny

LOD (Level Of Detail) node (2)

Switch/animation node

Depending on a decision function only a specific subtree is
used

Switch/Animation
node
Keyframe
0
...
Keyframe
4
Keyframe
3
Keyframe
2
Keyframe
1
Rendering the scene graph (1)

Next child
node?
Root node?
Done!
Return render
queue
Initialize render
state and start at
root node
Pop render state
Go to parent node
No
No
Yes
Yes
Push render state
Geometry or
state change?
State change
Apply state change or
transformation
current render state to
render queue
Geom
Input: Scene graph, initial render state

Output: Render queue

Rendering the scene graph (2)

Next, let OpenGL or other rendering context consume the
render queue.

Changing the render state might be expensive!!

Therefore the render queue is often sorted in such a way
that the number of render changes is minimized.

Frustum culling

So far, we've been rendering everything without
considering wether or not it is in our field of view.

Frustum culling: only process that part of the scene graph
that is within our field of view.

Test if an object lies within
all six frustum boundaries.

Do not proceed if this isn't
the case. Not rendering
something is cheap.

Frustum culling (2)

Bounding volumes

Testing individual vertices of a model is not very efficient.
By using bounding volumes, the number of tests is
reduced significantly, at the cost of some unnescessary
rendering.

Bounding Sphere

Axis Aligned Bounding Box

Orientated Bounding Box

Bounding volumes

Bounding volumes can be grouped in larger bounding
volumes, so that large sections of the graph can be
rejected at an early stage.

Spatial structuring: Static grid

Only process nodes that overlap grid cells lying inside the
frustum.

Spatial structuring: BSP
-
tree

Binary Space
Partitioning
-
tree. A
spatial binary
hierarchy within the
scene graph.

A balanced, axis
aligned BSP
-
tree
can be generated
with the k
-
D tree
algorithm.

Spatial structuring: Octree

BSP
-
related. Every node of an octree splits an region in
eight subregions or none at all (leaf).

The 2
-
dimensional version
of the same principal is

O
Portals

Portals clip the viewing frustum. When an additional
transformation is added as well, portals can also be used
for 'television' or mirrors.

Making the viewing frustum smaller by clipping increases
the chance of rejection.

Occlusion Culling

Occlussion culling attempts to not render objects that are
invisible because occluding objects are located in front of
them.

Z
-
Buffering

Z
-
Pyramid/Hierarchical occluding maps

OpenGL Performer

"Industrial
-
strength" scene graph API developed by Silicon
Graphics for OpenGL.

Mainly used for visualisation purposes, but can also be
employed for simulations and games.

From the "Getting Started" guide:

OpenGL Performer is an extensible software toolkit for
creating real
-
time 3D graphics. Typical applications are in
the fields of visual simulation, entertainment, virtual reality,
flexible, intuitive, toolkit
-
based solution for developers who
want to optimize application performance.

OpenGL Performer

Performer is composed of the following eight libraries:

1.

High performance rendering library

2.

Visual simulation library

3.

Geometry Builder Library

4.

Utility Library

5.

User Interface Library

6.

Graphical Viewer Library

7.

A Configuration
-
import Library

8.