Node setup for shadow only material. Need some improvement but I think that is a good start.
this method not work with light objects (emission material)
this method not work with light objects (emission material)