|
Feedback
Posted: Aug 03, 2007
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:
Image Description: 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)
Image Description: 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:
Image Description: 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:
Image Description: 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.
Image Description: 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. | |||||