Render only depth

Is it possible to make something rendering only into the depth?
I tried disabling “render in main pass” but then it doesn’t render depth either.

Hey Obscura90,

What you are looking for is Custom Depth, which is done through a custom depth buffer so you can write certain actors to only draw to that depth buffer. Below is a tutorial and examples of how to use custom depth written by our own Tom Looman.

Many uses of Custom Depth

Custom Depth

Let me know if you have additional questions.

Thanks,

Hello!

Thanks, but unfortunately custom depth doesn’t really help on what I would want to do, because its not a post process.

I would want to cull some translucent material parts, by putting an “invisible” object on top of it, that renders only depth, like in this video:

The post processing is simply an overlay to draw the selected objects you have set to only render in custom depth. The functionality will be within the shader itself and within your blueprints.

Lit - Custom Depth

Buffer Visualization - Custom Depth

As you can see, I have selected the object to only render in the custom depth buffer. The shadow persists just because I have not rebuilt my static lighting, but this is the only way I know of to render and object in the world only with depth. You could set it up via a SceneCapture 2D actor, but that only applies to the Render Target and not the physical geometry placed in the world.

Cheers,

Thanks for taking your time, but custom depth is not what I’m looking for. As I mentioned above, I’m trying to use this invisible object, to “unrender” some parts of a translucent material. Imagine a boat on the water. You wouldn’t want the water to appear inside the boat. In the video I was showing, he shows a technique that uses a mesh that renders only depth, and its placed on top of the boat. So when you look at the standard depth pass, you dont see inside the boat and the translucent water material also doesn’t appear inside the boat. The game that was shown in the video didn’t made with Unreal Engine, but I guess it would work the same, if I could somehow set it to render only depth…This is not for a project by the way, I’m just curious if this is possible to do in Unreal, or not.

Actually , yes. I could use this with the scene capture, and just use the render target as opacity in the material. But if there would be a way without scene capture, that would be nice.

You can use an If node within your material to put checks in place to make sure it doesn’t render when the water clips into the geometry. This or custom depth are the way you would go about doing this. I understand what you are trying to do, and perhaps you might be misunderstanding how custom depth is used within the engine. Either way, goodluck!

Now I see how could you use custom depth. I didn’t know you can use the scene texture node in translucent materials. I thought its only for post process materials. Works like a charm,thanks again!

Hi Obscura90,
I have same trouble with you. I used some ways like customdepth but not work. Could you please tell me how you solve this problem? I want render some object only depth but not in main pass,thanks a lot!

I have just encountered this issue… the bRenderInDepthPass flag seems to only work for StaticMeshComponent (and its derived classes). It does not work for ProceduralMeshComponent. A fix for that is a one liner that needs to be added to the GetViewRelevance method of the FProceduralMeshSceneProxy class:
Result.bRenderInDepthPass = ShouldRenderInDepthPass();

This unfortunately will require you to make a custom build of UE.