Best way to get random spherical distribution using geometry nodes?

I want to create a spherical distribution of points. At the moment I use this node setup.

But this creates noticeable higher densities on diagonals

It should be more uniform like this

What's a better method for creating a spherical distribution?

• your question isn't clear. What do you mean with better? you could use e.g. a noise texture, but it depends, what exactly you wanna achieve. So please tell us how it should look like and maybe add an image of your target. And your node tree isn't complete as well, so pls provide a node tree which you used so we see at least what you did and how we can improve it. thx Sep 17 at 13:04
• Plug that node into a set position node. But I've updated Sep 17 at 14:29

Spawn twice as many points as you need (I do an exact sphere radius vs cube radius ratio but you're not guaranteed to get enough points regardless how many spare points you generated due to the nature of randomness) inside a cube, and delete the excess that wasn't inside the sphere:

360-430 ms for 10 million points

Proper Maths Approach

Taken from here: Karthik Karanth: Generating Random Points in a Sphere

function getPoint() {
var u = Math.random();
var v = Math.random();
var theta = u * 2.0 * Math.PI;
var phi = Math.acos(2.0 * v - 1.0);
var r = Math.cbrt(Math.random());
var sinTheta = Math.sin(theta);
var cosTheta = Math.cos(theta);
var sinPhi = Math.sin(phi);
var cosPhi = Math.cos(phi);
var x = r * sinPhi * cosTheta;
var y = r * sinPhi * sinTheta;
var z = r * cosPhi;
return {x: x, y: y, z: z};
}



300-340 ms for 10 million points

• First result presents same issues as my method. Second one is great! Thank you blender wizard. Sep 17 at 15:24
• @TheJeran nocebo. First solution is absolutely correct, must be. It's simple to reason about: you start with a uniform distribution in 3D space and then cut out a sphere out of it. Sep 17 at 15:44

In this particular case, you find that the Random Value node is not as random as its name suggests....

If you want to solve this mathematically, use the wonderful answer from @Markus von Broady.

However, if you want to use fewer nodes, and stick to using Random Value, you could solve it as follows:

• Here I use many points created at the same position.
• I rotate them with random values between $$-\pi$$ and $$\pi$$, so that they are positioned in a circle.
• Then I rotate these positions again on a random axis so that the previously circularly positioned points form a sphere.
• Finally I scale the positions with a value between $$0$$ and $$1$$ with another Random Value node, but a different value for Seed (!)

You can also replace the first two operations with one, but it is important that at least one of your Random Value has a different seed value.

(Blender 3.6+)

• I like the random axis approach. Take the cubic root of the magnitude for an even distribution (otherwise points clump near the center) i.imgur.com/7ONZ3T6.png Sep 17 at 20:50
• @MarkusvonBroady I actually thought that was intentional, that it gets denser towards the center (at least that's how it is in the example image), but that's a brilliant idea! Sep 17 at 21:07
• @quellenform In my use case I would like it to be denser near the center. But I think having uniform distribution is a good property as well Sep 18 at 7:25

No way intended to compete with Markus' answer, which is proved, where this is not.

Following the Math Exchange answer here, though, with its commentary, and told that (Blender) Perlin Noise's distribution is Gaussian-like, this is another shot at it:

.. it's just interesting that there's no obvious visible bias? But I wouldn't trust it to do strict statistical sampling.

• This is an amazing answer. The OP wanted points inside a sphere, which you can see by him scaling the vector, but the same can be applied here, with cubic root applied for uniform distribution (to avoid clumping in middle) i.imgur.com/KsUb13b.png Playing with the setup, all kinds of amazing effects can be achieved, basically you can get an even but perlin distribution with local clumping if you get the settings just right Sep 17 at 21:13
• As for checking the solutions, could actually be done in geonodes or python, I'll give it a go tomorrow. It's hard to inspect the distribution visually in 3D. Sep 17 at 21:15
• @MarkusvonBroady I'd like to get at least some inkling of why 'Gaussiam-like, SD doesn't matter' works.. that's weird, to me. Graphing the distribution of Blender's noise would be a nice little question in its own right. P.S. Cycles must do this all the time.. random distribution over the hemisphere.. I wonder how it does it. Sep 18 at 6:05