Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zorodius

Generating texture coordinates along a sphere?

This topic is 5766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m using tessellation to dynamically create an approximation of a sphere. All is well, except I can''t figure out how to generate texture coordinates that will map a 2D texture onto the sphere. Given an (x, y, z) point, I want to be able to find out the (s, t) coordinates that should be used for that point. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Bump?

What I have so far is sort of a spherical coordinate conversion. It doesn''t look too far off, but it has problems with artifacts appearing near x=0.

What I''m doing right now goes something like this:

Given an x, y, and z
r = sqrt(x² + y² + z²)
s = atan(y / x)
t = acos(z / r)
textureCoordinate = (s / pi, t / pi)

If it weren''t for the artifacts that appear close to the YZ plane, this would be great.

Anyone have any suggestions? Anyone see where I''m going wrong?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!