This recipe is another procedural texture, which is an extension of our circle pattern shader. In that recipe, we looked at the logic behind producing a 2D circle pattern on a planar surface; this planar surface was created using fragment coordinates. In this recipe, we will create a polka dot pattern on the surface of the 3D mesh object; the main difference here is that instead of producing a logical circle in the square, we will use an inscribed logical sphere within the logical cube of dimensions Side x Side x Side units:
In this recipe, we have reused the lighting technique using the Implementing two-side shading recipe in Chapter 5, Light and Materials. The generic vertex attributes for vertex positions, normals, and texture coordinates are laid out with 0, 1, and 2 indexes, respectively.