The home of Stainless
  • Starflight
    • Hacking
    • Remake
    • Archive
  • XNA
    • Planet generation >
      • Planets 1 Mercators
      • Planets 2 Bump maps
      • Planet 3 Ice worlds
      • Planets 4 Gas giants
      • Planets 5 Airless rocks
      • Planets 6 Molten planets
      • Planets 7 Bug fixes and improvements
      • Planets 8 Clouds
      • Planets 9 Atmospheric Scattering
      • Planets 10 Rings and stars
    • Remakes >
      • Ultima 4
      • World map
    • Facial Animation >
      • Importing the expressions
      • Loading the base mesh
      • Using the mesh
    • Spherical Harmonics >
      • GPU based
    • Sand
    • Alpha blending bug
  • Contracting
    • Clients
  • Blog
  • New Games
    • Onslaught
    • Towers
    • Two Towers
    • FOFT
    • Convoy
    • IL2 Mod tool >
      • Gallery
    • Downloads
  • Magic System
    • Genetic Magic
  • DevMaster Competition
  • Reality
    • Chapter 1
    • Chapter 2
    • Chapter 3
    • Chapter 4
    • Chapter 5
    • Part Two
    • Chapter 6

A hybrid approach for procedural planets

Part three - Ice worlds
Picture
The universe is not populated entirely with Earth like planets, so we had better add some more planet types.

The first one I want to consider is the ice planet. We can generate an ice planet completly trivially from our existing code by just supplying a new palette texture. Using something like this will give a reasonable result.

Picture
Create a new class IcePlanet and just copy the code from WaterPlanet. Change the palette texture and you should get something like this.
Picture
Not bad for two minutes work, but we can do better.

Take a copy of the water shader and save it as Ice.fx and add it to the project. Don't forget to change the shader in IcePlanet.cs as well.

In my mind, ice planets will be smoother than water planets. No running water to erode the land. So we need to smooth out the terrain a little.

In the pixel shader we have a power function. Simply change the 0.5 in that to a smaller value, I used 0.25, and the terrain will smooth out.

 
PS_OUT PS_ColorMap(VS_OUT input)
{
	PS_OUT output = (PS_OUT)0;
	
	float amp=2;
	float freq=1;
	float y=0;
	for (int i=0; i<4; i++)
	{
	   freq = (2*pow(2,i))-1;
	   amp=pow(0.25,i);
	   y+=snoise(input.WP*freq)*amp;
	}
	
	y=(y+1)/2;
	y = 1.0f-pow(y, xOvercast)*2.0f;
 
	output.Color =  float4(y.x,y.x,y.x,1);
	
	return output;
}
Don't you just love shaders?
Picture
Well now you have two types of planet to play with. 
In the next page we will add a really important one. Gas giants.
part3.zip
File Size: 39 kb
File Type: zip
Download File

Powered by Create your own unique website with customizable templates.