5.2. Classic deterministic ray-tracer

Classic Whitted-style deterministic ray-tracer is done by TClassicRayTracer class in RayTracer unit.

Point and directional lights are used, as defined by all normal VRML light nodes. This means that only hard shadows are available. Algorithm sends one primary ray for each image pixel. Ray-tracing is recursive, where the ray arrives on some surface we check rays to light sources and eventually we recursively check refracted ray (when Material has transparency > 0) and reflected ray (when Material has mirror > 0).

The resulting pixel color is calculated according to VRML 97 lighting equations. This is probably the most important advantage of ray-tracer in our engine: ability to calculate images conforming precisely to the VRML 97 lighting specification. Actually, we modified these equations a little, but only because:

  1. I have recursive ray-tracing while VRML 97 specifies only local light model, without a placeholder for reflected and refracted color.

  2. VRML 1.0 SpotLight must be calculated differently, since it uses the dropOffRate field (a cosinus exponent) to specify spot highlight. While VRML 2.0 uses the beamWidth field (a constant spot intensity area and then a linear drop to the spot border). So for VRML 1.0 spot lights we use the equations analogous to the OpenGL lighting equations.

  3. The ambient factor is calculated taking into account that standard VRML 1.0 light nodes don't have the ambientIntensity field. Although, as an extension, our engine allows you to specify ambientIntensity to get VRML 2.0 behavior in VRML 1.0.