Material Properties
Now you can create and light some primitives, we can also look more at changing their appearance, other than simply setting their colour.
The surface parameters can be treated exactly like the rest of the local state items like transforms, in that they can either be set using the state stack when building primitives, or set and changed later using (with-primitive)
.
Line and point drawing modifiers (widths are in pixels):
(wire-colour n) (line-width n) (point-width n)
Lighting modifiers:
(specular v) (ambient v) (emissive v) (shinyness n)
Opacity:
(opacity n) (blend-mode src dest)
The opacity command causes primitives to be semi transparent (along with textures with an alpha component). Alpha transparency brings with it some problems, as it exposes the fact that primitives are drawn in a certain order, which changes the final result where opacity is concerned. This causes flicker and missing bits of objects behind transparent surfaces, and is a common problem in realtime rendering.
The solution is usually either to apply the render hint (hint-ignore-depth)
which causes primitives to render the same way every frame regardless of what's in front of them, or (hint-depth-sort)
which causes primitives with this hint to be sorted prior to rendering every frame, so they render from the furthest to the closest order. The depth is taken from the origin of the primitive, you can view this with (hint-origin)
.