Is there a way to render a static mesh to the scene depth buffer only. I want to turn of Render in Main Pass so the mesh is hidden, but doing this causes it to not render to the scene depth buffer, which I still want it to. I know I can render it to the custom depth buffer, but that is not what I’m looking for. I need it to render to the scene depth buffer. Surely there is a way to do this?
No, there isn’t. There is, but consider that there isn’t and act accordingly. Rendering to depth buffer only is outside of common pipeline and needs to be done in code(plugin, or engine change, depending on particular case).
Thank you for your very uninformative answer. Please don’t clutter answerhub with “answers” that don’t actually solve the problem. It doesn’t help others in the future looking for a real answer.
After some research, it turns out that it is actually possible. I’ll update the main forum thread with more details.
https://forums.unrealengine.com/development-discussion/rendering/1630765-render-to-scenedepth-only
Hi , I am a programmer and I am trying to fix this problem ,yes , I consider it as a problem.Please wait my work.
Hi ,wilberolive
I am glad to tell you I have fix this problem by just modify one place, yes, it is a bug not fixed until UE4.24.
You need to get souce code first, than modify:\Engine\Source\Runtime\Engine\Private\StaticMeshRender.cpp
FStaticMeshSceneProxy::GetViewRelevance
…
Result.bRenderInMainPass = ShouldRenderInMainPass();
- → Result.bRenderInDepthPass = ShouldRenderInDepthPass(); (this is reason not render t o scene depth )
…
ok, build ue4 project , done.
Hello, @sitonmoon
Which version of Unreal Engine did you test these changes on? In version 4.22.3, the FPrimitiveViewRelevance structure does not include a member called bRenderInDepthPass, and additional modifications are required.
Hi,@montazeran123
Apologies, but I’m currently working in UE5 and have not old engine versions. From what I recall, those previous modifications should have been based on UE4.24.