Array of pixel mapped to spherical coordinates

Godot Version

Godot 4.2.2


I want to create an array of pixels mapped to spherical coordinates. I know the location of every pixel in 3D space, and I know how to calculate its spherical coordinates, so I want a simple way to flood-fill them.

The easiest solution I could think of would be to create a 2D array, like this: array[θ][φ] = Vector2(x, y), where (θ, φ) are spherical coordinates and (x, y) are pixel coordinates. Then I could just find a pixel where I want to start and spread from it iterating on (θ, φ).

The thing is, of course, that (θ, φ) are not integers, so they are not good for array indexes. I know I can sort them in their 2D array and then use it to do the chore, but maybe there’s a better solution?

Ok, so I realized that I can just use pixel coordinates as they are because the UV map I use is just an unwrapped sphere. Sometimes simplest solutions are the best.