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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Texture making its way into custom depth

I am trying to use custom depth with a translucent material to get a post process fog effect working under water. I need my water shader to draw to custom depth so the fog will affect the water plane as well. I can draw to custom depth just fine, I have 'Allow Custom Depth Writes' on in the material and have Custom Depth enabled in the rendering settings. However the depth that is drawn seems to also take values from a texture that is being used in the scene.

The underwater fog should make all of the screen blue but where I am drawing custom depth some values are being taken from a texture. I have no idea how this is happening, it seems almost like the custom depth buffer is overrunning graphics memory to a location where there is texture data. I am using UE 4.14 with the deferred renderer with a NVidia Geforce GTX 980.

Product Version: UE 4.14
customdepthbug.png (333.6 kB)
more ▼

asked Dec 20 '16 at 07:36 PM in Bug Reports

avatar image

413 15 15 31

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey QSBen,

Thank you for all of the help and cooperation. This issue is very specific and was a pain to lock down to an exact cause. I was able to narrow down the issue and file a report here: https://issues.unrealengine.com/issue/UE-40252

It seems that the new "Allow Custom Depth Writes" feature has some kinks to work out so you may need to do the old work around. This involves having a duplicate mesh with "render in main pass" unchecked occupying the same space. It needs to have an opaque material and render to custom depth as well.

That should create the custom depth info you need from the water mesh. There are a few specific conditions that need to be met in order for this issue to occur so be sure to check out the report for more info!

Thanks again!


more ▼

answered Jan 05 '17 at 08:17 PM

avatar image QSBen Jan 05 '17 at 08:27 PM

Thanks a lot for looking into this for me Ed. I know this is probably an edge case for this feature but I'm glad you were able to find the source of the issue.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi QSBen,

I'm going to need a bit more information. Could you provide screenshots of your material graphs. I have a few questions about your setup as well.

  • Are you using a post process material (AKA Blendable) to create the fog like effect?

  • How is the fog effect having difficulty with the water shader? Could you elaborate on how/why you are using custom depth.

I put together my own underwater effect to get an idea of what you are doing. First I made the post process material:

alt text

Then I applied it to an unbound post process volume. Once the fog looked like how I wanted I used a water plane "BP_OceanWater" from our "Water Plane Examples" assets and put it above some boxes.

alt text

This is where I get a bit confused as to where the Translucent material utilizing Custom Depth comes into play. If I have your workflow all wrong could you please elaborate on how you are putting together this effect so that I may reproduce this issue on my end.


fogexample.jpg (84.2 kB)
example.jpg (96.6 kB)
more ▼

answered Dec 21 '16 at 05:24 PM

avatar image QSBen Dec 21 '16 at 06:04 PM

Sure thing Ed.

I am working with a scene that is both above and below water. The reason I felt the need to use custom depth is that when using scene depth the fog extends above the surface of the water even though my post process volume is not unbound. Using scene depth alone also incorrectly fogs things less that are close but out of the water as seen in this image scene depth only

Using custom depth allows me to get the depth of the water surface and fog only to that extent in the scene which solves both of the issues when using only scene depth as seen in this image

scene depth with custom depth

But to be honest the reason behind why I'm using custom depth is less important than the fact that I'm getting artifacts in my custom depth buffer, regardless of what I plan on using it for. For your reference here is my post process material, used as a blendable in my post process volume.


avatar image Ed Burgess ♦♦ STAFF Dec 21 '16 at 10:31 PM

Thank you for clarifying your workflow. Asking how and why someone is doing something really reveals a lot. Mainly because you would be surprised the crazy odd ball methods users can come up with. I just needed some extra clarification.

Regarding the artifacts where you describe scene depth fogging things incorrectly that are outside the water. This is actually occurring because DOF is blurring the "silhouette" of the assets where the scene depth does not.

When using the scene depth as an alpha between scene color or a 3 vector (rgb) you will see a hard outline of things that would normally be blurred since the alpha has this hard outline (notice the colors are blurred).

I got around this by enabling a few things, I also fixed some minor artifacts with the water shader I was using. However, I never got anything as wild as what you showed in your first screenshot.

First to assist with the scene depth artifact I went into the Postprocess material and set the blendable location to "Before Translucency"

alt text

Here is a before and after example:

alt text

To further remove artifacts caused by objects in front of a translucent plane I had to uncheck "Separate Translucency" in the water shader settings so that DOF could influence it and the objects in front of it.

Let me know if this helps, If it doesn't could you narrow down what asset(s) are causing the artifact specifically. If it is related to a texture in a material I may need information on both the material and texture in question so that I may experience that artifact on my end.


temp.jpg (64.0 kB)
del1.jpg (77.4 kB)
avatar image QSBen Dec 21 '16 at 10:57 PM

Setting my material blendable location to 'before translucency' did indeed help with the sharp outlining issue. However scene depth itself has the other issue of fogging things out of the water more the further they are away even though they are viewed through the same amount of water. In this image both of the places the arrows indicate should be fogged about the same amount since they are viewed through the same amount of water. alt text

By using custom depth I can get the distance to the surface of the water (since I can't get regular scene depth from a translucent material). This allows me to get more accurate fogging underwater if not for the artifacts I am seeing.

The amount of artifacting I see changes depending on view direction which is confusing and interesting. It also isn't always the same texture that ends up in the custom depth buffer. However the textures I've seen seem to all come from Instanced Foliage Actor in my scene. The only actor set to draw to the custom depth buffer in my scene is the water plane.

avatar image Ed Burgess ♦♦ STAFF Dec 22 '16 at 03:37 PM

Would it be possible to provide a video of the artifacts. I've tried a few different scenarios in my test and haven't been able to reproduce anything that looks similar.

If that isn't possible could you answer these questions.

  • Do you see the artifacts when looking through the water and only then or do they appear in other situations.

  • If so, could you provide a screenshot of your water shader's material graph.


avatar image QSBen Jan 02 '17 at 05:49 PM

Here's a video of the bug. As you can see when I look around the artifacts appear to change which texture they are coming from as well as, when looking up and down, the data from a single texture appears to change somewhat.

In addition, to prove that this is a bug with custom depth and not something else, here is a render of the custom depth buffer showing the artifacts.


These artifacts appear both above and below water. In game they are only visible below water since that's where the fog post process is applied, but when rendering the custom depth buffer it is visible both above and below. Here's my water material graph.

Water Mat Graph

avatar image Ed Burgess ♦♦ STAFF Jan 04 '17 at 07:45 PM

Hey QSBen,

I appreciate all of the info, I haven't been able to get those strange flashing artifacts.

I assume that this issue is only occurring in that map, for example if you create a default map and visualize your custom depth buffer you wont see any artifacts.

Could you either provide a small sample project that reproduces the issue OR narrow down what assets in the map seem to be causing this to happen.

Unfortunately, I haven't seen this error before and am unaware of what may be the cause. Getting a project that reproduces the issue would make it much easier to figure out what is going on as I feel that it is related to your content.


avatar image QSBen Jan 04 '17 at 11:24 PM

I've stripped down the project to the bare essentials and I'm still seeing the issue although I'm starting to thing the bug may be independent of the engine. Either way Here's the project.

To see the issue you simply need to open the map, fly the camera under the water and look around.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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