Controlling Appearance whith 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

<Shape>
  <!-- appearance ... -->
  <!-- geometry ... -->
</Shape>

Classic Encoding

Shape {
  appearance ...
  geometry ...
}

Syntax: Appearance

An Appearance node describes overall shape appearance

  • material properties - color, transparency, etc.

XML Encoding

<Shape>
  <Appearance>
    <!-- material ... -->
  </Appearance>
  <!-- geometry ... -->
</Shape>

Classic Encoding

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

<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

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)
Color Red Green Blue Result
White 1.0 1.0 1.0 white
Red 1.0 0.0 0.0 red
Yellow 1.0 1.0 0.0 yellow
Cyan 0.0 1.0 1.0 cyan
Brown 0.5 0.2 0 brown

Syntax: Material

A Material node also controls shape shininess

  • specularColor - highlightcolor
  • shininess - highlightsize
  • ambientIntensity - ambient lighting effects

A sample world using appearance

XML Encoding

<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

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

Box1

View scene in this window.

Download ZIP Archive

Summary

The Appearance node controls overall shape appearance

The Material node controls overall material properties including:

  • Shading color
  • Glow color
  • Transparency
  • Shininess
  • Ambient intensity