The STL specification has no colour. It says the two-byte attribute byte count at the end of each triangle record should be zero, and never documented anything else. Two groups of programs later put a colour there, in ways that do not match. Neither is part of any published specification; the details below are as described by their users. ASCII STL has no colour at all.
VisCAM and SolidView
The VisCAM and SolidView programs store a 15-bit colour in the attribute bytes of every triangle, read as a little-endian 16-bit value:
| Bits | Meaning |
|---|---|
| 0–4 | Blue, 0 to 31 |
| 5–9 | Green, 0 to 31 |
| 10–14 | Red, 0 to 31 |
| 15 | 1 if the colour is valid; 0 if not, as in an ordinary file whose attribute bytes are zero |
Bright red is red 31, green 0, blue 0 and the valid bit: the value FC00,
stored as the bytes 00 FC.
Materialise Magics
Materialise Magics uses the 80-byte header for the colour of the whole object, and the attribute bytes for the colour of single facets.
| In the header | Followed by | Meaning |
|---|---|---|
The text COLOR= | 4 bytes: red, green, blue, alpha, each 0 to 255 | The colour of the whole object, used by every facet that does not have its own |
The text ,MATERIAL=, directly after the colour | 12 bytes: three colours of 4 bytes each, in the same order | The diffuse colour, the specular highlight colour and the ambient colour |
The text may be anywhere in the header. When both are present, the material is preferred over the plain colour. The facet colour in the attribute bytes, again read as a little-endian 16-bit value, is:
| Bits | Meaning |
|---|---|
| 0–4 | Red, 0 to 31 |
| 5–9 | Green, 0 to 31 |
| 10–14 | Blue, 0 to 31 |
| 15 | 0 if this facet has its own colour; 1 if it uses the object’s colour from the header |
A bright red facet of its own is the value 001F, stored as
1F 00. A facet that takes the object colour is 8000, stored
as 00 80.
Telling them apart
The two schemes reverse both the order of red and blue and the meaning of bit 15, and
a reader cannot tell from the facet bytes alone which one a file uses. A
COLOR= in the header points to Magics. Otherwise the choice is a guess, or
a setting for the user. Neither scheme has a transparency per facet. A reader that
shows the colours scales each 5-bit value to 8 bits, for example as
value × 255 ÷ 31.