0

I need to generate textures for 3D planets (spheres) in Java using a perlin noise program I wrote. But the catch is that the left and right need to be the same, also up and down so you can put the texture on a sphere.

I can't put the perlin noise source here because it's too long but it's mostly based on http://devmag.org.za/2009/04/25/perlin-noise/

Clement Bellot
  • 841
  • 1
  • 7
  • 19

2 Answers2

1

The way perlin noise works is that it interpolates between values of a grid.

For this purpose, the simplex noise would be more appropriate (else the noise density won't be the same at the poles, as you can't pave a sphere correctly with squares).

You will need to divide your sphere in simplexes (triangles in your case), and then for each triangle angle (only once per point), randomize a value.

Then you can calculate the texture at each point of a triangle by interpolating with the simplex noise method.

Clement Bellot
  • 841
  • 1
  • 7
  • 19
1

If your noise function scales to 4D, then you can feed x,y,z,w with the coordinates of two 2D circles. The resulting image will tile optimally on both x and y axis.

For example(very sloppy but for clarity) :

float textureSize = 1024.0f;

    for(float i = 0.0f; i < textureSize; i += 1.0f){

      for(float j = 0.0f; j < textureSize; j += 1.0f){

        nx = cos((i / textureSize) * 2.0f * PI);
        ny = cos((j / textureSize) * 2.0f * PI);
        nz = sin((i / textureSize) * 2.0f * PI);
        nw = sin((j / textureSize) * 2.0f * PI);

        looped_noise = noise_4D( nx, ny, nz, nw, octaves, persistence, lacunarity, blah...);
        noise_buffer[((int)i * (int)textureSize) + (int)j] = looped_noise;

      }
    }

If your function does not easily scale to 4D, try with any simplex noise implementation out there.