Creating a Water/Liquid Material
A project to create a better water/liquid material node.
First, a quick note. For many of the examples I will show, I'll be using a simple scene. The elements in the "base" scene will not change. The point of these elements is to make it easier to see some of the material aspects as I progress through this project. Here is the basic scene:
I do not submit that this is the best method. I am quite confident that there are many people who are far more experienced in using Blender (or other rendering apps) that could come up with a better and/or more streamlined material. I only present this as my progress in creating a better water/liquid node for my uses. Since I have gained so much from the online community, I felt I owed it to others to share my little experiment, on the off chance that it may be useful to anyone else. Plus, by explaining what I have done helps me to understand it all better. So there you go.
-----------------
Ok. Some time back, I wanted to create a water material in Blender. Specifically, I was going for a calm water effect. I began by trying to get the Ocean Modifier to work; however, that modifier is either not suited for calm water or I just have not really learned how to use it properly.
So, I worked out a way to create a calm water surface using texture nodes. As it turned out, the setup is very simple. You could even make it even more basic or more complicated by following this structure.
Having tackled that aspect (and feeling quite happy with myself about it), I then wanted a better water material. Sure, for many scenes, just using the Glass node will work very well.
I quickly found a problem, however. Let's say you want the water to be cloudy. You just set the Glass Roughness to your desired amount. Right?
Depending on your desired result, this may be way off. The issue is that the Glass Roughness causes a blur in the water refraction and the water reflection. While watching the pool guy add his chemicals to my the water one day, it occurred to me that this is not always what I would want. When he put in the chemicals, the water turned a bit cloudy, but the reflections on the water did not lose any clarity. I can think of many instances where this would be the case. Think water with something dissolved in it. Or milk. Or orange juice.
So, I split it up. One node for the water itself, a Refraction node, and one node for the reflection, a Glossy node. The result is this:
Nothing comes without a price, though. This setup takes significantly longer to render than just using a Glass node. So, you wouldn't want to do this if you only want clear water or you don't mind that both the water and the reflections are blurred the same amount.
Next, there is the issue of the color change that often occurs when you have water, or any liquid, that reaches a certain depth. This one was a real bear and I had to resort to a bit of research to figure it out. To be more accurate, someone else had figured it out and I found his tutorial.
The tutorial is brilliant and I highly recommend it: http://blenderdiplom.com/en/tutorials/419-tutorial-absorption-in-cycles.html His process is fantastic, is surprisingly simple (the math isn't the easiest to follow, but he does a nice job of simplifying it for you.
So, I incorporated his setup into my own and grouped it all together. This gives me my Water & Reflection Base node.
That give us this result:
Great. But (there is always one big but, isn't there?), the depth color isn't doing much to the light tubes, is it? In fact, you could up the Depth Strength to 1000, resulting in deep blue water, but the light emitters still show as pure white. Yes, you could change the Water Color to a blue, and that will change the light in the water. However, it will change the light's color, no matter the what water depth may be. That's not right either.
When I *informally* began this experiment, there was not an option for volumetrics in Cycles. There were probably other things I could have tried, like the Subsurface Scattering node. However, up to this point, I could render this using GPU. So, now we have a couple of nice volumetric effects, but we have to switch back to rendering on the CPU - until volumetrics are made to be GPU compatible, anyway.
So, I started building a grouped Volumetrics node. Here is the setup:
I cannot explain exactly how I came to this setup. It was a lot of trial and error, before I got it the way I wanted it. You may want something different. For example, I noticed that the color for the Volume Scatter results in a scattering color that is exactly inverted of whatever I put in. In other words, I put in a red color for Volume Scatter and I would get green water. I wanted the scatter color and the absorption color to be the same. I cannot tell you if that is realistic or not. It's just what I wanted. So, I take the same color input for both the Scatter and Absorption nodes, and just invert it for the Scatter node.
Ok. Adding that to our blue water example from above, we get this material:
Which results in this render:
So much better!! The light turns more blue as the water gets deeper. Exactly what I was going for. However, with the volumetrics added, do we need the Water Depth settings from before? Changing the Water Color to white and the Depth Strength to 0 gives this result:
The difference is very slight. Without the Depth settings, the blue is slightly less intense. So, no. You don't need both. However, I can imagine wanting to play with mixing three colors in one liquid (the base Water Color, the Depth Color and the Volumetric Color). However, in my initial tests, the Volumetric effects tend to over power the Depth effects. There *may* be a way to use both, but I am guessing that if you can do something using both settings, you can probably do it without the Depth settings and just the Volumetrics.
To test that out, as well as to put everything else together into one monster node (because why not?), here is an attempt at some murky, algae water. For the material, I grouped everything I have done so far - including the Material Output node.
Which results in this render:
And there you have it. Nasty water. As I said, this is just my little experiment. I may well have gone about it in the most difficult way possible. I certainly do not have the best solution, but it works for me - until I find or figure out a better way.
Suggestions for improvement are absolutely welcome. I am not used to sharing things like this, so bear with me while I figure out how I am going to share the blend file. Stay tuned.