Issue with Surface TranslucencyVolume and backfaces

Hi,

I’m using a Translucent material, with Surface TranslucencyVolume as the Lighting Mode. This is for an Ocean shader.

However, since there are waves, parts of the surface are obscured by itself, when the camera is low enough. When that happens, random backfaces get rendered a much darker color. I made a blocky mesh to make this more visible. First pic is a normal opaque material to show the shape, second pic is with the translucencyvolume mode enabled.

Is there a way to avoid these artifacts?

Bump? I’d like to have an answer to this!

Hey joelr,

I have created a blocky texture inside of Maya and imported it into UE4. I then changed the blend mode to translucent and turned the lighting mode to Translucency Volume.

A couple questions and trouble shoots for this.

1.) Is this a plane or a cube that you used
2.) What OSX and Graphics card are you using?
3) What Modeling program did you use
4.) Send me a screenshot of what your material looks like.
5.) See if you can recreate this in another project.

Troubleshoot:

1.) Make sure you have clean geometry
2.) Make sure you don’t have any unnecessary export settings turned on.
3.) Unwrap your geometry.

Thanks,
Logan

Thanks Logan,

  1. This is a plane, subdivided maybe 50 times on both directions to give a grid. I then selected strips a couple squares wide and pushed them up and down to give the simplest approximation of a wave, and exhibit the bug.
  2. Win 7, GeForce GT750M, made in Blender
  3. Screenshot attached
  4. Yes, I can recreate the issue in a separate project, using a newly made mesh.

The bug is much more apparent if you check “Two Sided” in the Material properties, but that’s not required.

I have the same settings for export as I normally do for FBX, never had an issue with those. I am confident the topology is clean.

So,

What you are experiencing is a normals issue inside of blender.

The steps to fix this are as follows,

1.) Open Edit Mode inside of Blender
2.) Go to Mesh, right beside the edit mode button.
3.) Click on the normals option
4.) Then click recalculate outside.
5.) Re export from blender, just like you did before, and try it again.

Try this and let me know if it worked,

Logan

Hey Logan,

That did not solve the issue. I attached the offending FBX, just rename the .txt to .fbx.

Just apply the above material to it, then spin around it in the editor.

Ilink text

Hey joelr,

So I took your model into a 3D modeling software and made sure all of your normals were facing the right way and your topology was clean, etc. I then imported your model into UE4 and applied the shader mentioned above. I was able to recreate the bug you are experiencing on your model.

I then took a plane and modeled it to as close as I could to your model in Maya and repeated the applying of the above material. My model is clean and does not have the artifacting that I see in yours.

One thing that I did notice was your wave was triangulated upon importing it into Maya.

If you export from Maya to or other modeling programs like 3DS Max and you have smoothing groups selected or smooth in the .fbx options then UE4 tessellates the mesh in a triangular fashion.

What I’ve concluded is that the issue you are having is somewhere inside of your geometry. This may be cause by vertices not welding together and after the light map back you have light being cast through that opening.

I would suggest going back to your original mode and reducing the polygons you have. Right now with the triangulation it has over 22,000 Polygons. Even for deformation and normal map purposes this is a lot.

Start with something like 50 polygons or so just having say four or five divisions across the mesh vertically and horizontally, Then, import that into a new project and put the same material on it.

I will also attach a screenshot of your mesh in engine and my mesh in engine.

Thanks,

Logan

Thanks a lot Logan, I’ll fiddle with Blender until I find what’s wrong with it. If I do find the issue, I’ll post back.

Yep, the shading was Smooth, and it gets fixed if I use Flat.

Is there any way to visualize normals in the editor? And do you have any guess as to why smooth shading would produce these artifacts? I’m not sure to get why Unreal tessellating smooth groups would lead to this.

The reason I’m asking is because I originally encountered the bug on a flat grid mesh that gets displaced in the material, to produce waves. On that mesh the Flat shading does not change anything since it’s already flat I guess. But the normals are definitely smooth once computed (i.e. they are computed to be half-way between face normals).

Something about Surface TranslucencyVolume does not like smooth normals.

Hey joelr,

I know that the engine tries to calculate the smoothing of geometry inside of UE4. When that happens, your mesh is tessellated to try and compensate for what UE4 believes to be beveled.

There are a few ways around this.

1.) Create a normal map
2.) Use smoothing groups instead of smooth, if Blender has this feature.
3.) Don’t smooth :slight_smile:

As far as I am aware UE4 does not have a way to view normals. I willl do some research into this and get back to you.

Thanks,
Logan

Is this tessellation done on the mesh at import time? Because I do not use D3D11 tessellation in the material if that’s what we are talking about.

  1. I displace the vertices at runtime in material using Gerstner wave algorithms. I also compute normals. I tried lerping these normals with normals from a map, but that does not fix it.

  2. I don’t Blender supports smoothing groups the way 3DSMAX and probably Maya does. Seen a couple forums posts about that.

  3. In the mesh used for the waves, I do not use any Blender smooth, but a smoothing effects gets applied by Gerstner’s algorithm at runtime. Is this ok?

Hey joelr,

In order to truly understand you methodology with that formula I will need a screenshot of your material and how you are implementing Gerstner’s algorithms. I know that if you don’t set the algorithm up exactly correct then it WILL break your models. Also I have a link to a guy who has already done the math and set the project up in UE4’s node based system.
You can download his project through GitHub. I know the way he is implementing it, it will never be used inside of an engine. I will also link you to our wiki page where a much more cost efficient way implementing waves and translucency has been used.

Link to Gerstner

Link to our wiki

Hope this helps,
Logan

Thanks for the links Logan, I downloaded the Ocean Project. My material code is strictly equivalent AFAICS. And if I simplify their material (to remove detail maps, SSR, that kind of stuff) and just keep the Gerstner basis, I can reproduce the issue in there as well. Lots of visible triangles seen through the waves. They use the same type of translucency (Volume).

I’ll look at the other material. For gameplay reasons though, directional moving waves would be best. I am also in the process of implementing Tessendorf which gives a non-directional, very fluid kind of ocean, as if you just shook it really hard, like during a storm. But it’s not as good at giving the illusion of wind in a given direction, and I would definitely tone it way down near shores in favor of Gerstner. Blending both would probably be ideal, but costly.

So, after looking at Ocean Project in more detail, it seems they use a workaround based on the Custom Depth buffer, to get rid of the artifacts. So they are basically rendering the surface of the ocean twice, with one of the surfaces writing to Custom Depth and not to the main pass.

Then the opacity of the main surface is set to 0 whenever its depth relative to the cam exceeds the depth in the Custom Depth buffer, essentially hiding the far triangles.

Since this means the whole displacement computation with Gerstner is run twice, this is a very costly workaround. I believe there should be a better fix in the renderer.

Alright this is the first answer that made any sense whatsoever.
Since a few versions ago you no-longer need a double mesh to get the custom depth pass working.

This makes it possible to just feed a multiply of 0/1 based on the depth into the current shader (stencils and all)

Still trying to work out how to make custom stencil work with this as well, but it’s a solid start. finally.