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.

See the International Color Consortium page for some notes on gamma correction, especially the sRGB paper (near the bottom of their page), also see Poynton's page. For PC monitors gamma is an average of 2.2 (according to the sRGB white paper). To compare stored image values across platforms, set the gamma value to 1.0. However, VRML is concerned with how the users perceive worlds viewed on the screen, so I give a default value of 2.2 in order to show how the results should look on a gamma-corrected browser on a PC. Just to hit you over the head: gamma matters, and the sooner browser writers and authoring systems deal with it the better we'll all be. End of agenda.

Note that CosmoPlayer and Live3D on the PC are the only PC browsers which attempts to simulate gamma correction (they do this by boosting the material contributions on the front end; gamma should be corrected on the back end but most rendering APIs do not support this). Note that gamma is important: if you design your world so that it looks good on a PC browser which does no gamma correction, your materials will tend to look washed out on a SGI or Mac, which do some gamma correction. This is a long term issue which is being addressed by the Color Fidelity workgroup (contact: Mark Callow,, but is something to keep in mind.

An interesting idea is for each browser company to put into Java code their approximation model and so have their own pellucid application which shows how they render a given scene. All they would have to do is edit the code to show their simplifications or translations of various fields, assuming they know their API's illumination algorithm.

There is a white paper by Alan Norton about how he used Renderware to approximate the VRML illumination model.

code history:
3/6/97 - created 1.0
3/13/97 - released 1.1: added clamping, erased sphere during recompute, changed defaults to be more interesting and useful.


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).

Eric Haines /

Last change: March 14, 1997