[4.12] Cable Components Don't Render Custom Depth Pass

Cable components include the render flag for ‘render custom depth’, but it doesn’t seem to have any effect. I would really like to do a post process material on the cables in our game, but I can’t get one working. I tried using a conditional on the custom depth value, and I tried using a custom stencil, but neither worked for cable components (they worked for other meshes in the scene, though). Just for more info, my custom depth pass is before the tone mapper, and my cable’s material is opaque.

Hey extralongpants,

Can you provide me with some screenshots and steps so I can visualize and reproduce this issue on my end?

Since you are trying to use Custom Depth I highly recommend taking a read over an article one of our staff wrote for the many uses of Custom Depth in Unreal Engine 4.

Let me know if you have further questions.

Cheers,

Hi Andrew -
Sure, here are some simple steps:

  1. Create a blank project with starter content -mine had a level with two chairs, a table, lights, etc. in it.
  2. Click on one of the chairs and add a cable component
  3. In the cable component, set ‘Attach End To’ to the other chair.
  4. Set the cable’s local location to (0,0,100)
  5. Set the cable’s ‘End Location’ to (0,0,100) - so you can see it above the ground.
  6. Assign an opaque material to the cable. I used M_Basic_Wall.
  7. In the cable’s rendering settings, check ‘Render Custom Depth Pass’ and set ‘Custom Depth Stencil Value’ to 255.
  8. Click on one of the chairs and do the same thing - enable Render Custom Depth Pass and set the custom stencil value to 255.
  9. Go to Edit → Project Settings… → Rendering. Set ‘Custom Depth-Stencil Pass’ to ‘Enabled with Stencil’.
  10. Create a new material and open it for editing
  11. In the material’s settings, change the material domain to Post-Process.
  12. Also set the ‘Blendable Location’ to ‘Before Tonemapping’
  13. Create nodes to match: http://imgur.com/a/QaFC1 (just does a simple color*10 on objects that write to the custom stencil buffer).
  14. Save your material
  15. Go back to the scene, and click on the ‘GlobalPostProcessVolume’.
  16. Expand the Post Process Volume Settings, expand Blendables, and add an element
  17. In the drop down, select asset reference.
  18. Choose the material you just created
  19. The chair will now glow brightly through objects, while the cable looks the same as it did before: http://imgur.com/JvMb8jP
  20. :frowning:

Hope that helps.

Thanks,
Chris

Hey Chris,

Thanks for the clear and precise repro steps. I was able to confirm what you are reporting and have gone ahead and entered a bug report for the issue. You can track the issue following the link below on our new Public Issues Tracker.

UE-34365

Once the issue has been addressed by our engineers, the fix will be added to the release notes for fixed issues within an upcoming full engine or hotfix release.

Let me know if you have further questions or need additional assistance.

Cheers,

Great, thank you!

Sorry to bump this but I was having the same problem, saw that the bug was marked as “Won’t Fix” and fixed it myself on the engine code:

128310-2017-02-28+(1).png

I haven’t noticed any problems after changing the code, just added one line actually. Should I send this to Epic to include on the next version or what?

You could make a pull request with the change in question. What was the line you added?

On CableComponent.cpp I just added:

Result.bRenderCustomDepth = ShouldRenderCustomDepth();

to the GetViewRelevance function on the FCableSceneProxy class. I don’t know the exact line cause I’ve been changing some stuff on the CableComponent class and it’s likely that it won’t be the same to you.

Now Epic states that when a bug is marked as “Won’t Fix”, this could mean that they won’t have time to look into that because there’s too much stuff that’s more important or that the bug may break something in the engine. I hope it’s the former and I wish someone could clarify that to me.
Well, I’m making a pull request and I guess I’ll find out then.

1 Like

Thanks for sharing your fix! :slight_smile: From the description, it looks like the bug just went to won’t fix because it hasn’t been updated in a while. Hopefully Epic will reopen it in response to your pull request.

This is still broken in 4.17. It’s annoying - please fix

This is bull**** ;/ Almost two years and still…

3 years and nothing

Thank you for posting the solution, the custom depth on my cable now works as expected! :slight_smile:

i tried this solution on unreal 4.27 but i couldn’t get it to work.
i opened up CableComponent.cpp at Epic Games\UE_4.27\Engine\Plugins\Runtime\CableComponent\Source\CableComponent\Private
i then inserted the line of code like this

virtual FPrimitiveViewRelevance GetViewRelevance(const FSceneView* View) const override
{
	FPrimitiveViewRelevance Result;
	Result.bDrawRelevance = IsShown(View);
	Result.bShadowRelevance = IsShadowCast(View);
	Result.bDynamicRelevance = true;
	MaterialRelevance.SetPrimitiveViewRelevance(Result);
	Result.bRenderCustomDepth = ShouldRenderCustomDepth();
	return Result;
}

but it still wont work. did i do something wrong or is there something i’m missing?

Hello @Overshoot

I think you should set

Result.bRenderCustomDepth = ShouldRenderCustomDepth();

before calling

MaterialRelevance.SetPrimitiveViewRelevance(Result);

Maybe that will work?

This is still an issue, Epic - and it seems like it could be an easy fix. UE-34365

5.4 at preview, cable component support path tracing. I hope that dont change in final version. (I will test in Movie Render Queue)