Pre-rendered Backgrounds using custom stencils?

I’m having trouble setting up pre-rendered backgrounds similar to classic Resident Evil, Final Fantasy, or Parasyte Eve on the PS1.

I have multiple camera trigger volumes that activate the camera when overlapping, and it creates that fixed camera angle. I’m rendering everything in real-time 3D in the game, but I’m using Level Sequencer and Movie Render Queue to render the camera scene to a final color image and depth map in PNG and EXR format. Then I set all the meshes in the scene “Actor Hidden In-Game”. So that they’re hidden when playing the game, but the collision is still there. Then I applied a post-process material to the camera so that when you’re in the camera trigger volume, it should activate that fixed camera and display the pre-render background along with any additional 3d meshes or particles (stencil order “2” for particles, stencil order “1” for character or any other meshes).




As you can see from the screenshots, it seems that the stencil layering is working correctly but the background image is overlaying it with an outline and won’t display behind everything else. I’m not sure what else to try or look for…

EDIT: Updated. Made some progress, notice it has to do with depth maps and comparing depth map with scene depth to figure out masking.

1 Like


I made some progress with this. I figured out that the issue has to do with the Scene Depth (that it gets from the scene vs the Depth Map that is saved into the alpha channel of the texture map.

I have had the SceneTexture.SceneDepth divide by a number like 2000 and then input to the Red channel Component Mask. Then it compares the Scene Depth and Depth Map to figure out what is front or back. So far, it’s sort of working but it has some clipping and overlapping even when I try adjusting the number. It’s not smooth. Also, I tried a higher resolution Depth Map, it did better but then it had other clipping issues.

Is there a better way to do depth maps? Why should I compare the scene depth and depth map? I don’t know how others have done this so well while I am having issue with clipping and overlays. See below:


Any suggestions or help would be greatly appreciated!

1 Like

Finally solved it! The material was set up correctly. The division node is required. Just had to ramp up the value to like 10,000. But also, needed to re-render the Depth Map using Movie Render Graph (PIZ compression EXR with SceneDepth at a higher resolution at 32-bit quality).

So it was a three-issue:
Lack of a division node with the SceneDepth node.
Lack of resolution, quality, bit depth, and file format for the Depth Map and Color.

You should export the Scene as a final color image and a scene depth (both as EXR, 32-bit). Then, in Photoshop, open the EXR file (with alpha channel and HDR viewing turned on). Also, open the EXR depth map in Photoshop and convert to grayscale. Copy and paste the grayscale map into the alpha channel of the color map. Then you have a single EXR file with the HDR color and depth map. When you import the map into Unreal, make sure to change compression to HDR with Alpha (no sRGB).