Mask an object based on the shadow it's receiving?

Is it possible to make a dynamic mask from shadows of a directional light? So the part of the object which is in the shadow can be masked to use different color or texture?

Example:- http://puu.sh/sqvJr/c6bd1b5894.jpg

With Forward Rendering maybe you could use this approach: link