dhpoware logo
navbar
home products source demos contact us
navbar navbar
box top left corner box top right corner
 
 
XNA 4.0 Earth Demo.

This Windows XNA application demonstrates how various shader effects can be combined to render the planet Earth. Some of the effects used in this application include: per pixel lighting, tangent space normal mapping, using compressed normal map textures stored in DXT5nm format, controlling specular reflectivity using a specular map, and multi-texturing.

A single directional light shining down the world negative Z axis simulates sunlight. Use the left mouse button to orbit the camera around the Earth. As the camera orbits the Earth notice the smooth transitions between day and night. To enhance the night effect a separate night texture map is used that displays the city lights.

The normal map for the Earth is stored in the DXT5nm DDS file format. The uncompressed normal map is about 8 MB in size. After compression it is about 2 MB in size. The DXT5nm format uses a DXT5 block to represent 3D normals. The X component of the normal is stored in the alpha channel and the Y component is stored in the green channel. The Z component of the normal is reconstructed in the pixel shader using an orthogonal projection: Z = sqrt(1 - X * X - Y * Y).

The starfield in the background is just a bunch of points of varying sizes and colors randomly distributed on the surface of a sphere. The naive approach is to assign each point a random spherical coordinate. This approach will result in the points bunching around the poles of the sphere. We use the Sphere Point Picking algorithms described on the Wolfram MathWorld website.

The day, night, specular, and bump map textures of the Earth are based on the originals from JHT's Planetary Pixel Emporium. The bump map was imported into CrazyBump and converted into an uncompressed normal map texture. The uncompressed normal map texture was then converted to the compressed DXT5nm DDS file format using NVIDIA Texture Tools 2 nvcompress command line utility. The cloud texture is based on the original from the NASA Blue Marble collection.

Note:
1. This demo requires shader model 2.0 or higher support.
2. This demo is provided in source form only. No pre built binaries are supplied.

screenshot

zip file Download source, assets, and XNA Game Studio 4.0 solution files.

Change History:

30 September 2011.
StarfieldComponent.cs: Initial version. This XNA 4.0 Component is used to render the stars as camera-aligned billboard textures. For further details please see the XNA 4.0 Billboarding 4 Demo.

15 January 2011.
Initial release of demo for XNA Game Studio 4.0. The previous XNA Game Studio 3.0 version of the demo is no longer supported and is now only available upon request.

The starfield has been removed in this version of the demo. The starfield implementation relied on the PointList primitive type. The PointList primitive type is no longer supported in XNA 4.0. A future version of this demo will reimplement the starfield using camera aligned billboard textures.

 
box bottom left corner content box box bottom right corner
logo logo