It's free to join Gamasutra!|Have a question? Want to know who runs this site? Here you go.|Targeting the game development market with your product or service? Get info on advertising here.||For altering your contact information or changing email subscription preferences.
Registered members can log in here.Back to the home page.

Search articles, jobs, buyers guide, and more.

By Niniane Wang
[Author's Bio]

Gamasutra
January 14, 2004

Introduction

Performance

Formation and Dissipation

Printer Friendly Version
   

This review originally appeared in the January 2004 issue of Game Developer magazine

Change Login/Pwd
Post A Job
Post A Project
Post Resume
Post An Event
Post A Contractor
Post A Product
Write An Article
Get In Art Gallery
Submit News

 


 


[Submit Letter]

[View All...]
  



Upcoming Events:
IGDA Leadership Forum
Burlingame, United States
11.12.09

GameSoundCon
San Francisco, United States
11.13.09

Southwest Gaming Expo
Dallas, United States
11.20.09

Workshop on Network and Systems Support for Games (NetGames 2009)
Paris, France
11.23.09

EVA 09 - Exposicion de Videojuegos Argentina
Buenos Aires, Argentina
12.04.09

[Submit Event]
[View All...]

 


[Enter Forums...]

Note: Discussion forums for Gamasutra are hosted by the IGDA, which is free to join.
 

 

 


Features

Let There be Clouds!
Fast, Realistic Cloud-Rendering in Microsoft Flight Simulator 2004:
A Century of Flight

Formation and Dissipation

The clouds look more realistic when they can form and dissipate. We control the evolution of a cloud by adjusting the transparency level of sprites.

We multiply a transparency factor into the alpha value for each sprite vertex based on its position within the cloud. When a cloud is beginning to form, we render only the sprites whose center is within half of the cloud radius from the cloud center, and we render them with a high transparency level that we decrease over time. After these sprites have reached a threshold opacity, we begin to render sprites whose center is more than half of the cloud radius from the cloud center. Cloud dissipation is simulated by reversing the process (see Listing 1).


vertex is the (x, y, z) with respect to cloud center.
cloud_radius is the radius of the cloud bounding box.
alpha_at_edges controls how much to fade out the edges;
 this increases from 0 to 255 over time.
alpha_of_cloud controls the transparency of the entire cloud;
 this starts out at 255.
time_delta is the time that passed since the last frame.

float alpha;
if (fade_out_to_edges)
{
  float radial_magnitude = cloud_radius -
    vector_magnitude (vertex);

  radial_magnitude = max (0, radial_magnitude);

  alpha = (alpha_of_cloud - radial_magnitude * alpha_at_edges /
    cloud_radius) / 255.0f;
}

alpha = min(1.0f, max(0.0f, alpha));

if (alpha_at_edges < 255)
  alpha_at_edges += 255 * time_delta / time_to_fade_cloud_edges;
else
  alpha_of_cloud -= 255 * time_delta / time_to_fade_cloud_core;

Listing 1. Calculating the alpha value of a vertex when forming and dissipating the cloud.

Limitations and Extensions

Our system is well suited for creating voluminous clouds but less suited for flat clouds. Of the four basic cloud types - cumulus, stratus, cumulonimbus, and cirrus - our system easily handles the first three. However, cirrus clouds are so flat as to be almost two-dimensional, and it would require a large number of small sprites to model them using our approach, which would cause a performance hit. Instead, we represent cirrus clouds with flat textured rectangles.

Because sprites within each cloud are sorted back-to-front to the camera, moving the camera can occasionally result in popping as sprites switch positions in the draw order. This effect is more noticeable at dawn and dusk, when directional shading plays a greater role, but has not been jarring enough in our experience to necessitate a solution such as caching the previous sort order and crossfading.

As mentioned previously, our shading model does not include cloud shadows, self-shadowing, or the halo effect when the cloud is between the sun and the camera. One potential solution is to precalculate the lit and shadowed regions of the cloud for a set of sun angles. We can load this information at run time and interpolate based on sun angle.

The ring of impostors can create visual anomalies. The clouds in the impostor do not move relative to each other, which means the parallax looks wrong. Also, distant objects must be drawn either in front of or behind all the clouds in the impostor, instead of in front of some and behind others. We could mitigate this by adding additional rings of impostors, but that increases video memory usage.

In the future, we would like to implement some of our techniques into vertex shaders, as more of our user base upgrades to video cards that support hardware vertex shaders. Our system can be extended to other gaseous phenomena, such as fog, smoke, and fire. Fog is a natural candidate, since it is essentially a stratus layer placed close to the ground. The problem is getting rid of the hard lines where sprites intersect the ground polygons. We can either split the sprites along the ground or multiply by a one-dimensional alpha texture based on the altitude.

Research into fluid simulation has produced realistic animations of clouds as they change shape. This creates more extensive morphing than our system of formation and dissipation, but it frequently does not yield enough control to the artists over the final result. It can be difficult to tweak the humidity and other parameters just right to have a cloud form over three minutes, or to ensure the cloud that forms looks a particular way.

A solution more appropriate for games and movies may be one that combines our artistic modeling with fluid simulation by using simple rules for cloud morphing in combination with our system of textured particles. For example, we could use weather variables such as humidity, airflow, and temperature to rotate, translate, and adjust transparency on individual sprites within the cloud to change the overall shape of the cloud. It would give the impression that wisps are being blown by the wind, or that clouds are condensing or breaking into several pieces.


For More Information

Download a video describing the cloud-rendering system at
www.gdmag.com.
Mark Harris and Anselmo Lastra. "Real-Time Cloud Rendering."
 Computer Graphics Forum, vol. 20, issue 3. Blackwell, 2001.
Gernaut Schaufler. "Dynamically Generated Imposters." Modeling
 Virtual Worlds - Distributed Graphics
, ed. D. W. Fellner, MVD
 Workshop, 1995.



Acknowledgements

Thanks to Adrian Woods and John Smith, two very talented artists from Microsoft, without whom this work would not have been possible.


______________________________________________________

[back to] Introduction


join | contact us | advertise | write | my profile
news | features | companies | jobs | resumes | education | product guide | projects | store



Copyright © 2003 CMP Media LLC

privacy policy
| terms of service