Photobucket

related link

Tuesday, January 29, 2008

RUNNING WATER

by Ted Boardman

You’ll often hear it said that you need 3ds max to create running water effects with Particle Systems and it can’t be done in VIZ. Well, true enough that VIZ doesn’t have Particle Systems, but that’s only one type of running water and the method I’ll cover in this months column is valid in any version of both max and VIZ.

The process is quite simple once you have the speed and scale of the animated map for the water worked out. There may be some formula that could be devised to figure the size of the maps and the motion necessary to produce the desired results, but I have found that just doing a few test renders for both the map and the final water material is the best method. Because the Noise map used is a Procedural map it has no real-world “size” and the dimensions of the surface Noise is mapped to and the size of the water surface the material is applied to a little experimentation is necessary.


This won’t be a step-by-step tutorial this month, but I’ll walk you through the process I used to Model the landscape and to set up the material for both the landscape and the water and will encourage you to use my example to create a scene of your own.



Figure 1 shows a still image from an animation of water running through a ravine on a sloping landscape.


The Landscape

The first thing to look at is the landscape itself. The modeling is done with the same method I covered in last month’s column. A Gradient Ramp map is used in the Displacement slot of one part of landscape material.

The whole material is a Blend material so that a Falloff mask can be used to reveal dirt on the sides of the ravine and grass on the flat surfaces of the landscape. This is the same method used for the snowy mountain with some adjustments for color and bump mapping. See Figure 2 for the Gradient Ramp displacement map on the left, the result of that map in the center, and the structure of the material in the Navigator on the right.



Figure 2: Gradient Ramp Displacement map settings and the Landscape material hierarchy in the Navigator.


The color and bump patterns of the landscape material are simply combinations of Smoke, Noise, and Speckle maps to provide a variety of shades and textures to enhance the randomness of natural materials. Be sure to open the viz file and experiment with the materials to get the look you want in your scenes and to see the settings in the Displacement mapping that will help optimize the landscape mesh.

The Water

What this column will focus more attention on is the water material itself. It’s really made up of two processes. One mesh and material are used to generate the animated maps that create the illusion of movement for the water in the ravine.

In the right-hand Top viewport of my Flowing_water_viz4. max file, I have created a Plane primitive object off to the left of the landscape. I then applied a material called Water map that contains a Noise map in the Self-illumination slot. See Figure 3 for the Noise settings and the resulting map.




Figure 3: Noise map settings for the Self-illumination slot of the Water map material that is applied to a flat plane.


TIP: you can view a large version of any map by toggling the Show End Result button in the Material Editor, then double-clicking on the Sample Window to show an enlarged window.

The Noise map is used in the Self-illumination slot because we want to generate a black and white animation to use as a map in the water material and do not want to have to adjust the lighting in the scene for this object. A black and white map causes the white areas to be fully self-illuminated and the black areas to have no self-illumination to render correctly with no variations caused by the scene lighting.

This new material is applied to the flat plane. In a Top viewport, zoom in so that an area of the flat plane fills the viewport. Right-clicking the viewport label and checking the Show Safe Frame option will ensure that what you see in the viewport is the area that will be rendered.

Now you can animate the flat plane moving past the viewport by turning on the Animate button, going to the last frame in the Time Slider, and moving the plane. This will cause the pattern to move as you render.

There is some trial and error required to get the size of the pattern and the movement of the plane to match the water flow that you want in your scene. I haven’t devised a reliable set of rules that states, “if you do X, you will always get Y” as a result. The overall size of the actual water surface object in the landscape, the amount of ripple you want, and the apparent speed of the current are all variables that come into play. I recommend you test with a short 15 frame example with only the flat plane and the water surface object visible until you get the speed the way you want, then render the whole sequence to be more efficient.

In the example file for this column I rendered the full 100 frames from the left-hand Top viewport (there are two Top viewports). I chose to the render images as individual PNG files at 24-bit color with Alpha channel. You could render as an AVI or MOV file as well, but you will get better results using Alpha channel when possible, especially for bump maps and masks. PNG files are highly compressed and load fairly quickly. The name of the rendered file was water.png and because it is 100 frames the individual files are actually named water0000.png through water0100.png.

Again, the Water surface material is a Blend material with a mask to vary the color and shininess for a more random look. Figure 4 shows the Navigator so you can see where the PNG files were used; as Bump and Mask maps.



Figure 4: The Water surface material is a Blend material that uses the rendered sequence of images as Bump and Mask maps.


TIP: the animated map is actually an ifl file that shows in the map slot. This file is automatically generated when you use one map of a sequentially numbered set of maps and check the Sequence option in the dialog. The ifl file is simply an ascii text file that lists all the files in the sequence. Max and VIZ then call the correct image for each new frame in the final animation.

The transparency of the water is not created by setting the Opacity lower, but by using a Thin Wall Refraction map in the Refraction slot. This automatically makes the material fully transparent and distorts surfaces behind the water surface. I then set the Refraction Amount in the Maps rollout to around 90 to reduce the transparency somewhat and allow the colors in the Diffuse slot to show.

Another important factor for water is to set the Specular level fairly high and to use a Falloff map in the Glossiness slot. This Falloff map has its Mix Curve adjusted to give hard-edged Specular highlights on the water surface. See Figure 5 for the Falloff Mix Curve. The Mix Curve points can be adjusted for different viewing angles and lighting scenarios.



Figure 5: Falloff map with Mix Curve to cause hard-edged Specular highlights on the water surface when the Specular level is set high.


Try a few variations of the materials and lighting in this example scene then try making your own from scratch.

The modeling of the water surface can also be important to the end result. As with any models, you want to be as efficient as possible and still get the amount of detail you need. I recommend lofting the water surfaces for several reasons; you can adjust the density of the mesh (face count) easily with Path and Shape Steps and, more importantly, lofted objects will generate mapping coordinates that allow the material to follow the curvature of the loft path. This would be very important for water that flowed around corners or spilled from a fountain spigot.

TIP: if the water map appears to be flowing in the wrong direction of the lofted surface you can edit the loft path at sub-object Vertex level and change the First Vertex to the opposite end of the path or at Spline sub-object level with the Reverse button.

You can also change the map itself by adjusting the W angle rotation in the Coordinates rollout.

In this example the water surface is a short Line shape lofted along a longer Line path that has been moved into position in the ravine. If, by chance, the lofted surface is not showing when you loft your own example it may be because the Face Normals are pointing in the wrong direction. Changing the First Vertex position on the shape Line will flip the normals or you can apply a Normal modifier to the loft object.

In this case I used a Noise modifier on the lofted surface to give it some extra bumpiness than that achieved with the Bump maps alone.

Enhancing the Contrast

Our perception of both water and glass (very similar properties for both) are often enhanced by increasing the sharpness and contrast of the rendered scene. I personally like contrasty images anyway so it works well for me.

One step you can try for overall sharpness is to change the filter that is used during rendering. In Figure 6 you can see that I have changed the filter from the default Area filter to a Catmull-Rom filter that gives sharper edges of dark and light areas. Another option would be to try the Mitchel-Netravali filter.



Figure 6: Changing the filter in the Render dialog from Area to Catmull-Rom can enhance the apparent contrast of water or glass.


While the filter affects the image when rendered another option that is seldom used is the Contrast adjustment on the lights themselves. In the Modify panel, Advanced Effects rollout, (see Figure 7) for a light you can adjust the Contrast setting to create radical changes in the rendered image. It may be helpful to light the water with a light that Excludes all other objects if you don’t want to increase the overall contrast in the scene.



Figure 7: Each light has a Contrast setting in the Advanced Effects rollout that can dramatically affect the lighting.


While you’re in the Advanced Effects rollout, try adjusting the Soften Diffuse Edge setting for scenes that have curved shaded surfaces. This setting will harden or soften the edge at the transition of lit to shaded areas and can be used to adjust the Specular highlights of glossy surfaces.

TIP: Use RAM Player to compare two images side by side when making adjustments to important materials and lighting setups.

Summary
Water is one of the most dynamic and difficult surfaces to render. This column gives you a possible starting point from which to experiment in your own scenes. Keep in mind that the position and quality of the lighting can make or break the appearance of materials like water and glass so always adjust each as you fine-tune your renderings.

Make sure that you take the time to look closely at water and glass in the real world in all lighting conditions so you can visualize what you must to in max and viz to achieve a certain look. You might even think about how an oil painter might approach the look and attack the problem from that perspective first.

In any case, good luck and have fun.

Ted

No comments: