Text component - extensions


1. Text transparency mode (FontStyle.blending)

FontStyle {
  SFBool     []            blending    TRUE      

X3D text is rendered using transparent textures. This allows very efficient rendering on all possible 3D devices. But it also means that you have the usual choice whether to use "alpha testing" transparency ("all or nothing", when the FontStyle.blending is FALSE) or smooth blending (default, when the FontStyle.blending is TRUE). Each one has it's benefits and drawbacks:

  1. With alpha blending, glyph borders looks smooth (currenly our alpha test will make weirdly jagged letter borders).

  2. With alpha testing, you do not have to worry about the order of blending. You will never see any artifacts. With alpha blending, you may need to set NavigationInfo.blendingSort field to "3D".

  3. With alpha testing, the text casts correct shadows using shadow maps.

This is available for all FontStyle node versions (VRML 1.0 and VRML 2.0 / X3D).

2. DEPRECATED: 3D text (node Text3D)

Since version 5.1.0 of Castle Game Engine (corresponding to version 3.15.0 of view3dscene), this node is deprecated, and it is rendered only as a flat Text node. If you need 3D text, use a 3D modelling software, like Blender, to create 3D mesh for text.

We add new node:

Text3D : X3DGeometryNode {
  MFString   [in,out]      string      []        
  SFNode     [in,out]      fontStyle   NULL      
  MFFloat    [in,out]      length      []        
  SFFloat    [in,out]      maxExtent   0         
  SFFloat    [in,out]      depth       0.1         # must be >= 0
  SFBool     [in,out]      solid       TRUE      

This renders the text, pretty much like Text node from VRML 97 (see VRML 97 specification about string, fontStyle, length, maxExtent fields). But the text is 3D: it's "pushed" by the amount depth into negative Z. The normal text is on Z = 0, the 3D text had front cap on Z = 0, back cap on Z = -Depth, and of course the extrusion (sides).

Also, it's natural to apply backface culling to such text, so we have a solid field. When true (default), then backface culling is done. This may provide much speedup, unless camera is able to enter "inside" the text geometry (in which case solid should be set to FALSE).

If depth is zero, then normal 2D text is rendered. However, backface culling may still be applied (if solid is true) — so this node also allows you to make 2D text that's supposed to be visible from only front side.

See our VRML/X3D demo models, file text/text_depth.wrl for example use of this.


  • You should specify external prototype before using this node:
      exposedField MFString string
      exposedField SFNode fontStyle
      exposedField MFFloat length
      exposedField SFFloat maxExtent
      exposedField SFFloat depth
      exposedField SFBool solid
    ] [ "urn:castle-engine.io:node:Text3D",
        "https://castle-engine.io/fallback_prototypes.wrl#Text3D" ]

    This way other VRML browsers should be able to render Text3D node like normal 2D Text.

  • This is somewhat compatible to Text3D node from Parallel Graphics. At the beginning I implemented this extension differently (kambiDepth, kambiSolid fields for AsciiText and Text nodes). But later I found these Parallel Graphics Text3D definition, so I decided to make my version compatible.