Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > University Math Help > Linear and Abstract Algebra
Reply
 
Thread Tools Display Modes
  #1  
Old November 4th, 2009, 10:18 AM
Newbie
 
Join Date: Nov 2009
Posts: 10
Country:
Thanks: 0
Thanked 2 Times in 2 Posts
umbrella is on a distinguished road
Unhappy Spherical UV mapping

Hello,

If I posted this question in the wrong section please correct me. I don't really know where I should put it.

I got the following problem: I have build a ray tracing engine and I'm now working on texture mapping. However I came across a problem when I used the functions defined in the book.

Let's define some values:

o(x, y, z) is the origin of my sphere, which is the same as the center of my sphere.
p(x, y, z) is the intersection point of a ray from the camera that hits the sphere.
R is the radius of my sphere.

Let's see what my book has to offer:

Fundamentals of computer graphics - Google Boeken

Now I know that I do not like to read pages before I can answer a question so, I will type the formula here:

\theta = \arccos{(\frac{p_{z} - o_{z}}{R})}
\phi = arctan2{(p_{y} - o_{y}, p_{x} - o_{x})}

So what does this arctan2 do? it returns the arctangent of a/b. Because (\theta, phi) \in [0,\pi] \times [-\pi, \pi], we convert (u, v) as follow, after adding 2 \cdot \pi to \phi if \phi < 0.

u = \frac{\phi}{2 \cdot \pi}
v = \frac{\pi - \theta}{\pi}

Now you might wonder, what kind of results does this give us? I will show you a picture what kind of result it should be giving with bilinear interpolation applied.



Well how does it look for me?



(Please do not pay attention to the edges, I cut them with Photoshop so you don't have to bother looking at the rest of the image, which contains no spheres at all except the one I'm showing.)

Now how did I tried to fix this? By fixing it accourding to the image.

I ended up with the best result given by:

\theta = \arccos{(\frac{p_{y} - o_{y}}{R})}
v = \frac{\pi - \theta}{\pi}

\phi = arctan2(o_{x} - p_{x}, o_{z} - p_{z})
when \phi < 0 I do phi + 2 \cdot \pi.
u = \frac{phi}{2 \cdot \pi}

My best result:



Now my question, is there any possible way that I can fix my best result to resemble the correct result?

If yes how can I do this by only modfying my equations? (please do not tell me to debug my code, but if you have a suggestion where the bug may lie, I will be happy to hear your suggestion.)

If I remove the devided by 2 * \pi and \pi, I will end up having a lot of image tiles in my image, which is a good thing. However when tiling is not needed (the picture is large enough to fit onto the sphere), it will still places replicas of the image onto my sphere . That is not correct. I need equations that only places replicas when the image is too small.

If you have other methods of doing a spherical uv mapping please tell me. I am very happy to look into it!

Thanks for your answers
Reply With Quote
Advertisement
 
  #2  
Old November 4th, 2009, 03:58 PM
Newbie
 
Join Date: Nov 2009
Posts: 10
Country:
Thanks: 0
Thanked 2 Times in 2 Posts
umbrella is on a distinguished road
Default

I think it would be impossible to tile one sphere and not tile the others, when calculating the uv coordinates. So I created a patch for this. If anyone disagrees, please state your solution.
Reply With Quote
Reply

Tags
spherical, uv mapping

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 01:56 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.