My question is how to get xyz(uvw) coordinates from a texture that is mapped on a sphere.

I try to explain my setup as good I can:
I have a videoIn(cv) node and a contour(cv) node which gives me the the XY coordinates from the brightest pixels from the video. This XY coordinates I use to spawn particles(dx11). It works fine, but now I have to map the videoIn texture on a sphere(PhongDirectional) and I need to transform the contour pixel data from XY space on the sphere coordinates. So that I can spawn the particles on the sphere.

I think about two options:

There is a vvvv node (or combination) that can give me the uv coordinates after I mapped the texture on a sphere.

I have to write kind of a shader to calculate the mapping of my pixel on a sphere by hand.

I’m new too vvvv and hope that I explained it right. Any ideas how to solve this thing?

I gave it a try. It’s a little bit hacky, but could work for your use case: uv_to_3d_question.zip (8.2 KB)

You will recognize that you will get often more than one point, depending on the Epsilon and the resolution of the sphere.

Maybe someone else here in the forum has a more straightforward approach. Will also think about another solution with a uniqe conversion. But maybe this helps already.

think about it as a worldmap: if you have XY on the map, you have also latitude and longitude, since you happen to know how the sphere is projected on the flat surface - how the flat texture is wrapped on the sphere and since you probably know the radius of the sphere, you have the exact mathematical solution.

so for your case of a sphere you can use the Cartesian and 2 map nodes, voilà

In case you will only need a solution for a sphere (as you’ve wrote…), Woeis approach is the way to go.

I’ve thought one step further / complicated by searching for a solution with any mesh UV to XYZ conversion. Still wondering what could be a cleaner way to do so.

The sketch from woei is perfect, never thought that it would be that easy, just one node. The only thing I don’t understand is the MapRange of x and y?

I couldn’t transform the sketch form timpernagel to my needs, don’t know exactly why. Maybe because of my very basic beginner knowledge in vvvv. Anyway, thanks a lot for the help!

the xy mapping is needed, since the random points are between -1|-1 … 1|1 (in the renderer) this texture covers the whole sphere. spherical coordinates however, range between -90 and 90 for latitude and -180 to 180 for longitude (and in vvvv it’s converted to cycles where 360° == 1 cycle).
so x becomes longitude becomes Yaw from the range of -1x … 1x to 1 … 0 (=360°)
and y becomes latitude becomes Pitch from the range of -1y … 1y to 0.75 … 0.25 (=180°)