Lighting component

This component defines light source nodes.

See also X3D specification of the Lighting component.


1. Support

Supported nodes:

  • DirectionalLight (API reference),
    PointLight (API reference),
    SpotLight (API reference)

    Note: VRML 2.0 SpotLight.beamWidth idea cannot be translated to a standard OpenGL spotlight, so if you set beamWidth < cutOffAngle then the light will not look exactly VRML 2.0-spec compliant. Honestly I don't see any sensible way to fix this (as long as we talk about real-time rendering using OpenGL). And other open-source VRML implementations rendering to OpenGL also don't seem to do anything better.

    VRML 2.0 spec requires that at least 8 lights are supported. Our engine can support as many lights as are allowed by your OpenGL implementation, which is at least 8.

    global field from X3D is also supported. The default value of this field is consistent with VRML 2.0 specification (that always wants directional lights non-global, and other lights always global).

2. Per-pixel lighting

By default we render most shapes using Gouraud shading (per-vertex lighting calculation). This is fast, but not always pretty.

Using the "View -> Phong Shading on Everything" option in view3dscene forces everything to be rendered using Phong shading (per-pixel lighting). This is sometimes a significant boost to quality.

  • Per-pixel lighting means that local lighting effects, in particular spot light cones and specular highlights, are precisely rendered.

  • Lights attenuation is also calculated per-pixel, this sometimes gives much better results.

  • Lights with radius with fixed-function pipeline rendering
    Light with radius with per-pixel lighting (shader pipeline)

    Light radius is also checked per-pixel when necessary (when shape is partially inside, partially outside the light radius). This allows to use "radius" field (on point and spot lights) for much more dramatic lighting effects. For example, compare the two screenshots from light_street_lights_radius demo on the right (from our VRML/X3D demo models).

You can also switch to Phong shading for particular shapes.

Pascal Developers: you can switch to Phong for the whole scene by Scene.Attributes.PhongShading := true or only for a particular shape using Shape.Shading := shPhong.

2.1. Problems? Get latest GPU drivers

Using the shader pipeline (right now activated by certain features, like Phong Shading or shadow maps or bump mapping; may be default in the future) requires a good graphic card with latest drivers. Before reporting problems, make sure that you have the latest OS version, with the latest drivers. You may need to download latest drivers from

Windows often comes with quite outdated drivers, so be sure to get drivers from above sites. On Linux and Mac OS X, it should be enough to make sure you use the latest version of your system, with all updates applied. On Linux, you may need to install the proprietary OpenGL drivers to squeeze best performance from your NVidia/Radeon GPU. (Although latest Mesa may also be quite capable of handling simpler stuff, even with shaders.)