# Thread: Show function on the surface of a sphere

1. Originally Posted by Brokenmind
If the creation of the texture is computationally efficient, then this is no problem.
The sim runs ~40 fps without computing map textures. With texture computations it's ~2 fps, which is on the slow side. For this application I don't need speed. The texture image is 1080x540 pixels.

Do you have a basic texture on which you only highlight certain areas?
No - every pixel in the image is recomputed every time. The resulting texture is applied to both the flat map and the sphere. 'Computing' a pixel means converting it from pixel to lat-lon to spherical coordinates, checking for satellite visibility, and coloring the pixel accordingly. This conversion is necessary for me to get a value for each pixel.

OP would not have to do this conversion. He already has values at various lat lons. What he could do is plot his points in a rectangular viewport (with lat-lon dimensions) and triangulate those points to get polygons. GL will automatically do the color interpolation for him, assuming he applies colors to each point. He would then need to overlay his map of the continents. The hardest part here is the triangulation. If there aren't many points and they don't change location with time, he could do it by hand. Otherwise he's going to have to apply an algorithm such as Delaunay Triangulation.

2. Thank you two for your constructive discussion.

Originally Posted by Carmine
What he could do is plot his points in a rectangular viewport (with lat-lon dimensions) and triangulate those points to get polygons. GL will automatically do the color interpolation for him, assuming he applies colors to each point. He would then need to overlay his map of the continents. The hardest part here is the triangulation. If there aren't many points and they don't change location with time, he could do it by hand. Otherwise he's going to have to apply an algorithm such as Delaunay Triangulation.
In fact i have very few points. Worst case: On one side clusters of points and on the other side large gaps.

If i have understood you correctly i can create a triangulation, assign a color value on every vertex and OpenGL do the interpolation for me inside the triangle? I will look for a good tutorial to test this for a single triangle.

Because of the fact that i have only a few points on the sphere i don't want to triangulate only the points and let OpenGL do a linear interpolation inside the triangles. I want to use the information from my own interpolation. Would it be a good idea to use a good triangulation something like this, compute for every vertex the value with my own interpolation and then let OpenGL interpolate it. Or is this a bad idea?

An idea for the future would be to blend between functions (like i have a visualization for the temperature in 2013 and blend to the temperature in 2014).

3. If you have few points which are unevenly distributed and form a convex geometry around the center of the imaginary sphere, you could extrapolate the values to map a sphere and assign the color values resulting this calculation to a sphere.
Whether you use an icosahedron sphere or the gluSphere doesn't matter. I personally prefer the icosahedron sphere because of the even distribution of triangles (the gluSphere is very dense at the poles and very sparse at the equator), but it is much more complex to build up.

With the extrapolation, I mean something like this:

only that the points in the left image correspond to your data points and get colors assigned.

4. @ Brokenmind: Your idea seems very interesting to me. I think it is like subdivision? Could you do me a favor and make an test image with more clusters (distance between some points very small). I would like to see how this influence the result.

5. A test image like the above one? I'm afraid it's from Google But there's an image for everything: Here, for example. I do have selfwritten code for such a sphere, but no project to display it atm. You could test it yourself, just take the template from here.

The issue you face is assigning to the sphere points the colors from your "object consisting of the coordinates that have colors". How detailed you draw this sphere does not really matter, since you have a texture and only little light influence (in the yellow image, the lighting role is much stronger than with a texture). Shading also greatly reduces the amount of faces needed to display a smooth surface (see here).

By the way, this image illustrates what I mean by "projecting on the sphere", only not a vertical projection, but one to the center of the sphere.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•