Take out water from inside of the boat with Custom Stencil - logic puzzle

Hi guys,

I thought I have a simple task to resolve but i was wrong.

Basically I want take the water out of my boat:
Since I have an opaque ocean , i choose to use Custom Stencil as masking solution. For that I build 2 meshes to play with as it follows:

1. The actual mesh of the boat that i’ll use for render

2. A “mask” mesh to hide the inside of my rendered mesh hull.

3. … and of course the ocean surface.

Now, I assigned, 3 different stencil values to each of my meshes + the ocean
render mesh - > ( mask = 150 , Render mesh = 10, ocean = 200)

My problem is that whatever substractions or adding operations I do with this stencils in my PP material blueprint
i’m not able to get an intersection , to isolate only the water from inside the boat… For sure my math is poor, and i’m missing something:

Help, I’m losing it…

the mesh to render :

the mesh for mask:

viZualisation of my stencil values:

My basic Blueprint in PPDepthShader

1 Like

an example for one of my combinations of stencile masks

Here for example i masked the boat out of my ocean,
but if i zoom inside the boat, under the “roof” of my mask volume
the water is still inside, ( second image in attachment) and i don’t know what fantastic math equation.( part from add and subtract), i should use to cut it out.

does this make any sens to you, or I’m talking gibberish?

I’ve change my method and I’ve done, it. Differently. Using DistanceToNearestSurface to mask a hole in my ocean
in the shape of the boat.
here is the blueprint:

][2]

Custom stencil method, at least for this problem (and for me) is an dead end.

I know this is old, but I’m trying to do something similar. Could you elaborate on what exactly the working setup does? I need something similar, not the exact same, and I’m unsure what to take away from yours.

Can you elaborate more on your solution? About where and how you applied the distance to nearest surface? I might be missing something obvious.

Thanks!

This is a consistently difficult thing to do for many people. Would you mind explaining your customdepth technique in a bit more detail?

Also, what are you using for the ocean system? Is it the Community Ocean Shader? Also, would your customdepth technique work with transparent materials on the ocean plane mesh?

Also tried out so so much… the stencils were a no go for me either… then I also tried the DistanceToNearestSurface method OP described, and oh boy! It worked!

Just plug this into the water material of your ocean or water.

Then make a low poly shape of your boat in 3D, slightly bigger then the hull, import that mesh into the same BP/group as your boat mesh (named DistanceField in the example image), enable Generate Distance Fields on the low poly SM, but change the resolution to like 0.1 instead of 1 (tweak where needed). Then on the low poly mesh disable everything visual related and shadow related, like render in main pass and use as occluder.

A BP would look like this:
image

And then you should be done… just leaving this here for future generations :D…

PS: Make sure your project has Distance Fields enabled in the Project Settings, otherwise it isnt working at all.

1 Like