Computer Graphics
File Format for Defining a Material
The material properties for an object determines how the object
reflects light, and therefore its perceived colour.
In this implementation an object as a whole can have a material
property, and each individual face of the object may have a material.
If a face does not have a material then it inherits the material of the
object. If the object is not given a material, then it inherits a
default material.
Note that setting the material for each face of an object considerably
slows OpenGL rendering.
A material specification has the following components:
-
whether it is being defined at all (0 or 1)
If the previous entry is 1, then it is followed by:
-
model - whether a flat shading or smooth shading model is to be used
(0=flat, 1=smooth)
-
ambient reflection 0/1 r g b a, where 0=no ambient, rgb are red, green
and blue intensities between 0.0 and 1.0, and a is the alpha channel
for transparancy.
-
diffuse reflection 0/1 r g b a, where 0=no diffuse component
-
specular reflection 0/1 r g b a, where 0=no specular component
-
shininess - if there is a specular component, then shininess is a
positive number
-
opacity = 0/1, 0 = opaque, 1 = transparant in the case of opacity =
1 then the alpha values above are used.
For example,
1
0
1 0.2 0.2 0.2 1.0
1 0.9 0.1 0.1 1.0
0
0
means:
-
there is a material being defined;
-
there is no ambient reflection
-
there is diffuse reflection, with the rgba values being 0.2 0.2 0.2 1.0
-
there is specular reflection with the rgba values being 0.9 0.1 0.1 1.0
-
The shininess is 0
-
The object is opaque.