Solved: Inside the fish's mouth--custom depth?

polycounter lvl 5
Offline / Send Message
sharsein polycounter lvl 5
I set up this diorama thing in Unreal. Nice and dandy, except the water material clips inside the fish's mouth. Not good.


So I poked around the internet, and it seems like the solution to this problem involves custom depth. Most resources point to this guide, but it seems like that's for stuff like Assassin's Creed eagle vision? I'm having a hard time understanding it. http://www.tomlooman.com/the-many-uses-of-custom-depth-in-unreal-4/
The water is translucent, there's bunch of stuff saying custom depth doesn't work for translucent stuff? I still want to be able to see the submerged parts of meshes, just not that ugly clipping inside the mouth. I was also really confused what needs to be set where, like if I have to add some node to the water, or if some setting on the fish mesh, or both?

If anyone knows any easy to understand tutorials or solutions for this I would greatly appreciate it.

Concept credit: https://www.artstation.com/artwork/dx4JQ

Replies

  • Obscura
    Online / Send Message
    Obscura veteran polycounter
    You can do it like this:

    Have a cover mesh that defines where to hide the water, so it should be inside the mouth. Then this mesh should have "render custom depth pass" enabled, and "render in main pass" disabled. so its technically hidden but it will still render custom depth. You also need to disable cast shadow on the cover mesh. Then inside the water material, you add a thing where you compare scene depth with custom depth, and if custom depth is smaller, so its closer to the camera, it means your water is behind the mesh that we have previously set up, and then just set the opacity of the water to zero.

    In the water material:

    Cover mesh settings:

    Result:

  • sharsein
    Offline / Send Message
    sharsein polycounter lvl 5
    It worked, thanks! :)


    I did hit snags where it didn't seem like the masking mesh was working, but that got fixed once I cleared the old material I had on it. Since I already had stuff connected to opacity in the water material, I found I had to add that input with itself and then combine it with the custom depth nodes with a multiply node. Just using the multiply node increased the overall transparency. There might be a better solution for that, but huzzah anyway.


  • Obscura
    Online / Send Message
    Obscura veteran polycounter
    Thats because of the lerp (0,0.5). If you would replace the 0.5 with 1 or change the if to output 0-1s in a way that is ideal for you, you could get rid of the lerp and the adding with itself. If you would change the lerp to be 0,1 you could get rid just of the adding with itself part.
Sign In or Register to comment.