1
\$\begingroup\$

There is an fantastic answer by DMGregory here where he explains how to calculate and generate the vertices of an UV Sphere: OpenGL calculate UV sphere vertices

Based on his code, how can we change the "altitude" of each individual vertex?

To create something like this:

enter image description here

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Hint: the secret is already in that answer. Look at the radius parameter. That determines the "altitude" from the center of the sphere. Vary that, and you get mountains and valleys. Can you show us how you've tried to vary the radius in your code so far? \$\endgroup\$
    – DMGregory
    Commented May 28, 2020 at 23:15

1 Answer 1

1
\$\begingroup\$

As DMGregory said, I just had to vary the radius variable.

// You simply have to multiply radius by any kind of random value
// I'm using perlin noise in this example
positions[v] = vec3(
                  c * cos(theta),
                  sin(phi),
                  c * sin(theta)
               ) * radius * noiseValue(latitude, longitude)
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .