Some of the most useful features in Photoshop are very well hidden, you discover them by accident or somebody shows you.
One of the best Photoshop tricks was shown to me by my former colleague Antti Kallioinen.
I`m very grateful he showed me this trick, because this isn`t something you would stumble on yourself.
The feature in this case is the `Blend If` feature of the `Layer Blending Options`, it allows you to quickly blend layers based on luminosity.
For this tutorials I assume you have a basic to advanced understanding of Photoshop, I will use pictures as much as possible to explain how it works.

Update 1st of February 2008: Jeff Ross has created a short video tutorial which explains this technique clearly and without the tedious reading:

The `Blend If` options will allow you to blend layers by the luminosity of the underlying layers, or the luminosity of the layer itself. Because this sounds a bit cryptic, I will explain the basics using this texture:

It`s not the prettiest texture but it has a lot of contrast which makes it easier to show how it works.

Create a new layer, and fill it with a purple colour (again, not very pretty, but much easier to understand this way):

Now place you cursor over the layer thumbnail or the layer name and press the Right mouse button, if you select `Blending Options` a new window will open (You can also double click on the layer thumbnail to open the Layer Options window):

This might be a familiar window if you ever used Layer Styles, because this is where you would tweak all the options. For this tutorial we will only use the bottom part of the window, which I highlighted in the next image:

These are the `Blend If` options, and this is where the magic will happen! Using the sliders you can set where the currently selected layer will show through. By default the whole layer will always blend, but by tweaking the sliders we can make this layer transparent based on the luminosity (how light the layer is) of the layers below it. Let`s move the black handle of the slider named `Underlying Layer` to the right and see what happens:

If we move the black handle to the right, the purple layer doesn`t show through in the darker areas of the underlying layers. In other words, only if the underlying layers reaches a luminosity value of `119` will the layer be visible. Lets see what happens when we put the black handle to it`s default position, and move the white handle to the left:

By moving the white handle to the right, the purple layer will be visible until the underlying layers reach a luminosity value of `140`
So by moving the handles, we can choose the blend the purple layer in only the dark or the light areas of the image.

Now I can hear you think: "Big deal, but the blending is so grainy I can never use this", and I agree, but luckily there is a hidden feature to make the blending softer. If you select the handle and press the `ALT` key (or `Option` if you are on a Macintosh) you can split the handle. With two handles instead of one, you will be able to set where the blending starts and where it will stop. Instead of an abrupt blending, you can smooth it out:

See how the purple layer blends in more softly? Instead of an abrupt start, the blending is spread out over a range of luminosity.
To be precise: in the darker areas (of the underlying layer) the purple layer is transparent, from 75 to 153 the layer fades in, and when it is brighter than 153 it is fully opaque (non-transparent):

The same way we can smoothly blend the purple layer in the lighter areas of the image:

If the underlying layer has a luminosity of 0 until 67 the purple will be visible. From 67 to 151 it will slowly fade out, and if the underlying layer has a luminosity value of 151 or higher the purple layer will be completely transparent.

Prettier Pictures

Hopefully the basics are clear, time to get rid of that ugly purple colour and show a more useful example.

One thing we can do is replace the light mortar between the stones with sand. Here is the stone texture and the sand texture shown side by side (in the Photoshop document they are on top of eachother, the stone texture on the bottom layer and the sand texture on the top layer) :

Next we go to the layer options of the Sand layer, and tweak the blending so the `sand` layer will not show up in the darker areas of the `stone` layer:

Then split the handle by dragging it while pressing `ALT`, and set the blending ranges for a nice soft transition:

And there you have it, with just a few clicks you have a sand covered floor texture. And what is best, it is completely non-destructive. What I mean with this is that the sand layer is still intact and unedited, we didn`t need to erase or delete anything. If you change the underlying layer (add more stones for example) it will still work without having to do anything to the sand layer.

What if your situation calls for orange colored stones instead of black ones? No problem, just add a layer of orange colored rock and blend this layer in the darker portions of the stone texture:

More Examples

A different texture this time, here is a concrete texture as a base with a greenish moss texture on top:

Overlay these two and make the moss transparent in the lighter parts of the concrete and we get this:

But what about having the dark seam in the concrete show through? With a combination of tweaking the dark and light handles we can have the blending not show the moss layer in the dark areas of the concrete texture:

It might be a bit confusing to see all those handles spread out, and it will take some playing around before you will get the concept completely. A good exercise is to try to predict how you need to place the handles to get the effect that you want.

Blending using the `This Layer` slider

Until now we`ve only used the `Underlying Layer` slider to blend, lets see how we can use the `This Layer` Slider. Here is a metal texture, and a rust texture:

Using the `This Layer` slider, we can blend in the rust layer so only the dark spots show up. Only where the rust layer is dark will it be opaque. When the luminosity reaches the value of 137 it will be fully transparent, so the light parts of the layer (the paint) will not be visible.

Blending Adjustment Layers

The layer that is being blended can also be an adjustment layer. For example, a `Hue/Saturation` Layer can be blended in the lighter or darker areas of an image. This is very useful to recolour of textures. For this exampe we`ll take the rust texture again, and recolour it so the paint is green. Because the Hue/Saturation layer is also colouring the rust, it doesn`t look very realistic anymore:

But with the layer blending, we can have the Hue/Saturation only show up when the layer is light (in this case, the paint part):

Because the blending is soft, even the subtle leaking stains can be kept intact.

Conclusion

`Blend If` can save you a lot of tedious masking and `Color Range..` selection. Another good thing about this technique is that you all other layer options are still possible, you can for example still a paint layer mask if you wouldn`t want the layer to be invisible in a certain place. Also, all the layer blending modes (like overlay or multiply) still work, so the possible combinations are endless.

In the future I will add some smaller tutorials that use this technique, for example to recolour textures or for adding dirt.