VRML II - Part 2
Color and Texture
Overview
• Customizing the color of shapes using the Appearance and
Material nodes
• Mixing red , green, blue light
• Creating dull, shiny, glowing, and transparent surfaces
• Wrapping images around shapes using the Texture node
(Andi)
• Texture mapping with images, movies, and raw pixel data
(Andi)
• Using the texture node to control texture mapping
(Andi)
Appearance of a shape
You can change the appearance of a shape by using
three nodes.
Appearance {
exposedField SFNode material NULL
exposedField SFNode texture NULL
exposedField SFNode textureTransform NULL
}
Material Node
Material {
exposedField SFColor diffuseColor 0.8 0.8 0.8 [0,1]
exposedField SFFloat ambientIntensity 0.2 [0,1]
exposedField SFColor emissiveColor 0 0 0 [0,1]
exposedField SFFloat shininess 0.2 [0,1]
exposedField SFColor specularColor 0 0 0 [0,1]
exposedField SFFloat transparency 0 [0,1]
}
Material Node: Diffuse Color
Material {
exposedField SFColor diffuseColor 0.8 0.8 0.8 [0,1] # R G B
}
• The diffuse color field sets the basic color for an object
• It accepts 3 floating point values which are based on the RGB
color model
Red - Green - Blue Color
R G B Resulting color
1 0 0 All red
0 1 0 All Green
0 0 1 All Blue
1 1 0 Yellow
0 1 1 Cyan
1 0 1 Magenta
0 0 0 All black
1 1 1 All White
.75 0 0 Light red
.25 0 0 Dark red
Example: Diffuse Color
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material {
diffuseColor 0 1 0
}
}
geometry Cone {}
}
Material Node: Ambient
Intensity
Material {
exposedField SFFloat ambientIntensity 0.2 [0,1]
}
•It is used to control how much or how little light is
reflected by the surface of a shape
Shiny Surface
• Material {
exposedField SFColor specularColor 0 0 0 [0, 1]
exposedField SFFloat shininess 0.2 [0, 1]
}
• The specularColor Field is to alter the surface properties
of a shape based on specular reflection, meaning that light
will be reflected in a specific direction
• The shininess Field defines the size of specular reflection.
Low values --> shiny appearance
High values --> dull appearance
Metal, Plastic, and Glass
Surface
By combining the Material node`s diffuse color, specular
color and Shininess fields in various ways you can create
metallic, plastic, and glass surfaces.
Surface diffuseColor SpecularColor shininess
Aluminium .37 .37 .37 .89 .89 .89 .13
Blue .20 .20 .20 .85 .85 .85 .15
Plastic
Cooper .30 .10 .00 .75 .30 .00 .08
Gold .49 .34 0.0 .89 .79 0.0 .13
Red Alloy .34 0.0 .34 .84 0.0 0.0 .12
Red Onyx 0.0 0.0 0.0 .72 .72 .72 .18
#VRML V2.0 utf8
Shape {
appearance Appearance {
material Material {
diffuseColor 0.37 0.37 0.37
specularColor 0.89 0.89 0.13
shininess 0.13
}
}
geometry Cone {}
}
Material Node: Glowing Colors
Material {
exposedField SFColor emissiveColor 0.8 0.8 0.8 [0, 1]
}
•It accepts three floating point numbers to describe the RGB
color model.
•0 is used to specify no glowing light for a given color while 1
specifies the highest possible amount.
Example:
1.Diffuse Color: 2.emissiveColor:
#VRML V2.0 utf8 #VRML V2.0 utf8
Shape { Shape {
appearance Appearance { appearance Appearance {
material Material { material Material {
diffuseColor 1 1 0 emissiveColor 1 1 0
} }
} }
geometry Sphere {} geometry Sphere {}
} }
Presentation:
Presentation:
Material Field: Transparency
Material {
exposedField SFFloat transparency 0 [0, 1]
}
•Values closer to 1 introduce more transparency to a shape by
allowing more light through it, while a value of 1 creates shapes
that are completly transparent.
Example:
#VRML V2.0 utf8
Transform { Shape {
translation 0 0 4 appearance Appearance {
children [ material Material {
Shape { diffuseColor 1 1 1
appearance Appearance { }}
material Material { geometry Cylinder {}
diffuseColor 0 1 0 }
transparency 0.75
}
}
geometry Cone {}
}]}
Example: