Rendering component

This component defines the basic properties of geometric objects, and nodes to render triangles, lines and points. See Geometry3D component for more comfortable geometric objects like polygons and spheres.

See also X3D specification of the Rendering component.

Supported nodes:

  • Coordinate (API reference),
    Color (API reference),
    ColorRGBA (API reference),
    Normal (API reference)

  • Triangles, lines and points:

    IndexedTriangleSet (API reference),
    TriangleSet (API reference),
    (see also analogous IndexedQuadSet, QuadSet from CAD geometry component).

    IndexedTriangleFanSet (API reference),
    TriangleFanSet (API reference),
    IndexedTriangleStripSet (API reference),
    TriangleStripSet (API reference)

    LineSet (API reference),
    IndexedLineSet (API reference)

    PointSet (API reference)

    Support includes the implementation of new X3D fields attrib (per-vertex attributes for shaders) and fogCoord (per-vertex fog depth).

    TODO: for TriangleFanSet and TriangleStripSet, a special constraint is present: if you will use colors (colors are always per-vertex on these primitives, according to X3D spec) and request generation of per-face normals at the same time, for the same lit (with material) node, then shading results will be slightly incorrect. Like this:

    #X3D V3.0 utf8
    PROFILE Interchange
    
    Shape {
      appearance Appearance { material Material { } }
      geometry TriangleFanSet {
        coord Coordinate { point [ 0 0 0, 1 0 0, 1 1 0, 0.5 1.5 0.5 ] }
        fanCount 4
        color Color { color [ 1 0 0, 0 1 0, 0 0 1, 1 1 1 ] }
        normalPerVertex FALSE
      }
    }
    

    Unfortunately, this is quite unfixable without falling back to worse rendering methods. Shading has to be smooth to interpolate per-vertex colors, and at the same time the same vertex may require different normals on a different faces. So to render this correctly one has to decompose triangle fans and strips into separate triangles (like to IndexedTriangleSet) which means that rendering is non-optimal.

    Ideas how to implement this without sacrificing rendering time are welcome. Eventually, a fallback to internally convert fans and strips to IndexedTriangleSet in such special case will be implemented some day.

    Note: As far as I see, X3D specification doesn't specify what to do for triangle/quad sets when appearance specify a texture but no texCoord is given. Our engine currently takes the IndexedFaceSet approach for automatic generation of texture coords in this case, let me know if this is wrong for whatever reason.

  • ClipPlane (API reference)

    OpenGL limits the number of clipping planes that may be enabled at the same time on a single shape. This limit is at least six (see view3dscene "Help -> OpenGL Information", look at "Max clip planes" line, to know the limit of your GPU). Following X3D spec, we treat the "more global" clipping planes as more important.

    Note that clipping planes are purely visual effect. The clipped geometry is still present for collision detection, picking, bounding volumes etc.

    TODO: clip planes don't work on background nodes (X3DBackgroundNode) yet.