Sign in to follow this  
Radiocreed

Raytracing: Texture mapping of primitives

Recommended Posts

atcdevil    145
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
Dmytry    1151
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
dimensionX    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this