Adding colors, textures and images to VRML Primitives.


Adding Color:    Color in VRML is in the form RGB, ie: Red-Green-Blue. Where the values of this triplicate range from 0 to 1 for example RGB of 1 1 1 means it will have full red, full green and full intensity of blue mixed, which makes white.
If the triplicate pair has the same number for each color, then the combined RGB color will be black(0 0 0) to white(1 1 1) as grayscale inbetween( .25 .25 .25).

RGB value 1 0 0 represents red, RGB value 0.5 0 0 also represents red but not as intense as 1 0 0.
RGB value 0 1 0 represents green.
RGB value 0 0 1 represents blue.
RGB value 1 1 0 represents red-green(yellow).
RGB value 0 1 1 represents green-blue(aqua).
RGB value 1 0 1 represents red-blue(purple).

Take a simple sphere and add a color to it, modify the sphere.wrl file by changing it to the following colorsphere.wrl


#VRML V1.0 ascii

Separator {
  Material { diffuseColor [ 0.0    1.0    0.0 ] }
  Sphere { radius  1.0 }
}



Different Colors:    There are various different types of colors.
They are:
ambientColor:        triplicate set RGB
diffuseColor:           triplicate set RGB
specularColor:        triplicate set RGB
emissiveColor:       triplicate set RGB
shininess:                single value
transparency:         single value

 colors belong in the object node called "Material" as follows, if values are zero, its not necessary to list them.
for example:



 Material {
    ambientColor       0.2 0.2 0.2
    diffuseColor          0.8    0.8    0.8
    specularColor       0 0 0
    emissiveColor       0 0 0
    shininess                  0.2
    transparency         0



Adding Texture:    Adding textures in VRML is much more easier than adding colors, in that memorization of a complex color table is not required. Simply create/find a "GIF" or "JPG" image file that needs to be attached, and modify the file as sphere.wrl to texturesphere.wrl.  Below we mapped the image "logo.small.gif" on to the simple sphere.

#VRML V1.0 ascii

Separator {
 Texture2{ filename "logo.small.gif" }
 Sphere { radius  1 }
}



Ronald D.Kriz and Sanjiv Parikh
Virginia Tech
VT-CAVE
Created 06/17/99, Revised 06/17/99

http://www.sv.vt.edu/classes/vrml/colors.html