Rendering Artifacts in VR using ForwardRenderer, InstancedStereo, and 'Render CustomDepth Path'


  1. Make a new VR project in 4.17.1

  2. Set Forward Rendering to: true

  3. Set Instanced Stereo to: true

  4. Set Custom Depth-Stencil Pass to: Enabled with Stencil

  5. Set Motion Blur to: False (probably not needed but I had it set in all my VR projects)
    4a) This is the config dir .rar’d up: Dropbox - File Deleted - Simplify your life

  6. Make a PostProcess material which will show a silhouette of the character when occluded by something in the world (c.f. this material ( Dropbox - File Deleted - Simplify your life ) which uses the ‘Render CustomDepth Pass’ to make a silhouette)

  7. Add a PostProcess Volume to the StartupMap and set the Material created in 5 to be in the PostProcess Materials List for the PPVolume

  8. Add UE4’s SK_Mannequin (might need to copy this asset over) and Shape_NarrowCapsule to the StartupMap

  9. Select SK_Mannequin and Shape_NarrowCapsule and set ‘Render CustomDepth Pass’ to true on each of those objects. Make certain each object shows its silhouette when something not using ‘Render CustomDepth Pass’ occludes it.

  10. rebuild lighting ^^

  11. Play the game with these options: -game -log -vr -emulatestereo -windowed (e.g. UE4Editor.exe “[path]VRInstancedStereoTes.uproject” -game -log -vr -emulatestereo -windowed )

  12. If you need to do: ` open startupmap

  13. Move around the scene with wasd and/or the just mouselook and notice that the Objects that have ‘Render CustomDepth Pass’ to on them have artifacts (flickering spots)

(c.f. these screen shots: Dropbox - File Deleted Dropbox - File Deleted - Simplify your life )

(c.f. this movie: Dropbox - File Deleted - Simplify your life ) (make certain you Download this as the dropbox compression makes it unusable)

Here is the uproject all .rar’d up: Dropbox - File Deleted

Here is the director with all of the files:

This is essentially z-fighting. It’s caused due to a small floating point result difference between rendering the custom depth path without the ISR vertex shader operations and rendering the depth buffer with the ISR vertex ops. The easiest way to fix it is to render the custom depth objects with ISR too, so the depth values match. It has the nice additional benefit of cutting down a few more draw calls for objects in the custom depth pass. A diff to enable ISR for custom depth is attached here.

If you’re running on PS4, you’ll want to enable both instanced stereo and multi-view. Multi-view is PS4 specific extension of ISR that’s a bit more efficient on their hardware.

Awesome! This fixed our rendering artifacts issue! Thanks so very much for the fast response!!!