• Advertisement
Sign in to follow this  

Raytracing: Texture mapping of primitives

This topic is 4805 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

Can someone help me on the equations of texture coordinates for sphere, cylinder, cone and cube? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
this is something you could find in 2 seconds using google you know...

disclaimer, this could be wrong, but I hope this helps

for the sphere:
x=ro*cos(theta)*sin(phi)
y=ro*sin(theta)*sin(phi)
z=ro*cos(phi)
0<=theta<=2PI
0<=phi<=PI
you'll leave ro as a constant (it's the radius), and theta and phi can correspond to texture coordinates

for the cylinder:
x=r*cos(theta)
y=r*sin(theta)
z=z
0<=theta<=2PI
0<=z<= whatever height you want
r is constant.. it's the radius
And z and theta will correspond to texture coordinates.

I'm guessing the cone is the same as the cylinder except:
x=z*r*cos(theta)
y=z*r*sin(theta)


and a cube.. I have no clue how to parameterize.

Share this post


Link to post
Share on other sites
again, there's no such single thing as correct texture coordinates on primitive.

You can use any texture coordinates you like, and that's all. For texturing with 2D tecture map, you should make function that takes 3D position on surface of object and output 2D texture coordinate that makes sense. For sphere, you can use cubemap for texturing, or you
can use polar coords, etc. For cube you can use cubemap, but also you can use polar coords. For cone you can use "unfolded" cone, like paper shape that can be folded into cone. For torus you can use parametric equation of torus. And you can use cubemap. Or instead of point you can use surface normal together with cubemap. Possibilities is endless.

Share this post


Link to post
Share on other sites
Check out the book 'Introduction to Raytracing" - Andrew Glassner

It has a detailed explanation and mathematics behind texture mapping sphere, quad, triangle, cone, cylinder and even quadrics. I am sure you will find it very help full.

Cheers!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement