Realtime Shadows for Pre-Rendered Scenes

I am currently working on a game with pre-rendered backgrounds. Therefore I use the 3d model of the rendered scene with a shader(invisible, hides 3d stuff behind it, casts and recieves shadows).

Now I want to cast realtime shadows from my character on the scene and there is the problem.
I want to show just the shadow that is castet by my character but only the parts of it which woudn’t be casted by my invisible scene.

I know it’s hard to understand so here you have some helping pictures:

Picture 1: No realtime shadows
2253671--150598--Picture 1.PNG

Picture 2: Invisible scene recieves shadow from the character but doesn’t cast one
2253671--150599--Picture 2.PNG

Picture 3: the region where i want to see the shadow from the character
2253671--150602--Picture 3.PNG

Picture 4: Invisible scene recieves and casts shadows (picture gets too dark)2253671--150603--Picture 4.PNG

Everything i need to do would be something like using the shadows from the invisible scene as a mask for the character shadow but i have no idea how to do that.

I would be really happy if somebody can lead me in the right direction or comes up with a good idea.

How exactly did you prerender a 3D environment?

You’ll need a render of the pre rendered scene’s main shadow to use as a mask for where to apply shadows.