Hi I am new to UE and I am trying to hide water inside a boat. In unity 3d there was a script Unity 5 Pro boat simulator - depth mask for water surface removal - YouTube . Is there something that can help in UE4 ?
Thanks
Hi I am new to UE and I am trying to hide water inside a boat. In unity 3d there was a script Unity 5 Pro boat simulator - depth mask for water surface removal - YouTube . Is there something that can help in UE4 ?
Thanks
You can enable custom depth rendering to render boad to a custom depth\stencil buffer. Enable it for your boat and set stencil value to 1 for example. In water material you have to set water alpha to 0 on any pixel which has stencil == 1
Can you please show to me a BP example ?
It is just material settings, not a blueprint. To create this effect you have enable render custom depth\stencil inside your project settings first.
Then you have to enable custom depth rendering for your mesh (inside mesh properties)
And create a material like that
This material compares current stencil buffer value with the given constant (I used 25, it doesnāt matter) and chooses the alpha for water between 0 and other value.
With this material as water and any static mesh you will get something like this
Until you enable custom stencil and specify stencil value greater than used in material.
To get best effect you have to separate your boat mesh to two parts: inner and outer. And enable custom depth stencil on both parts but set stencil value > 25 for inner part and < 25 for outer.
Improved a bit. This shader utilizes not only custon stencil but the depth too. It does not require rendering boatās exterior with enabled custom depth and will handle intersections with the world better.
That was very helpful and I want really to say a big thank you.
The problem is that this technique is can not be used by modifying the ue4 ocean water.
Is there a work around to make is work with opaque materials ?
Many thanks.
I tried to use your technique on the translucent water that come with UE4 but it is too complicated to use it. Can you help ?
Big thanks.
I packed this to the separate MaterialFunction [MaterialFunction][1]
Not sure that it possible to load directly from UE (you can try to copy this asset directly to your cintent folder)
It contains exactly this:
To insert this inside your material add CallCustomFunction node and connect it as shown on a picture
Stencil value input allow you to select working stencil value (less than boat interior and greater than boat exterior), by default it is 128
Unfortunately this can not be used with opaque and masked materials. On them depth buffers are inaccessible to read, Maybe it will be possible to pre-bake your boat depths picture each frame before rendering whole scene and use PixelDepthOffset to push water out from a boat. So, if your boat have near-square deeping it is possible to evaluate required PDO without any extra rendering, and both of these ways are bit complicated.
This works for ES5, anyone know of a solution that works for ES3.1/Mobile? cant use scene nodes.
ok so i followed all of your exampleā¦ I am using Dev kit for CE which is v4.15.3 Annndddd I cannot get this to work
And i did test if 0 or 1 was working for visible but for some reason its not looking at the render stencil to determine what pixel it should be at >< anyone know why ?
Thanks a lot Artefix, thats was very needed!
I follow this video step by step but it doesnāt work for me, I donāt know what Iām doing wrong. I double checked everything many times with no profit. Any idea where the problem might be?
on UE 5.2.1
Hi,
Iām totally new to UE5 (and UE in general), Iāve been googling and trying methods for two days nowā¦
Eventually got Artefix_3D1 method (the youtube video linked a few posts above) to exhibit signs of working, but not quiteā¦
āNew users cannot post attachmentsāā¦ srsl?
Ok, here goes verbal description:
Iāve only started learning UE5 a 3 days ago, and I have already encountered 3 full-on bugsā¦ What is this?
Any advice on how to successfully mask out water from the inside of a boat (in this case a hollowed-out submarine) would be greatly appreciated.
Get used to that, thereās a lot of bugs and weird behaviors with this water.
For masking water out of submarine Iām using both distance field test and cutting out a hole in water surface where the boat isā¦ neither seems reliable enough on itās own.
Iāve made a snippet a while ago for the hole thing
just make sure you are not editing original water materials, copy them or they will be reset to default if you upgrade engine version or reinstall.
the first image you posted is kinda broken, I cannot make sense of what i am seeing here!!
I dont use blueprints but I think the lines should be connected
those are not images I posted, itās bp code in text format that some script tries to render. looks fine here. you can try and copy paste the snippet into your bp with ācopy full snippetā button