2017-08-27

Making the water for the lake


In this episode, I will show you how I made the water for the lake. This was a tricky one to make, so it will be a long and a bit technical one, so hold on to your helmets!

Click on read more to start the nerd rage...


Ok, so the freshly carved out lake needs some water right? In the real world, you would wait for the rain to fill it up. In here sadly, this is not an option, so I have to make an illusion that there is water.

First, I made a plane that fully covered the hole. This will be the water surface. On this plane, I will apply a material that will mimic the water effect. But it’s very important, that you choose the right material. There are a lot to choose from, and of them there are ones that looks good, but not necessary behaves like I wanted to (and vice-versa).


My first attempt was to simply drag a material, from the built in ones. I didn’t hold any hopes that it will work perfectly, but I wanted to see something watery like.


As expected, I wasn’t amused. It doesn’t look anywhere near like in the movie. So again, I searched for a better alternative on Google. Luck was on my side once again and I think, I found best possible material that I can hoped for! It's very complex, has a lot of tuning possibilities, but there was one problem. It wasn't compatible for the Unreal Tournament Editor, just the Unreal Engine 4 Editor (where you can create entire games or cinematics, but not playable levels for Unreal Tournament). The launcher (where you start the editor) refused to download the material from the library. I had the latest UE4 Editor from previously, (cause when I started the project, I thought that in there you can make maps, but that wasn’t true) but apparently, my version of the UE4 Editor was too new, and because of that, it also refuse to download. (The button was greyed out). So, I tried to download manually. I searched for hours for a server that has the shader, but nothing. I almost lost hope and thought that it was too good to be true, when suddenly I got an idea.

It might be incompatible with my version, but it must’ve compatible with an older version. I downloaded an older release of the UE4 Editor, and then finally it offered me to download the thing. But there was one more fear. It’s only compatible with the UE4 Editor, not the UT Editor. I thought, well it SHOULD be compatible, heck it’s almost the same (right?). I opened the UE4 Editor, made a test scene just to make sure it works, and fortunately it does worked. Ok, now the big move. I copied the material’s folder into the UT Editor file structure, opened the latest Cove scene and… no errors, (yet) then I saw it was recognized in the Content folder, (that was also a good sign) then I crossed fingers, prayed to the old gods and the new, while I applied the material to the plane and… SUCCESS! No error, no crash, everything worked perfectly! (That is rare in this field).


All right! That’s more like it! Still, not looking perfect, but that's ok. It's already waaay better than the built in one. Luckily there are tuning parameters to tweak it, so you can modify the look, untill you get what you want. (That is always a good thing).

Now, when I thought everything got into place, I faced a serious problem. This issue caused me a lot of headache. The water from above looked as I wanted, but when I got under it and looked up, this horrid scenery happened.


Nothing… the water disappeared. Since the material is very complex, I couldn’t hope to understand why it happened, but I tried to look up on forums and search for people who used this same water material and faced the same problem, and wanted to make it two-sided. Things didn’t look too good for me. Later, I found an answer to that question and I wasn’t happy...

(BTW, this is the complexity I’m talking about)


“The material needs to be set to two-sided as well, not the lighting or the mesh. This will not work with the translucent water material though since that has a custom depth buffer on it. The lake and the ocean material ones will work OK with the two-sided method.”

Yes, I used the translucent water, because the other two were crap for this particular scene. Only this could work, nothing else. I tried to modify the parameters blindly, hoping for something good will happen, but it just made things worst. I thought, somewhere in the material’s very core or peculiarity of the technic hinders me to make it refractive from below. So, no hope to solve this.

But! I got thinking again and what I came up was, I copied the water plane, flip it 180° and moved under the first plane. So there were two water surfaces. After some playing with random parameters, somehow I made it work, but it was glitchy. There was a terrible tearing effect on the water shader and the refraction was just partially visible, only in a small area around the player or camera. This glitch haunted me for quite a long time. But it was at least something.


So, I had a reflecting and kinda refracting water surface. Great! But, as you can see, from below there is nothing that gives the impression, that I’m underwater (aside it’s refracting the world above). To achieve that feel, I used a Post-Process Volume. Basically what it does is, it makes a region (cube), and when you enter this region it activates the post-process effects that you applied to it. (Like tint, color correction, blur, depth of field, motion blur, bloom etc.) I positioned precisely below the water surface, so it’s only active when I’m under the water. I added color tint, to make a blueish tone, color fringe, (to shift the red green blue color channels from each other, like a prism) a little bloom, (or glow) to smooth things out, lens flare, depth of field, (the far things are blurred) vignette (the corners are darker) and motion blur. When I finished, it looked something like this:


Much better. Also, placed a Physics Volume where the Post-Process Volume was, and set it up as a water volume, so the character behaves like if it would be underwater (floating, and gets slower).

I wasn’t that impressed with the reflections though. Yes, it looked very nice, but in default it uses a premade texture for the reflection thus, not reflecting the real world. There is a visual effects thingy called Sphere Reflection Capture that solves this problem. Drag it above the water, set the radius of reflection to cover the whole scene, and the lake is now reflecting everything properly.

Before Sphere Reflection Capture 

 
After Sphere Reflection Capture 

After this, I moved on to work on the other aspects of the map, but recently I was so annoyed by this glitch in the water, that I had to figure out something. I played with the parameters again, and found out some parameters that affects the glitchy area, but not make it disappear. So it must have something wrong in the material somewhere. I remembered, that I modified the material and put a “two-sided sign” operator and a "lerp" to somehow blend the two faces together while the sign was the alpha channel (I don’t know what was I thinking, just tried whatever came to my mind). Maybe that worked, or I modified some parameter, or both, I really don’t know. But, even if it was glitchy, there was some refraction. Also, I didn't need that second water surface anymore.

I started to play with the operators again, and tried the simplest and most obvious change. I took the “two-sided sign” operator and connected to the refraction channel. Clearly this was too simple, and childish and dumb to think it would work, but apparently it worked! The glitch was gone, and everything worked finally as I wanted to. Huzzah! (I made the impossible less than 5 minutes, without understanding a thing)!

Original layout 

Modified, but glitchy layout 

Modified, fixed layout

After a bit of celebration, I modified the Post-Process Volume and made the Post-Process effects less prominent. I confess, I made them to be over the top intentionally earlier, to somewhat hide the glitch (cause I didn’t hoped that I will get rid of it, so tried to hide the ugly truth and my utter failure). So now it looks like this:


So far so good. It looks decent, (for now) but I have to say that, there is a high chance that I will modify it in the future. Most likely, when I will do the last finishing touches.

I also made the lake floor shallower (it’s not final also, but still better than that crater). Sadly, this negates a very cool effect from the water shader. As the water gets deeper and deeper, it’s also gradually gets more opaque as well. Giving the impression of very deep water. Because the floor is now shallow, I can’t really use this cool feature anymore, but maybe later I try to add a little bit without messing up the look.

I think that will be enough for today and sorry if I made your head hurt, (mine was too, when I had to come up with these crazy ideas, that somehow eventually worked out and let me progress further. Maybe this is a sign, not to give up and maybe it means also, that there is a slight possibility that this level idea, may actually will be a thing in the near future).

All right, thanks for reading! See you on the next one!

No comments:

Post a Comment