Ejemplo n.º 1
0
    /// <summary>
    /// Generate the planets texture based on given values
    /// </summary>
    public void CreatePlanetTexture()
    {
        //Loop through all pixels setting pixel to planet color based on noise function
        for (int i = 0; i < planetTexture.width; i++)
        {
            for (int j = 0; j < planetTexture.height; j++)
            {
                float4 pos = new float4((i - planetTexture.width / 2) / planetSettings.planetFeatureSize, (j - planetTexture.height / 2) / planetSettings.planetFeatureSize, 0, planetSettings.planetSeed);
                if (PlanetNoise.GetStateFromPos(pos))
                {
                    planetTexture.SetPixel(i, j, planetSettings.terrainColor);
                }
                else
                {
                    planetTexture.SetPixel(i, j, planetSettings.waterColor);
                }
                //planetTexture.SetPixel(i, j, new Color(val, val, val));
            }
        }
        //Set middle points to black to provide reference to start location
        planetTexture.SetPixel(planetTexture.width / 2 - 1, planetTexture.height / 2, new Color(0, 0, 0, 1));
        planetTexture.SetPixel(planetTexture.width / 2 + 1, planetTexture.height / 2, new Color(0, 0, 0, 1));

        planetTexture.SetPixel(planetTexture.width / 2, planetTexture.height / 2, new Color(0, 0, 0, 1));

        planetTexture.SetPixel(planetTexture.width / 2, planetTexture.height / 2 - 1, new Color(0, 0, 0, 1));
        planetTexture.SetPixel(planetTexture.width / 2, planetTexture.height / 2 + 1, new Color(0, 0, 0, 1));

        //Apply changes to pixels
        planetTexture.Apply();
    }
Ejemplo n.º 2
0
 public void Execute()
 {
     for (int j = -1; j <= height; j++)
     {
         for (int i = -1; i <= width; i++)
         {
             float4 tilePos = new float4((position.x + i) / featureSize, (position.y + j) / featureSize, 0, seed);
             tileStates.Add(PlanetNoise.GetStateFromPos(tilePos));
         }
     }
 }