What you should be looking at is how to build a shadow-catcher material.
You can look for detailed tutorials online by keywords: “V-ray matte shadow catcher material”.
Basic steps:
-
Create a generic material and use a light gray color for it.
-
Create a new wrapper material and use the background material as a base
-
Set Alpha Contribution to -1
-
Turn on “Matte” option
-
Turn on “Shadows” option
-
Apply the material to faces.