Controlling Appearance with Materials
Motivation
The primitive shapes have a default emissive (glowing) white appearance
You can control a shape’s
- Shading color
- Glow color
- Transparency
- Shininess
- Ambient intensity
Syntax: Shape
Recall that Shape nodes describe:
- appearance - color and texture
- geometry - form, or structure
XML Encoding
1
2
3
4
<Shape>
<!-- appearance ... -->
<!-- geometry ... -->
</Shape>
Classic Encoding
1
2
3
4
Shape {
appearance ...
geometry ...
}
Syntax: Appearance
An Appearance node describes overall shape appearance
- material properties - color, transparency, etc.
XML Encoding
1
2
3
4
5
6
<Shape>
<Appearance>
<!-- material ... -->
</Appearance>
<!-- geometry ... -->
</Shape>
Classic Encoding
1
2
3
4
5
6
Shape {
appearance Appearance {
material ...
}
geometry ...
}
Syntax: Material
A Material node controls shape material attributes
- diffuseColor - main shading color
- emissiveColor - glowing color
- transparency - opaque or not
XML Encoding
1
2
3
4
5
6
7
8
9
<Shape>
<Appearance>
<Material
diffuseColor='0.8 0.8 0.8'
emissiveColor='0.0 0.0 0.0'
transparency='0.0'/>
</Appearance>
<!-- geometry ... -->
</Shape>
Classic Encoding
1
2
3
4
5
6
7
8
9
10
Shape {
appearance Appearance {
material Material {
diffuseColor 0.8 0.8 0.8
emissiveColor 0.0 0.0 0.0
transparency 0.0
}
}
geometry ...
}
Specifying colors
Colors specify:
- A mixture of red, green, and blue light
- Values between 0.0 (none) and 1.0 (lots)
Syntax: Material
A Material node also controls shape shininess
- specularColor - highlightcolor
- shininess - highlightsize
- ambientIntensity - ambient lighting effects
A sample world using appearance
XML Encoding
1
2
3
4
5
6
7
8
9
10
11
<Shape>
<Appearance>
<Material
diffuseColor='0.2 0.2 0.2'
emissiveColor='0.0 0.0 0.8'
transparency='0.25'/>
</Appearance>
<Box
size='2.0 4.0 0.3'/>
</Shape>
<!-- ... -->
Classic Encoding
1
2
3
4
5
6
7
8
9
10
11
12
13
Shape {
appearance Appearance {
material Material {
diffuseColor 0.2 0.2 0.2
emissiveColor 0.0 0.0 0.8
transparency 0.25
}
}
geometry Box {
size 2.0 4.0 0.3
}
}
...
Example
Summary
The Appearance node controls overall shape appearance
The Material node controls overall material properties including:
- Shading color
- Glow color
- Transparency
- Shininess
- Ambient intensity
This post is licensed under CC BY 4.0 by the author.