I have an object that's lit by an HDR and a sun lamp. I want that object to cast shadow by the light coming from sun lamp only. How to do that?
Starting with a scene like this where one layer has a cube and a sphere are being lit by HDRI only.
The sphere has the shadows disabled in the cycles settings
On a separate layer containing the plane, a copy of the sphere with the shadows enabled and a sun light.
Create two render layers, one that uses the environment, and a second one that does not, and has the shadow pass enabled: