This component defines the materials and containers for geometric nodes and their appearance.
See also X3D specification of the Shape component.
The basic X3D node for "something that can be visible and collides".
Shape.geometry field place a geometry node, like
Shape.appearance field (optionally) place the
Describes the shape look (textures, material, shaders and such).
Place this node inside
Describes how the shape interacts with lights.
In simple terms: what is the color of the shape.
Place this node inside
Note that the rendering engine has special optimizations for the "pure emissive" materials, otherwise known as "unlit materials", that cannot be affected by lighting. If you want to use such optimized material, be sure to set to zero all these material fields:
Effectively, for such material, only the
Material is one-sided under Gourand shading.
This means that if you look at the object from behind,
it will be often pure black (lighting is not applied).
TwoSidedMaterial to have a two-sided material.
Note that you can also
use Phong shading.
This makes even the basic
Material two-sided in Castle Game Engine.
TODO: We don't support yet X3D
and related properties. So
is affected by lighting from both sides, but it always looks the same
from both sides.
Configure line width and type (pattern).
This node can be placed in
and it affects a shape that uses a line geometry,
It also affects normal (filled) geometry (like
when viewed in wireframe mode (see view3dscene "View -> Fill Mode" menu).
We only support values 1..5 (Solid .. Dash-dot-dot) for
We use the GPU (OpenGL/OpenGLES) features to render lines with custom width and pattern (type).
This has the advantage that it's ultra-fast. Changing line width or using line pattern has virtually zero cost.
But the disadvantage is that we only support what the GPU (OpenGL/OpenGLES) supports.
This particularly hurts on OpenGLES (Android, iOS), where
glLineStippleis not supported (so X3D
linetypefield will unfortunately do nothing).
GLInformationString), as "Max line width". Unfortunately, on many Android devices it's just 1. Which means that
glLineWidthis supported, but actually completely ignored by the device.
If you need 100% reliable line width or patterns on Android/iOS, you may need to render them differently, using filled rectangles (e.g. using
Rectangle2D nodes). To simulate line patterns, use small repeatable textures with transparent pixels (you can set texture filtering to
TextureProperties node to avoid smoothing the alpha channel).
Notes about VRML 1.0 and multiple materials: multiple materials
within a single VRML 1.0
Material node work 100%
correctly if you change only emissive and transparency,
or only diffuse and transparency for each index.
For complicated cases (like when you change diffuse, and specular,
and emissive...) for each material index -> they will fail.
VRML 2.0 and X3D removed this idea, replacing it with much
that are implemented fully.
Missing and planned:
Copyright Michalis Kamburelis and other Castle Game Engine developers.
Thank you to Paweł Wojciechowicz from Cat-astrophe Games for various graphics.
This documentation is also open-source and you can even redistribute it on open-source terms.