Problems creating a realistic underwater fog effect

I’m in the process of creating a bottom-of-the-sea scene with your typical landscape, fish, and wave caustics to show as an effects demo. Currently I’m trying to make the fog look good, but I just can’t cut it! What I’m trying to do is make the fog brighter near the surface of the water, and darker near the bottom as more light gets filtered out.

Here’s my attempts, and how they failed:

Idea 1: Make a regular cube with a 100% transparent material, connect a volumetric fog shader to it, and connect the fog color value to a vertical gradient.
Failure 1: The color is flat & static, can’t be connected to anything

Idea 2: Divide the fog into several layers, so the layers near the surface are given a lighter color and the layers near the bottom are given a darker color. This would produce a somewhat stepped effect, but better than no gradient at all.
failure 2: XSI/mr only sees the first fog. The camera renders the first fog it sees, but not the fogs behind the first fog.

Idea 3: Make a single dark fog, and illuminate it from above with a gradually weakening volumic light.
Failure 3: To create a realistic sunlight-effect the light has to be very far away. Take this, and combine it with the fact that the volumic effect doesn’t use the lights attenuation settings at all (just the exponent), and you just can’t tune the effect to a perceptible gradient. If there was a MAX-style directional light it would be easy, but there isn’t…

I think I had a fourth idea as well, but you get the point. I’d welcome any ideas on how to do something like this.

I also noticed that volumetric effects do not work with implicit objects like the manual says, you need a polygon or NURBS object with a transparent surface. Another thing is that the volumic light shadows do not seem to take into account the transparency of an object, even a 100% transparent object stops the volumic light unless you make it invisible to shadow rays. I find myself somewhat dissapointed here, can someone show me how XSI can do all these, but I just need to check a button somewhere?

Yes you do need to “just check a button somewhere” =)
What you are looking for is an effect like this? Correct?

To get that to work, you need to check the “Transparent” box in the volume lights Volumic Property editor.

As for your underwater fog. What you really need are the good old softimage lume shaders. But since those seem to be long gone, I suggest using two Volume shaders loaded into the render passes Volume shader stack, not attached to objects in the scene. Stack a Volume layered fog shader on top of a volume fog shader and play around with the layered fog settings till you get the proper “fade out” at the bottom.

Hope this helps.

Ed
XSI Videos, Tutorials, Tools, Shaders…
Available at:http://www.EdHarriss.comhttp://www.EdHarriss.com

Thanks for the tips Ed!

The volumic shader trick is just what I need, although the volumic light should be visible both before and after the transparent surface. I guess that’s what the other checkbox does, before the Transparent box (don’t have XSI here right now).

As for the fog, well, I wanted to avoid global fog cause I want to cut the fog at the water surface, but I guess I’ll just have to fake seeing the sky through the water surf somehow if I want that fog.

I tried using both a global and a local layered fog, but it always seems to be infinitely thin (like a 2D grid/plane), and didn’t have a type of distance cue effect for some odd reason =/. It was always so dense it just cut the objects off sharply, or then was just about nonexistant, probably cause it was always infinitely thin. Whatever I tried, I couldn’t get it to behave right. I’ll try again, but I’m not very convinced…

Thanks anyway! I’ll post results here.

Is there something I’m not understanding here?

Is there any way to make the layered fog into a true 3D layered fog, instead of a bad foglike effect on a 2D plane that suddenly flops from top to bottom or vice versa when the camera moves from one side of the fog layer to the other? Why is there even a volumic shader to it, when you could just as well create a 2D Grid that would do the same effect much better?

It’s not helping either that the manual uses a whole 8 words to describe the layered fog shader, and even that description seems be wrong…

furthermore, is there any way to move a shader up and down the global volume shader stack without deleting and recreating shaders?

I got fairly good results(pic 1) when I put a layered fog under a regular fog, and then constrained the layered fog base height to the camera height - 1, but even like this it doesn’t work for the background, only on objects, and the illusion is ruined when the 2D plane of the fog cuts some object(pic 2).

Pic 1:

Pic 2:

You are not missing anything. With out the lume shaders layering the Volume fog and the Layered fog on top of each other is the only way. And then you have to keep the camera from crossing the “top” or “bottom” of the layered fog.

To have the layered fog look like it is affecting the background put a giant inverted sphere around the scene. That might help.

I don’t think that there is anyway to move shaders up and down in the stack without deleting them. It’s a good idea to save a preset so deleting a shader only takes a few seconds to add back in the right spot.

Good luck.

Ed
XSI Videos, Tutorials, Tools, Shaders…
Available at:http://www.EdHarriss.comhttp://www.EdHarriss.com