Water Material. How long will all that bad? And what to do?

No it wont be released on the marketplace, it contains engine modifications, so most likely just released to my github for others to download. Maybe pull request to Epic if its good enough.

The UE4 reflections are pretty bad for water… I can confirm that.

this. please :slight_smile:

And where can I talk about it with the developers of the engine?
I am very interested in their official position.

I already requested better water rendering. Epic knows it’s a real problem. Ideally, people will have access to the Reflection environment in the material itself to allow for an easy placement of a realtime reflection. Unfortunately, nobody ever has access to the shadow, indirect lighting, or reflection environments, it’s all baked in by lightmass. You only have simple controls over it. There was a fluid surface actor being developed on the forums, which would help with wave displacement, but the project seemed to have been dropped. The community ocean shader is the best thing going.

Some people have implemented their own realtime reflections, but as far as everyone is concerned, it’s very expensive to render. Forget Half Life 2, there were realtime reflections in Super Mario Sunshine back in 2001 on the Gamecube! But that was at a screen resolution of 640x480, in 30 frames per second, and everything else was extremely simple: the water wasn’t even lit, and nothing had specular highlights. So of course they can get away with a realtime reflection! But doing that now would require an immense amount of power that few people possess. I have a GTX 960 (EVGA FTW), typical for a gamer nowadays, and I struggle getting stuff to run smoothly at 720p. And it’s not from the post process overhead because I zeroed it out! It’s just very difficult to make realtime reflections work. And this is coming from a guy who loved making water for fun in UDK.

The water I’m making in UE4 is just an experiment with the technical aspects of a rendering a nice, clear, Caribbean-type water similar to Assassin’s Creed. Caribbean water does not have a lot of foam because the sea is very shallow and choppy waves are highly unusual (do some research). The optimized version of this shader uses 180 instructions. An unlit version that uses basic unlit emissive rendering (no reflections) costs just 96 instructions. If you want nice, clean water that runs well and looks good, this is how to do it. Unless you’re specifically making a dirty lake or still stream where the water is dark underneath and the surface is calm, reflections don’t even show up in the final product at all. Until we get better reflections for water, you just gotta use what we have.

As for performance…
CryENGINE uses deferred rendering and physically based materials and everything is very fast.
Yes, there is used a few simple scene for reflection but still everything is rendered in a few milliseconds!
I believe that in the epic programmers not worse.
We just need to be paid to this problem enough attention.
In my project realistic water is very important. And I would like to continue using UE4…

Plane reflections are expensive but they should’t be over the top expensive. Performance cost should be always less than the normal rendering passes. It should be possible to reuse all the shadow maps. Reflection pass could skip most of the post process effects. It’s also should use smaller render target size which basically linearly scale the performance. So even without any LOD tricks it should only be about 30-50% of the normal frame time.

I heard something about the d-buffer being limited to only a certain number of channels for measuring properties like color, opacity, subsurface, material, depth, and normals. Not sure if that has anything to do with it.

ANYWAYS, I made significant progress on my Caribbean water shader: 98 instructions, unlit as far as UE4’s lightmass is concerned, no reflections whatsoever. No refractions either (just because :P). It uses just two normal maps at 512x512 each to calculate the final normals. The specular model was done by just adding two phong highlights on top of each other, a strong sharp one, and a dim soft one to show up at distant waves. Aside from the depth coloring and opacity tricks, everything looks good because the landscape under the water actually has depth-based coloring and caustics. The caustics is just a single 1k texture distorted by a 256x256 normal map. The caustics actually use Mip biasing to appear blurrier the deeper they dive into the water.

It’s not perfect, but it does look good.



It looks nice, cartoony. This shader did not meet my requirements or Most of the requirements. Our goal rializm.
Anvil engine
e2d4a726d91433720cb026fd9c11903f934cf179.jpeg

That is actually the Assassin’s Creed reference and document I used for my water. You can’t get perfect reflections on water in UE4.

By this I want to draw the attention of the developers on this problem.

Look at real world reference:

No reflection necessary.

No reflections because there is no object.

I need something like that

Then you need a mirror no water

water comes in many tones and varieties, it heavily depends on your ‘real world reference’

interlaken-lake.jpg

just because you’re making water in a cartoony style, allowing you to get away without reflections, doesn’t mean it’s something everyone else can do.
you can add all extra effects in the form of foam, caustics, vertex waves and whatnot. but without reflections it will never be ‘quite there’

I did this small scene around two years ago and was more than happy with the water, this before we had SSR on Translucency (think I did this in 4.1 or 4.2) and I think it looks okay. The whole scene is pretty out of date now and I only had old UE3 meshes to work with so it’s far from real PBR (the scene that is), and I didn’t bother with Scene Capture reflections.

Thing I did in case it helps anyone:

  • Flow Map generated in Houdini, which also masks in the foam at the edges and around the waterfall. You’d be amazed how much difference something like this makes.
  • Added a Chromatic Aberration effect that works in tandem with the default engine refraction.
  • Depth based-fog when you’re above the water plane
  • Distance-based fog when underwater (post process volume with blendable, not really any different to a fog volume in essence, just doesn’t have any scattering).
  • Caustics vertex-paint material
  • Tessellation waves
  • Subsurface colours (Didn’t really understand it at the time, so doesn’t work so well)
  • Bubbles / particles to help ‘sell’ the volume a little more
  • Rotating camera-facing godrays
  • Second plane underneath for distortion of the world above the plane.

That’s all I can remember. Took a long time to do in respect to the rest of the scene, but the entire scene was a weeks work.

To be honest I think the only things missing are planar reflections, but again that can be relatively easily done in the Shader with a scene capture, so it’s not like it’s “missing” - it’s just not convenient at the moment. I saw a post recently from James Golding (no idea what thread though), stating that Epic want to add Planar Reflections, but they’re not efficient enough as they stand so they’re looking at other things. It’s not high priority though so don’t expect to see them soon. 's implementation looks nice though and I’m sure that when it’s in a good state he’ll put it on GitHub, he usually does :slight_smile:

That water surface look really odd. It’s transparency is somehow very ghostly. Something is missing. What kind if fresnel effect you use for refraction and transparency? General rule is that when incidence angle goes near horizontal reflection value goes up which also mean that material turns more opaque. From wikipedia: “The Fresnel equations describe what fraction of the light is reflected and what fraction is refracted” Refraction and reflection always sum to one.
Another important detail when calculating under water fog(transmittance) is that you can’t use position behind transparency but you need to use position where your distorted refraction ray is. But you need to fall back to non distorted ray when distortion would go above the water.

Is that thing dynamic? Any tutorials or info you can share on it with us?

I agree about the reflections… SSR is simply not suitable for water in actual gameplay especially when the player has full control over the camera since half of the things that a water surface should be reflecting are out of screen, no matter what the camera angle is you would either be missing sky reflections or some object reflection.

I have spend a lot of time researching water shaders (probably more than most UE4 devs) and for me it comes down to two problems that are deeply rooted in UE4: lack of decent reflections and proper anti-aliasing since temporal AA totally destroys water surface details, FXAA is better for this but not without its issues.

The following is the best I have achieved so far (although there is definitely a lot of room for improvement, I’m not saying this the best currently possible) which is nowhere close to the CryEngine or AC black flag screens shown above but all things considered it’s not too bad :stuck_out_tongue:

http://www.mediafire.com/convkey/c49b/zr2avynw0q4n28vzg.jpg?size_id=5 http://www.mediafire.com/convkey/347a/pvjqn6786w8368dzg.jpg?size_id=5

I have made an attempt of planar reflections using scene capture 2d actor but as we all know if you use that you can kiss performance good-bye :stuck_out_tongue:


I suppose a few years from now when we all have better GPUs this technique will be acceptable but as for right now I don’t think anyone wants to spend nearly half of their framerate just for reflections.

@ I would love to take a look at what you have so far :stuck_out_tongue: have you managed to optimize it at all?

Very interesting! And could you tell us more about this?
How geometrically correct perspective?