Monday, July 27, 2009

What is a Scene Graph?

Advanced Graphics is new to the DTV arena. Occasionally, this blog will explain some traditional graphics terminology that may be new to even experienced engineers in DTV.

Scene Graph


Traditional computer graphics is rather like impertaive programming. In order to draw things we do a tiny bit of setup for the window and so-called device context and then we issue commands such as set colour, draw a line in 2D, draw a triangle in 3D. A piece of OpenGL-ES code, an example of this traditional style, will have a few functions for setup and the rest of the code will be drawing commands. The important point is that each time we draw a new frame of the animation, we loop around all the drawing code and issue all the commands again.

Scene graphs turn this on its head. Scene graph based languages (eg Java3D) usually have a tiny draw loop. It may infact be reduced to one line of code. Instead all the code is used to setup the scene graph which is a description of all objects, colours, animations and even event triggers in the scene. Code is often replaced by some XML or scene graph description language such as with GRIN.

The graph itself contains nodes which represent each type of drawing function - objects, animations, lights, appearance, events etc. The nodes are arranged in a graph. Drawing starts form the top most node and typically proceeds left to right, top to bottom. Thus nodes higher up in the graph, typically affect more of the scene. For example, overall lighting would appear high in a scene graph. The graphs are usually directed acyclic graphs.

Below is an example of a scene graph taken from SGI publications:



Scene graphs are often a higher level construct and deal with higher level entities (objects). Thus its often much easier to get graphics up and running using scene graph languages. They are thus very attractive in the DTV world where typically users are less experienced. Conversely, they may not be as flexible or performant as dropping to OpenGL and thus may limit advanced users.

Scene graphs are both for 2D vector based languages and 3D triangle based. The initial definition of a scene graph on wikipedia is thus misleading. However the rest of the article is fine.

No comments:

Post a Comment