Announcement

Collapse
No announcement yet.

Render to SceneDepth only

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Render to SceneDepth only

    I have a Blueprint with a static mesh component that is translucent. I understand that translucent meshes don't render to the scene depth, so I followed the advice in this post, but it doesn't work.

    https://answers.unrealengine.com/que...t-objects.html

    The idea is to duplicate the static mesh, and then turn of Render in Main Pass and turn on Render CustomDepth pass on this duplicate mesh. That way you don't see the duplicate mesh in game, but it will still render to the scene depth. However this appears to no longer work. The duplicate static mesh does not render into the scene depth buffer at all.

    Is this a bug or is there a new way to do it now, considering that post was from 4 years ago.

    #2
    You do not need to duplicate the mesh. Translucent objects can write to custom depth. There is a checkbox in material settings.

    Comment


      #3
      Originally posted by Deathrey View Post
      You do not need to duplicate the mesh. Translucent objects can write to custom depth. There is a checkbox in material settings.
      I've seen that and already tried it too, but it doesn't work. I have the feeling that both Render to CustomDepth Pass on the static mesh and Allow Custom Depth Writes on the material is for writing to the custom depth buffer. However it doesn't write to the actual scene depth buffer.

      So either it is not meant to write to the scene depth buffer and there is another way to do it, or it is a bug that should be reported.

      Comment


        #4
        Originally posted by Deathrey View Post
        You do not need to duplicate the mesh. Translucent objects can write to custom depth. There is a checkbox in material settings.
        I think the idea is to write to the actual depth buffer, rather than custom depth. As far as I know, effects like depth of field can only function based on the scene depth buffer, so if the goal is to apply depth of field to a translucent object (rather than whatever is behind it), this won't work.

        Comment


          #5
          So either it is not meant to write to the scene depth buffer and there is another way to do it, or it is a bug that should be reported.
          It is likely intended. If such functionality ever existed in past, it was and is undesired.

          There are workarounds to get mesh to render only in depth buffer, but I have no idea how one could apply that, especially considering that it would happen during pre/base pass.

          Comment


            #6
            Thanks anyway guys... surely someone knows how to do this. I can't be the first person that needed to render only to the scene depth buffer.

            Comment


              #7
              If I understand what you want, this definitely still works in 4.22. We use it for highlighting fully or partially translucent objects.

              + attach dupe static mesh with default world grid material (UStaticMeshComponent* proxy)
              + proxy->SetRenderInMainPass(false);
              + proxy->SetCastShadow(false);
              + proxy->SetCollisionEnabled(ECollisionEnabled::NoCollision);
              + proxy->SetRenderCustomDepth(true);

              One thing you might have forgot is swapping the material of the proxy to a non-translucent? We use the Unreal default world grid.

              Below is example of a translucent cube highlighted via CustomRenderDepth method.

              Click image for larger version  Name:	HighlightProxy.jpg Views:	1 Size:	194.2 KB ID:	1631257
              Last edited by Shmoopy1701; 06-14-2019, 10:22 AM.

              Comment


                #8
                Ohh hmm you want scene depth not custom depth. Will leave the above anyway in case someone searches this topic.

                Comment


                  #9
                  Well I sent a bug report in about it just in case, but turns out, no it is not a bug. I was told to post to answer hub, which I've done now.

                  https://answers.unrealengine.com/que...3454/view.html

                  Hopefully someone has done this before and notices my post.

                  Comment


                    #10
                    Thanks guys. I managed to solve the problem. It is actually possible to do what I wanted to do, just took a bit of experimentation and thinking outside the box.

                    Comment


                      #11
                      Can you post the solution for future google searches? Also just wondering but what is the use case for this?

                      Comment


                        #12
                        Originally posted by wilberolive View Post
                        Thanks guys. I managed to solve the problem. It is actually possible to do what I wanted to do, just took a bit of experimentation and thinking outside the box.
                        Writing that you "solved it" and not posting the solution is a grave sin in the question/answer community Please update the thread with the solution or point others in the right direction. Thanks!

                        Comment


                          #13
                          I found this thread while trying to find a way to get DoF to work with a translucent plane. My thought process was that if I had a second plane, rendering only to the scene depth, and put that plane beneath my translucent plane, I would be able to force the DoF code to use that second plane's depth for the the translucency plane. It doesn't work though because there's no way to render to just the depth buffer that the DoF shader uses.

                          I did however get something working, but I'm not proud of it. Below is a screenshot. It's a partially translucent plane (opaque on the white squares, translucent on the black), with some cubes underneath and above it. If you notice, depth of field appears to be working... the translucent plane blurs correctly, and also reveals the cubes underneath.

                          Click image for larger version

Name:	dof.jpg
Views:	1
Size:	82.0 KB
ID:	1655183

                          How is it done? A scene capture component on the pawn. And a hidden plane just underneath the translucent plane. The scene capture component ignores both planes. Then the render texture of the scene capture component gets projection-mapped onto the hidden plane. Like I said, not proud of it, but it seems to work ok. I've attached the scene files for anyone interested.

                          TranslucentDoF.zip

                          Comment


                            #14
                            Hey Guys, i want to write my mesh to scene Depth so i can use GPU emitters collision which works on scene depth
                            i tried using the above technique but that does not work.
                            if wilberolive can post his solution that would be great.

                            Comment

                            Working...
                            X