This entry will cover the function of creating a material mask using an image texture. Our starting model is a simple sub-surfaced cylinder with a uv-mapped texture on it.
Using the following material node setup, we essentially are taking a second texture and masking out parts based on luminance. A bright magenta is used to show what would normally be another texture showing through. The ColorRamp node converts the output of the texture to black and white, while the sliders allow you to control what parts of the texture will show through.
An example of the cylinder now masked showing some magenta areas through.
Taking this node setup further, the output from the ColorRamp can be fed into a Mix Shader to also act as a mask for another shader (in this example a Glossy Shader). A Mix Color node must be placed in between to control the strength of the second shader. The second color of the Mix Color node must be set to black, acting like a scale between black and the full white from the ramp.
The result of this setup is as shown below, where the glossy is only affecting the areas that are masked per say.