Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[Bug] Custom Depth/Stencil doesn't work consistently when enabled from Blueprint

Summary: static meshes that should render to the CustomDepth and CustomStencil buffers fail to do so when they are occluded by other meshes. This ONLY occurs when said functionality is enabled from script rather than on the Static Mesh Component itself.

Apologies if this was already submitted but I couldn't find anything. I ran into this when upgrading my game from 4.15 -> 4.17.

Here's a fresh sample project (link) with a 100% repro (20/20 attempts).


  • Place a cube static mesh and make it a Blueprint with the following nodes: Set Render Custom Depth = True and
   Set Custom Depth Stencil Value =

  • Add a post process material that simply visualizes the CustomStencil buffer.

  • Run the game from the default camera position. The cube SHOULD appear as a white box onscreen because of the post process material, visible through the occluding wall mesh, but it doesn't. If you strafe the camera around the wall so that the cube isn't occluded anymore, it will suddenly be visualized by the postprocess.

  • Now go to the cube's static mesh component and set "Render CustomDepth Pass"=True and set "CustomDepth Stencil Value"=1. Result: the cube will always appear in the postprocess, regardless of whether the mesh itself is occluded, as desired.

My game has a lot of meshes that are visualized through walls using the CustomStencil feature after certain scripted conditions are met, but unfortunately this bug totally breaks that functionality. It seems like I can work around it by turning on custom depth on all my meshes, turning it off in script, and then turning it back on again when I need it enabled, but that's a pretty awkward workaround for the dozens of blueprints I need to do it for. Help would be appreciated, thanks!

Product Version: UE 4.17
capture.png (70.0 kB)
more ▼

asked Sep 04 '17 at 10:17 PM in Bug Reports

avatar image

107 2 5 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hello Rinbu,

Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here


You can track the report's status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

more ▼

answered Sep 21 '17 at 03:18 PM

avatar image

Thomas G ♦♦ STAFF
7k 64 4 54

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I found workaround for this bug:

In c++ create function and call MarkRenderStateDirty() on your mesh component (after SetRenderCustomDepth()).



I found out that in 4.15 MarkRenderStateDirty was called everytime in SetRenderCustomDepth(), but why epic changed that?

more ▼

answered Nov 22 '17 at 01:38 PM

avatar image

Max Payne_
26 3 3

avatar image clau_ccanada Feb 28 '19 at 02:10 PM

It sounds like a good solution! I tried... but it didn't work. In my case, I have several ProceduralMeshes and RenderCurstomDepth activated by bluprint works only with some of them. I'm almost sure that is related to the fact that the ones that don't work have translucid materiales. Is this true? Anyone experienced the same issue?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question