4
\$\begingroup\$

I have 3D models which are typical hollow hulls. If such a model also had a 3D volumetric/voxel texture map then given a point P inside such a model, I'd like to be able to find its uvw coordinates within the 3D texture.

Is this possible by simply setting 3D texcoords on my existing mesh or does it have to be broken up into polyhedra? Is there a way to map a 3D texture onto a mesh without doing this?

\$\endgroup\$
1
\$\begingroup\$

All you have to do is to normalize the model-coordinates on your mesh to the range textures use which is [0~1] from top left to bottom right in DirectX or from bottom left to top right in OpenGL. You can store these texture coordinates in your mesh as attributes which you can set up to be accessed in the vertex shader. Then simply pass these texture coordinates to the pixel/fragment shader (using some form of interpolation).

Then you can simply use the normalized XYZ coordinates of the point on the mesh as UVW coordinates in your 3D-Texture.

\$\endgroup\$
  • \$\begingroup\$ That's only going to tell me the uvw for points on polygons... \$\endgroup\$ – Mr. Boy Apr 29 '14 at 13:34
  • \$\begingroup\$ Since the polygon will be made up of triangles the rasterizer will be able to accurately interpolate between the texture-coordinates from the three vertices of the triangle to be able to find the texture-coordinates of the point. \$\endgroup\$ – Roy T. Apr 29 '14 at 21:09
  • \$\begingroup\$ Yes, the point on a triangle. That's not what I'm asking... I am talking about a point inside the model. e.g. I have a 3D model of a skull as a hollow shell, and a 3D texture of your entire head. If I take a point inside the brain, I want to find it's uvw \$\endgroup\$ – Mr. Boy Apr 30 '14 at 7:26
  • 1
    \$\begingroup\$ Roy T's suggestion is that you use (scaled versions of) the x, y, z coordinates of the vertices as your uvw texture coordinates. That mapping remains continuous for (x,y,z) triplets of points inside the volume of the mesh, as well as on its surface. So for any point in the vicinity (even outside) of the model, you can find its texture coordinate. But it does not give you flexibility if you need to shift the texture on the surface by manually adjusting vertex uvw coordinates. \$\endgroup\$ – DMGregory May 29 '14 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.