This sample was written by a member of the site, Jan Vytlačil. You can write your own tutorials as well, learn how under the “Tutorials” tab.
Description: This post contains source code of two new components. First component provide function of dynamic sky with adjustable daytime and dynamic procedurally generated clouds. Second component adds very simple rain particle effect.
Basic part of the sky is a sphere model. Color gradients which are mapped onto the sphere are saved in one 64×64 texture. More about this method form J. A. Abad can be foun at http://www.geocities.com/ngdash/whitepapers/skydomecolor.html.
Clouds are compound of several transparent layers. Transparency of these layers is given by a Perlin noise texture. Way of generation is assumed from Riemer’s 2d Perlin noise tutorial. Layer colors depend on a color of the highest layer which is dependent on daytime. Colors of the other layers are computed by a simple shadowing method. The method make darker those pixels which are shaded by a layer above. Method output is a RGBA texture for each layer.
Link: http://cid-f101b99b3d4bc3a0.skydrive.live.com/self.aspx/.Public/dynamic_sky.zip
Here is how to control the sample application:
1-4 select one of a four predefined components settings
F1-F12 set number of cloud layers
T shift daytime
O increase overcast
P decrease overcast

« XNA Game Engine Tutorial #12 – Introduction to HLSL and Improved Terrain Updated JigLibX Builds »

Awesome games site, good work
I tried to solve the Material.Cs problem creating 2 SetEffect(), SetTexture() in the Material class. And giving all Effects and Textures an exclusive string Name, it runs, but cant see cloulds neither sun. Only stars can be seen in the night hours…
someone tried to adapt this tutorial to the newest engine version??
Ok, I solved it. I forgot to call SetTexturetoEffect when assigning texture to materials.
but its a forced inconsistent method because if I load a no-named effect or material, it could crash when looking for it by name…
I had to reverse the lightdir vector before assigning to the Terrain2 object to cast shadows correctly. I don’t know why, but it works…
This theme is very relevant and interesting to many people.