everyone! I am currently developing a program that converts a 3D model to 2D isometric pixel art. Part of my program extracts the texture from an FBX file (as FBX files can have textures built in), and then the texture will be used when converting to vox (which is then converted to a sprite sheet). So, I have a 3D model of a bed here: bed model

And then I extract the texture programatically, which leaves us with a jpg:

bed texture

But then, when converting the 3D model to vox, I need to get the color from the specific locations on the bed where the model is being converted to voxels, to apply to each voxel. To do this, my thoughts are that I'll calculate where on this texture sheet would map to my current point on the 3D model, and get the color at that pixel.

The trouble is calculating this. My question is, how do I calculate how a 2D texture sheet is mapped to a 3D model? Thanks in advance for your answers!


1 Answer 1


For each visible voxel side you need to iterate over all triangles and find if ray from voxel side normal intersects that particular triangle. Having intersection point you can then calculate barycentric coordinates of this point within intersected triangle. And with barycentric coordinates you can calculate UV of intersection point and therefore sample color from original texture. If you need more than one pixel per voxel side then you can cast more rays.

  • $\begingroup$ This is really interesting. I'm definitely gonna give it a try; though it might take awhile, so I won't mark this question as answered quite yet. Thank you! May I ask where you gained this knowledge? $\endgroup$
    – Simon Ward
    Jan 13, 2021 at 22:26
  • $\begingroup$ Most of engines return barycentric coordinates among other info when collsion test is requested, so you gain this knowledge wether you want it or not ;) $\endgroup$
    – Sergio
    Jan 15, 2021 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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