Username
Password
Auto-login
Show my name in the online users list
Not a member?
Please register.
Forgot your password?
(1) October 2008
(2) May 2008
(1) January 2008
(1) November 2007
(2) September 2007
(7) August 2007
(2) July 2007
(1) June 2007
(3) May 2007
(4) April 2007
(8) March 2007
(9) February 2007
Volume displacement method for clouds using fluids
Posted: Aug 02, 2007 - 07:22 PM
Category: tutorials
I was recently asked how to convert a cloud displacement map to bring it into Maya fluids. Displacement is rather incomplete for clouds.. even if one assumes the cloud bottom is flat, however it can look good in some cases. Also infrared images of clouds from space tend to nicely code for cloud height, because it gets cooler with altitude. Here is one of many sites that have nice infrared cloud images:

National Geophysical Data Center

2D Fluid Displacement method (shown above)

There are a few methods where one can import the data into a fully 3D fluid grid, although it is also possible to directly apply the 2d displacement image to a 2d fluid and volumetrically render it. The "useAsHeightField" toggle on a 2d fluid will interpret its opacity as displacement. It renders as a flat bottomed volume with continuous density between the bottom and the top or surface of displacement. The "pond" feature uses this toggle, but uses a surface render method. For clouds it is better to use a volume render method with self shadowing.

In the examples I've attached I've mapped a texture to the opacity and edited the opacity graph to get good shape on the clouds. If one instead wishes to use a map then instead make the opacityInput = density, and make the density grid static. Make the opacity graph the default linear 0-1 ramp to start with. Set the fluid resolution to your displacement map resolution, then use the fluid paint tool import function to load the image into the fluid density grid. One can then adjust the the opacityInputBias and transparency to get the best effect. Also the edgeDropoff can be used to soften the bottoms of the clouds( although it also softens all 6 boundaries of the fluids container ). The fluid's size "z" value will determine the maximum displacment while the opacity determines the displacement relative to the range. The transparency attribute determines how opaque the clouds are.

Here is a 2D fluid heightfield that uses noise on the opacity to create the clouds:
displacementClouds.jpg
displacementClouds.ma (find this at the bottom)
Here is the same scene but with the addition of a second fluid for the atmosphere. (Create a 3D fluid and then select the SkyFog preset in the attribute editor)
displacementCloudsWithSkyFog.jpg
displacementCloudsWithSkyFog.ma (find this at the bottom)
This next file uses a hurricane infra-red image loaded into a 2D fluid initial state for a more realistic cloud shape:
hurricaneCloseup.jpg
displacementHurricane.mb, fluid initial state (you'll find these at the bottom)
Here is the same file but with some added procedural noise to give it more detail than there is in the fluid grid:
hurricaneDetailNoise.jpg
hurricaneDetailNoise.mb (you'll find this at the bottom)
To animate the fluid One can simple set the initial state to a rotating velocity and simulate. (make sure to set density buoyancy to zero) You could paint velocity with the paint fluids tool or use a vortex field. Another method that can be very controllable is to keyframe the rotation of a drag field that has a magnitude around 10 and inherit motion set to 1.0.
displacementHurricane.jpg
hurricaneDynamic.mb (you'll find this at the bottom)
3D Fluid Method

If you want to instead map a displacement to a 3d fluid grid there are a variety of possible methods, although they are generally harder to implement than the 2D method above and will require more memory.

First off you should create a fluid that has the resolution set to cloud image resolution in x and z and the y resolution set based on the relative height of the cloud layer. Adjust the fluid size to the desired cloud bank size, but make sure the size value is always proportional to the resolution. Thus for a resolution of 1000, 500, 10 one might have a size of 20.0, 10.0, 0.2. The total memory used will be proportional to xres*yres*zres.

Here are a couple of methods for initializing the fluid density values from the displacement image:

1. In the paint fluids tool Import the cloud image as density starting from the bottom fluid slice or layer(click on the light blue dial next to the fluid to set the layer.. the view initially rotates the layer unless on hit the lock icon). As one moves upward
import the same (displacement style) texture, but threshold it so that only the peak intensities remain. The import remaps the image based on the min/max values in the paint attributes block, so I think one could use this to do the desired thresholding by making the min negative.

2. Write a script that loops over the image pixels, getting the color using either bonus tools iffPixelCmd or perhaps using colorAtPoint on a file texture with the image. For each pixel do setFluidAttr on the voxels where intensity from the image would be considered height, so for a given pixel if the intensity was one, one would set the density of all the fluid voxels in that column. If the intensity was 0.5 one would only set the bottom half of the voxels in that column, etc..

3. Apply the texture as a displacement to a surface. Convert this displacement to polys. Then emit from this mesh into the fluid over a few frames moving the mesh downward during the emission until it is totally below the fluid.

4. Write a standalone program that converts the image to a fluids cache using the technique in #2 above.

A Dynamic Cloud texture

In some cases you may wish to texture a cloud layer on a planet yet dynamically animate it as a fluid. In this case one can simply apply a 2D fluid texture as a transparency and color map on a cloud layer shader, and initializes it with the paint fluids tool. This is useful when you need to have clouds wrap around curvature of the earth.
In order to post any comments, you must be logged in!
  Posted by aaronv2  on  11 Mar, 2008  at  04:55 PM

im having trouble mapping an infra red image to the initial state also… i was wondering if a third request will encourage you to elaborate a bit on the process of mapping the image to the fluid.  ive tried a few ways but cant get rid of the perlin noise.

  Posted by n8skow  on  15 Jan, 2008  at  09:15 AM

these methods produce decent looking clouds, but how would a person go about implementing them if they wanted them to look good from below instead of from above?

  Posted by untelon  on  03 Jan, 2008  at  04:59 PM

Hmmm. I am not sure my previous post made it so here I go again. First of all, thanks very much for the tutorials Duncan, they are always great and offer new possibilities.

I was wondering if you could go into a little bit more details on the approach of mapping the image to the 2d container. I assume that you plugged the image as a projected file texture into the opacity input bias. Is this correct? I am asking because when I try it I only get a decent image when rendering from above. As soon as I go down toward a side or eye level view it breaks down, sometimes not rendering any fluid density at all. This does not occur when I do it with your sample scene.

Thanks much Duncan.

jim

  Posted by Martin Waters  on  09 Nov, 2007  at  07:07 PM

Hi there,

Great tutorials. Thanks very much.

I am currently trying to create a simliar effect using a 2d fluid mapped onto a sphere to create a globe. I need to get up close to the clouds and would like to have a volumetric effect. The problem is, the 2d fluid acts as the texture placement for the phong shader. How do I place, or is there a work around so that the fluid wraps around the globe correctly. I am using a cloud mp designed to be applied to a sphere as the density.

Any help or ideas you can provide would be greatly appreciated.

Regards

Martin Waters

  Posted by skylab82  on  24 Oct, 2007  at  11:25 AM

I don’t have understand where is load the file hurricane infra-red..
Can help me??

 
Page 1 of 1 pages