UE4 unaware of change in bRenderCustomDepth

When I set bRenderCustomDepth to true on the mesh of my ACharacter actor, the desired highlight effect on the mesh doesn’t work until I change the Cloth Blend Weight value on the mesh to any value in the details section. It seems as if UE4 is unaware of the change made to bRenderCustomDepth during gameplay and only becomes aware of it the moment Cloth Blend Weight is changed manually in the details section.

Solved it using SetRenderCustomDepth() instead of setting bRenderCustomDepth directly.

Thank you for posting the solution, this one had me!

Well this is just bad design right here.

Bad design? Not really. Like many graphic functions in UE4 SetRenderCustomDepth() does not execute something immediately but rather sets the stage for a complex rendering pipeline by either telling the scene that this will have a given effect (true) or making the scene dirty so it can plan its removal (false). Therefore, you don’t want to waste time checking if a value has changed for a single effect change (as there are many values to check along the way). And yes, it will set bRenderCustomDepth but its effect will happen later on. The reason bRenderCustomDepth is public is only to be used in the constructor (or a Blueprint check mark on the properties sheet) by which the complex rendering pipeline will kick in eventually for the first time and take that flag into account.

So it’s always confusing as we (myself included) take for granted that the first match Intellisence will give us is the good one and assume that this should “just work”.

There are many bXXX values that have a SetXXX() equivalent in UE4. Just keep a sharp eye as to when to use them. :slight_smile: