Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Hiding water surface inside a boat

Hi I am new to UE and I am trying to hide water inside a boat. In unity 3d there was a script https://www.youtube.com/watch?v=-KNevBGhpxI . Is there something that can help in UE4 ?


Product Version: UE 4.15
more ▼

asked Mar 14 '17 at 12:19 AM in Rendering

avatar image

8 2 3 6

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

It is just material settings, not a blueprint. To create this effect you have enable render custom depth\stencil inside your project settings first. alt text

Then you have to enable custom depth rendering for your mesh (inside mesh properties) alt text

And create a material like that alt text

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 alt text

Until you enable custom stencil and specify stencil value greater than used in material. alt text

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.

enablecds.png (56.5 kB)
mat_psw.png (87.9 kB)
wo_cds.png (520.4 kB)
with_cds.png (503.6 kB)
more ▼

answered Mar 17 '17 at 04:37 PM

avatar image

1k 12 8 31

avatar image c4tnt Mar 17 '17 at 04:48 PM

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. alt text

mat_psw.png (158.1 kB)
avatar image cmvrgr Mar 17 '17 at 11:22 PM

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.

avatar image cmvrgr Mar 17 '17 at 11:28 PM

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.

avatar image c4tnt Mar 18 '17 at 04:06 AM

I packed this to the separate MaterialFunction MaterialFunction 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: alt text

To insert this inside your material add CallCustomFunction node and connect it as shown on a picture alt text

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.

mf_shader.png (154.8 kB)
mf_usage.png (31.9 kB)
avatar image EmpireLion Jan 01 '19 at 01:22 AM

This works for ES5, anyone know of a solution that works for ES3.1/Mobile? cant use scene nodes.

(comments are locked)
10|2000 characters needed characters left

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

more ▼

answered Mar 14 '17 at 03:24 AM

avatar image

1k 12 8 31

(comments are locked)
10|2000 characters needed characters left

Can you please show to me a BP example ?

more ▼

answered Mar 16 '17 at 07:13 PM

avatar image

8 2 3 6

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question