Shape component - extensions

Contents:

1. Toggle shape rendering (Shape.render)

Shape {
  ...
  SFBool     [in,out]      render      TRUE      
}

The field render allows to easily hide and show the given Shape. A hidden shape is not rendered, but otherwise it's still processed (for example, it is used for collision detection).

If you want to hide a particular shape, sometimes this may be a simpler method than using standard X3D Switch node. It doesn't require to wrap the Shape in a Switch node.

This is compatible with InstantReality Shape extension.

2. Specify shading, e.g. to force Phong shading or wireframe for a shape (Shape.shading)

We add a shading field to the Shape node (more precisely, to the abstract X3DShapeNode):

X3DShapeNode (e.g. Shape) {
  ... all normal X3DShapeNode fields ...
  SFString   [in,out]      shading     "DEFAULT"   # ["DEFAULT"|"GOURAUD"|"PHONG"|"WIREFRAME"]
}

The allowed values for the shading field:

  • DEFAULT: use the default shading. In view3dscene you control this using the "View -> Phong Shading on Everything" checkbox. In your own games you control this using the Scene.Attributes.PhongShading property in Pascal code.

  • GOURAUD: fast per-vertex lighting calculation. It is the default shading for now.

    Explicitly specifying the "GOURAUD" indicates that this shape wants to use Gouraud shading, even if the default scene shading is Phong. Note that some features (like bump mapping and shadow maps) will override this and require Phong shading anyway, since it's impossible to realize them with Gouraud shading.

    Note that the "GOURAUD" shading performs only one-sided lighting in the shader pipeline. This means that only one face side receives lighting. TODO: For now, this is always the CCW side, regardless of the front face indicated by the "ccw" field.

  • PHONG: pretty per-pixel lighting calculation. This also means always using shader pipeline to render this shape. This also performs two-sided lighting.

  • WIREFFRAME: render as a wireframe. The rendering model matches the IndexedLineSet specification, in particular: the shape is not lit.

    For now this is only honored by the Box, Sphere nodes. It will be extended to all geometry nodes when necessary in the future.

These shading names are consistent with "Browser options" in X3D spec (with DEFAULT added by us).