How to make a model cast shadows onto the world texture/background?
CYCLES ENGINE
Shadow Catcher
Starting from version 2.79 any mesh object can be set as Shadow Catcher.
Select object (like a Plane) and check this option.

2.79 located in Properties Editor &gt; Object &gt; Cycles Settings
2.8+ located in  Properties Editor &gt; Object &gt; Visibility



Issue of current Shadow Catcher
Shadow Catcher can receive only shadows (limits are nicely summarised in this DevTalk) So I will keep Shader method, that can be used to &quot;catch&quot; also emission, indirect light or reflection that gives more sense in term of merging CG into image. Comparison ...
Example of Shadow Catcher issues -/- comparison with Shader solution


Edit 2021-05-05 Finaly movement :) Initial implementation of improved shadow catcher. Anyway here is shader solution for now ...

Shader for HDRi Environment

This material for ground plane object can also receive lights, indirect light or reflection.

This material gives you precise feedback if the HDR image lights correctly. If not, ground plane will be brighter or darker (or will tend to be a different colour tone) depending on image color deformation.


Material for ground (plane) is Diffuse shader with assigned Environmetal (Equirectangular) HDRi texture. The same texture used for World. The trick here is to use &quot;Reflection&quot; texture coordinates with negative Z value (-1). For smaller color differences between found and environment use RGB node.

Showcase https://vimeo.com/159234378
For more examples and tests check out this Blenderartists thread.

Lighting by HDRi
is another topic, so just a quick tip if HDRi doesn't light properly. Use this World node setup, in most cases just increase/decrease Fac value of the first &quot;Mix&quot; node solves. Second &quot;Mix&quot; node affects &quot;Exposure&quot; of the HDRi.

If lighting seems to be ok, but shadows are still too blurry you will have to fix the HDRi image manually. Open the image in an image editor that supports 32 bit images, select small circle in place of sun and increase exposure. Sorry can't find the tutorial link.
Rendering – Be sure &quot;Multiple Importance&quot; is enabled in World Properties panel (value like 840), it should be checked by default.

Shader for Backplate (2D image)
In case you want to merge your CG with the backplate, simply use &quot;Window&quot; texture coordinates for shadow / light receiver. This material doesn't have a geometry limitation. In this example, a plane is used also, but it can be any shape. Scene is lit only by a sun with strength that brings ground image to background colours. Both previously mentioned benefits (shadow/light receiver and in this case general feedback of correct lighting) works here too. Disadvantage of backplate (compared to equirectangular HDRi image) is lighting inaccuracy and missing reflections.
Note: the same node tree is used for the world.


Note:
There exists OSL shader QUIP and QUIPCam for this purpose that gives you the ability to have a bit of movement in the environment too. But OSL isn't supported for GPU calculation and takes quite a lot of time to get a clean render.