Surfaces whose shininess varies, like wet marble or wet paper or fabrics that are smoothed only in places, can be modeled with gloss maps. A gloss map is a texture which modulates the contribution from specular lighting, so that some points on the surface reflect less specular light than others.
This technique can be implemented using a multipass process in which the diffuse, ambient, and emissive lighting components are drawn and then the specular lighting component is added using blending.
First, draw the surface normally with specular lighting disabled. This can be performed by setting the specular material value to zero, for example, in OpenGL, by glMaterialfvGL_ FRONT_AND_BACK, GL_ SPECULAR, specularColorArray(GL_ FRONT_AND_BACK, GL_ SPECULAR, specularColorArray), and then drawing the surface normally.
Second, draw the surface with the specular color restored and the diffuse, ambient, and emissive colors set to zero, and with a texture encoding the gloss map. The texture can be a one component alpha texture or a two or four component texture with the maximum value set for the luminance or color components.
Typically the gloss map value is stored directly in the alpha component, with zero indicating no contribution from the specular component and one indicating the full specular reflection is to be added. Draw the second pass with blending enabled, adding the new pixel color modulated by the alpha value from the texture. (In OpenGL this behavior is configured with glBlendFuncGL_ SRC_ALPHA, GL_ ONE(GL_ SRC_ALPHA, GL_ ONE)). The meaning of the alpha component may also be reversed if the applications takes care to reverse the frame buffer blending operation as well.
The second pass can be drawn either with the depth test set to pass when the framebuffer depth equals the depth of the surface, or the initial pass can set the stencil buffer where the depth test passed and the second pass drawn where the stencil buffer was set.