| http://www.sim.no/ http://www.coin3d.org/

Vertex array and VBO rendering in Coin

Coin 2.5 added improved support for OpenGL vertex array and VBO rendering. This might lead to major rendering performance improvements compared to the old rendering code. The new rendering code has been added for the SoIndexedFaceSet, SoVRMLIndexedFaceSet, SoIndexedLineSet, SoVRMLIndexedLineSet, SoPointSet and SoVRMLPointSet nodes.

To take advantage of the improved performance vertex array and VBO rendering yields, you'll need to organize your vertex data in a way that makes it possible to render it with OpenGL vertex arrays. OpenGL vertex array rendering does not support multiple index arrays, so all your vertex data (coordinates, normals, colors and texture coordinates) must use the same index array; or use OVERALL binding. For the indexed nodes, this means that PER_VERTEX_INDEXED and OVERALL are the only supported bindings for materials, normals and texture coordinates. When PER_VERTEX_INDEXED binding is used, the corresponding index field should by empty. This will signal the shape to use the coordIndex field for indices. Below is an example scene graph that will be rendered using vertex arrays:

    NormalBinding { value PER_VERTEX_INDEXED }
    Coordinate3 {
      point [
        0 0 0, # 0
        1 0 0, # 1
        2 0 0, # 2
        0 1 0, # 3
        1 1 0, # 4
        2 1 0, # 5
        0 2 0, # 6
        1 2 0, # 7
        2 2 0, # 8

        2 0  0, # 9
        2 0 -1, # 10
        2 1  0, # 11
        2 1 -1, # 12
        2 2  0, # 13
        2 2 -1  # 14
      ]
    }
    Normal {
      vector [
        0 0 1, # 0
        0 0 1, # 1
        0 0 1, # 2
        0 0 1, # 3
        0 0 1, # 4
        0 0 1, # 5
        0 0 1, # 6
        0 0 1, # 7
        0 0 1, # 8

        1 0 0,  # 9
        1 0 0,  # 10
        1 0 0,  # 11
        1 0 0,  # 12
        1 0 0,  # 13
        1 0 0   # 14
      ]
    }

    IndexedFaceSet {
      coordIndex [
        0, 1, 4, 3, -1,
        1, 2, 5, 4, -1,
        3, 4, 7, 6, -1,
        4, 5, 8, 7, -1,

        9, 10, 12, 11, -1,
        11, 12, 14, 13, -1
      ]
      normalIndex [ ] # = use coordIndex
    }

Please note that since only one index array can be used, it might be necessary to supply duplicate normals and coordinates to meet this requirement.

Also, if normals are needed, you have to supply them. A shape with autogenerated normals can't be rendered using vertex arrays (since a single coordinate might get multiple normals).

The PointSet nodes can always be rendered using vertex arrays since these nodes haven't got index arrays, and the only bindings supported are PER_VERTEX and OVERALL.

If it's inconvenient to create vertex array ready scene graphs directly from your application, it's also possible to use SoReorganizeAction to reorganize the geometry before rendering.

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.