How to make an object cast a shadow on a flat surface?

But the surface is not part of the final render.

I have a cube, and it is casting a shadow on a flat surface.
I don’t want the flat surface to be in my in my final render.

I only want the cube and the shadow. The shadow that is being
cast on the flat surface ( which, like I said, is not in the in the final render).

Anyone? :confused:

Set ‘Shadows Only’ in the settings of the material used for the plane (Blender Internal renderer)

For the cycles renderer it is more complicated, search for cycles shadow catcher

Funny, I was just watching a tutorial that mentioned this.

-Select your surface.
-Go to the Materials tab of the Properties area.
-Find the panel named “Shadow”
-There should be an option called “Shadows Only”. If you tick that checkbox, it only renders the part of the object that has a shadow on it.

It only took one button? Only one button! I was looking for the answer all over the internet. Set Alpha to 0, put on alpha clip, render it all in UV. And you did it with one button. Thank you sir.