Many types of colors exist in the world; diffuse colors, emmisive colors, specular colors, &c. VRML allows for the manipulation of all of these types of colors. Here, only diffuse color will be explained.
Color (appearance/material) is considered to be part of the Shape. Just as the geometry field lies within the Shape node, so does the appearance field. Recall that the geometry field must contain the name of some geometry node. Well, the appearance field must contain the name of an appearance node. There is only one appearance node: the Appearance node. Let's have a look at this example:
#VRML V2.0 utf8
#attempt at a colored ball
Shape{
appearance Appearance{}
geometry Sphere{}
}
One of the fields of an Appearance{} is material. Of course, the material field requires another node as its value; namely Material{}. Therefore:
#VRML V2.0 utf8
#second attempt at a colored ball
Shape{
appearance Appearance{
material Material{}
}
geometry Sphere{}
}
Here are Material{} defaults:
Material{
diffuseColor .8 .8 .8
emissiveColor 0 0 0
specularColor 0 0 0
shininess .2
transparency 0
}
Let's look at values other than the default:
#VRML V2.0 utf8
#a red ball
Shape{
appearance Appearance{
material Material{
diffuseColor 1 0 0
} }
geometry Sphere{}
}
What do the values of the diffuseColor field mean?
diffuseColor 1 0 0
Simply, they are the red, green, and blue (respectively) contribution to the final color. The first of the three values is the amount (between zero and 1) of red in the final color. In this example, 1 (or all) of the possible red the monitor can make, will be included in the color. 0 (or none) of the geen, and 0 (none) of the blue will be combined with all of the red.