views:

466

answers:

4
A: 

I am not a mathematician. I am willing to be corrected.
It looks like you are using standard triangles (sum of angles = 180 degrees). I assume you should be working with Spherical Trigonometry. For example: Right Spherical Triangles: Let a, b, c be the sides of a right spherical triangle with opposite angles A, B, C = 90 degrees, respectively, where each side is measured by the angle subtended at the center of the sphere. sin a = tan b cot B, sin a = sin A sin c, ... There you can find rules for Determining the Quadrant of a Calculated Part of a Right Spherical Triangle. Such as: A leg and the angle opposite it are always of the same quadrant. If the hypotenuse is less than 90 degrees, the legs are in the same quadrant...

gerard
Sorry, I don't get it—how does that help me with the texturing? Actually, in the long run, I need to texture non-spherical objects that “behave” like spheres when it comes to texturing.
Ferdinand Beyer
I might add the Wikipedia description as they do a better job of explaining. http://en.wikipedia.org/wiki/Spherical_trigonometry. Another example - http://mathworld.wolfram.com/SphericalTriangle.html. And finally http://demonstrations.wolfram.com/AVisualProofOfGirardsTheorem/ which shows the source code. I think it would be worth viewing.
gerard
This has nothing to do with 3d graphics.
Alan
+1  A: 

First off, you probably don't want to just map the spherical coordinates to a single rectangular texture that covers the sphere since the texel resolution becomes very non-uniform over the surface.

A better approach is to use an atlas. An "atlas" is a parameterization of the surface into multiple "charts", each of which is a connected region. For example, you could map the sphere onto roughly 6 charts that correspond to the sides of a cube, and each chart would preserve the shape of the portion of the sphere much better. You can google for multi-chart parameterization or something like that. DirectX has built in UVAtlas generation if you want to go that route. The issue of what to do at the seams between charts is simpler actually since triangles always sit within one chart, and is a different problem entirely.

That said, to deal with the seams in your case, you need to know which triangle edges of the (spherical) mesh intersect the boundaries (meridian or whatever). You will then have to break up the triangles incident on those edges into pieces that don't cross the boundary, and apply the texture coordinates properly.

Victor Liu
Thank you for your effort to introduce the atlas approach. Actually I wanted to keep things simple since I only need to visualize data and I am not developing a game or something similar. I realize now that I have to adjust the geometry in order to get rid of the seam, I'll upvote your answer for pointing that out.
Ferdinand Beyer
+3  A: 

The answer is very simple you need to map your texture coordinates over the edge. The implementation depends on your data set but here is a stab at the problem.

In computer graphics texture coordinates are stored on the faces and not on the vertices and your problem shows the reason. When you map a texture around a sphere, let us say in 10 steps you start with 0.0 then continue in 0.1 increments. If you go with texture coordinates along the prime meridian you get faces with the texture coordinate 0.9 and 0.0. The graphic hardware does what it is told and interpolates the texture between 0.0 and 0.9.

To solve your problem you need to map the texture from 0.9 to 1.0.

If you can, create the polygons that way or duplicate the offending vertices with other texture coordinates.

Sean Farrell
Duplicating some vertices seems the most practical solution so far—I will try that out. Thanks for the hint.
Ferdinand Beyer
A: 

Hi,

I am facing a problem more or less similar to this.The difference is I am trying to sphere map non spherical objects.I will describe my problem in detail.

I am writing an application which generates 3d models out of system fonts.I am using the gluTesselator for triangulation of my font contours. I have also implemented certain UV mapping techniques like simple Planar/Box mapping.I am in the process of implementing sphere mapping where I am stuck.

My problem is as follows: After the gluTesselator gives me the faces,I get the sphere mapping coordinates for every vertex using simple Cartesian to polar coordinate conversion. When I use these UV values and try to render this geometry I get undesirable artifacts at random places. After digging into this issue a little bit I found the reason to be that the faces in my geometry actually share vertices.This is the way the gluTesselator gives me the faces.Therefore my start and end vertex will end up having the same UV values which is improper.Also I am not aware as to which are supposed to be the pole vertices because my geometry could be of any shape based on the font and character chosen.

One solution could be to duplicate some vertices,but what I am not able to understand is which vertices to duplicate and what should be the change in UV for these vertices. Another solution could be to write my own tessellator which would tessellate the contours the way I want..This looks like quite a bit of work :(.

Can anyone please suggest a solution and give me a direction as to how I must approach this problem.

Thanks in Advance, Pravi

Pravi
Please post this as a separate question. Otherwise nobody will notice you (probably nobody but me since I asked the original question) and its hard to give you an answer!
Ferdinand Beyer