VRML 2.0 shading model applet
by Eric Haines,, copyright (c) 1997
version 1.1 3/13/97

{You may freely use and redistribute this code as long as you keep intact the author and copyright information in}

This applet simulates the VRML illumination model given a default view of a sphere, a default directional light with direction [ -1 -1 -1 ], and a default material. Also, we have set the ambientIntensity to 1 for the light (by default it is 0) so that the Material's ambientIntensity immediately has an effect. The lighting and material fields can be modified, as well as the background color and the gamma correction factor for the monitor. Shading is computed on a pixel by pixel basis (so, for example, the specular highlights will be tighter and more precise than those normally seen using Gouraud interpolation, which is what all VRML browsers currently use).

No error checking is done by this application; the short answer is "read the spec" for the range of values, but in actuality it's pretty easy to characterize: except for the light's direction and gamma, all values should be in the 0.0 to 1.0 range. Even with this limitation it is easy to create scenes where the computed color is outside the 0.0 to 1.0 display range; this applet clamps each individual RGB channel (vs. uniformly scaling each channel by the largest value) so that the values are within this range. When "show clamp" is set, all pixel results which had to be clamped are instead turned red for easy identification.

Note that the view in the applet is "from infinity", while the corresponding pellucid.wrl file simply moves the eye back and tightens the field of view, so the views will not be identical. Also, the sphere here is not tessellated, while spheres in VRML browsers are turned into polygons. Therefore, do not expect to do a pixel by pixel comparison with your VRML browser - the major goal of this program is to help browser writers using APIs which are different than OpenGL to be able to see how their approximation of the VRML illumination fares under various parameter combinations. This should help us all reach some level of convergence in rendering similar materials and lighting conditions similarly.


View the pellucid Java source, or download, which contains all relevant files (java, classes, html, wrl).

A VRML world file which has the default pellucid program settings (you'll have to modify the pellucid.wrl file by hand to match whatever you see in the applet - sorry, Java applets can't write to your disk).