Translucent Material only receiving per-vertex lighting?

So, I’ve made a translucent water material, but for some reason, it only seems to receive vertex lighting. This looks extremely ugly with large areas of water, as you can imagine. This effect is, oddly, greatly diminished when the viewport is maximised, but is still noticeably not per-pixel lighting.

My material uses opacity and refraction, as well as fresnels and depth fades to get the appropriate effects. I have no idea what could be the problem here, and have changed almost all the settings on the material, with no change to the result. Could someone help me work out what’s going wrong here?

Hey Hoeloe -

Are you using Customized UV inputs in your water shader that references normal maps?

Thank You -

Eric Ketchum

My shader uses two world oriented textures, using the world aligned UVs node. It uses the normal map to displace the opacity and colour, and attached into the normal map. I’m not using any customised UV pins.

If it’s helpful, this is my material graph:

There are a few parameters, including a texture reference for a render target so I can apply screen space reflections (which are also being a problem, see my other question: Owner No See on Scene Capture Component - Rendering - Epic Developer Community Forums)

No, the issue is still there with or without the reflection component, last time I checked.

Hey Hoeloe -

So I have been working on this one and at least have it narrowed down to the Reflection component you have added in, so I am working on trying to figure out why that would be causing it. But, to confirm if you remove the math around the reflection component, does the water render correct (as expected).

Let me know -

Eric Ketchum

Hey Hoeloe -

Are you using LPV’s in the level?

Thank You

Eric Ketchum

I’m attempting to, I have them enabled, but they don’t seem to be generating correctly.

Hey Hoeloe -

I am looking into this issue and your scene component Owner no see issue. I think there might be some connection and possible a way to solve both issues. Is it possible for you to upload a sample project with those two functions setup as you have them in your level.

Let me know and thank you -

Eric Ketchum

I will set up a MWE and send it over as soon as I am able.

https://dl.dropboxusercontent.com/u/30847069/Volume_Water_Error_Demo.zip

That contains a minimal demo highlighting both issues. Reflections will not display properly unless in Play mode (not just Simulate). Note how the light causes clearly square illumination, and the reflections of the two pillars appear behind them as well as in front (because the scene capture 2D is capturing the reflections that were rendered on the last frame).

Hey Hoeloe -

Just giving you an update, we are still looking into why the lights are not rendering correctly on your water mesh.

Thank You

Eric Ketchum

Thanks for that update!

It might help to know (and will certainly help me to find out how to solve this) that I’ve discovered another interesting bug: The reflections don’t work in the standalone player. Or rather, the scene capture doesn’t, it just uses the default texture. I’m not sure why this might be, but one theory is that I’m using a dynamically created Canvas Render Target 2D (so that I can generate it automatically, rather than having to make a new asset for each section of water in the game) to render the reflections onto. I’m not sure why this would be a problem, or why it would only work in the editor. I haven’t tested using a normal Render Target yet (it’s late, and I will likely do so in the morning). I suspect these two issues may well be related, though.

Okay, I have ascertained that using a Render Target asset, rather than a dynamically generated Canvas Render Target 2D, does allow reflections to work in the standalone player. Now I just have to work out if there’s a way to create them dynamically at runtime…

Sadly, changing this didn’t fix the lighting bug.

Hey Hoeloe -

Okay thank you for your patience on this issue, but I finally have a definitive answer for you as to what is causing this vertex light. Lit Transparency in the engine is done with vertex lighting and what your water shader is presented is an extreme cause of this issue. Specifically your shader is using a Depth Fade and a Fresnel which are pixel based elements which are not transferable to the vertex based lighting on translucent objects. The vertex Square-ish lighting happens on all lit translucent objects it just normally is not pushed to such extremes.

Wish I could give you better news here,

Eric Ketchum

Ah. That is a huge shame. Is this being looked into for a fix in future versions, and is there anything I can do to lessen the effects?

Yes, I know that we are actively looking to improve translucent rendering with lighting, but it is a long term project. I talked with one of our technical artist about your shader to see if we could debug it and we did have a few things which could help out, but nothing will completely eliminate the issue. One, Don’t use a flat plane, the flatter it is the more you are going to notice the effect. Make sure that the plane or mesh that you are going to be applying it to is plenty tessellated before import and limit the tessellation and displacement and instead use the World Position Offset which is a Vertex Function and not a Pixel Function so will cause less noticeable lighting distortions. The hard part is the Depth Fade and Fresenls though which make your water so nice, but are pixel based and will cause the distortion.

One last thing which totally depends on your game and style but you can make your water unlit and plug your Base into Emissive and place the lights under the water (or increase the radius to touch the bottom of the water area). This produces a quite nice effect almost would you would expect in a cavern or underground water source.

Hopefully that helps -

Eric Ketchum

So, I’ve just realised something. The lighting I’m seeing is not per-vertex. I’ve discovered that the squares of light I see remain constant sized even when I scale the mesh down. It appears that it actually maps to about 1 square per 10 unreal units. This doesn’t sound like the vertex lighting you described in the solution.

It also still occurs when I use World Position Offset instead of tessellation, and even if I apply the material to a spherical mesh, rather than a flat one.

Hey Hoeloe -

I will look into this further, but your shader was given to one of our Technical Artists and my answer came directly from him.

Thank You

Eric Ketchum

Just adding the actual solution to this old post since I spent the better part of the day trying to figure it out and this was the only post that came up.

SOLVED

Check the lighting mode (under translucency) set to one of the vertex modes.
try setting it to surface volume or even forward shading