# Calculation point in 3D polygon, from 2D texture coordinates

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

## Recommended Posts

Basically what I'm looking for is a way to calculate the real position of a pixel in 3d world. I know the texture coordinates of that polygon(triangle), and it's 3d representation, i would like to loop through whole texture and retrieve positions for all points in it. so: for i = 0 to width for j = 0 to height if (i,j) in triangle_texture_coordinates point[i,j] = calculate( (i,j), triangle_texture_coordinates, triangle_positions )

##### Share on other sites
there is no fast way to accomplish that , texture uv coords are normalized , thus you can cycle trhough 0..1 and get the correct index.

first you need a bilinear transofrmation beetween the points rendered in the surface and points in 3d , this is achieved retriving the point coordinate in space for each vertex.
Once you have that, compute the normal for this surface
write polygon rasterizing function.
when you have rasterized each polygon scan line pass the extremes for
this scan line in a function which computes the plane
equation like this
a * ( x-px0 ) +b * ( y-py0 ) +c* ( z-pz0 )=0;

a,b,c is the normal vector
px0,py0,pz0 is a point lying on the plane, usually is the first vertex
you obtain from polygon coordinates.
now in side the main loop you have the x,y,z values spanning all the polygon
and with the function above you can easily compute the z coordinate
By the way i think that this method is computationally expensive
what are you trying exactly to do ?

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633330
• Total Posts
3011389
• ### Who's Online (See full list)

There are no registered users currently online

×