XNA Meeting Point
  • Home
  • English
    • FAQ
    • Site Architecture
    • Who we are
    • Contact Us
    • XNA Tutorials
    • XNA-inspired technology>
      • MonoGame Tutorials
    • Game Development
    • Math
    • Physics
    • Computer Science>
      • Programming
      • Data Transmission
      • Hardware
    • Useful Links
    • Ressources
    • Community Spotlight
    • Game Renders
    • News Blog
  • Français
    • FAQ
    • Plan du site
    • Qui sommes-nous ?
    • Contactez-nous
    • Tutoriaux XNA
    • Technos inspirées de XNA>
      • Tutoriaux MonoGame
    • Développement de jeux
    • Maths
    • Physique
    • Informatique générale>
      • Programmation
      • Transmission de données
      • Hardware (machine)
    • Liens utiles
    • Ressources
    • Community Spotlight
    • Captures d'écran
    • Nouveautés / Blog
  • Español
    • FAQ
    • Estructura del sitio
    • ¿Quiénes somos?
    • Contactarnos
    • Tutoriales XNA
    • Desarrollo de videojuegos
    • "Links" utiles
    • Recursos
    • Community Spotlight
    • Capturas de pantalla
    • Actualidad / Blog
  • Search
  • Tutorial Contests
    • XTC 2010
  • XN'net
    • English
    • Français
    • Español
  • YouTube
  • About me
    • School Projects>
      • Numerical Analysis (Python)
      • C Programming
      • Lisp Programming
      • Presentations
    • GCC Projects>
      • GCC Presentations
    • Pollen Hunt
  • RSS
    • XNA News!
    • Other Projects

A hybrid approach for procedural planets
Part III - Ice worlds

by Stainless
author's website
Photo
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.
Photo
Create a new class IcePlanet and just copy the code from WaterPlanet. Change the palette texture and you should get something like this.
Photo
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?
Photo
Well now you have two types of planet to play with. In the next page we will add a really important one. Gas giants. Grab an updated zip here.

Next part of the tutorial
Powered by Create your own unique website with customizable templates.