3

How can i store the X,Y,Z vertex points of a mesh into a 2d image, such that reading the image pixel values will correspond to the 3d coordinates? is it possible to just store x, y, values on a grid and use the Z value as an intensity value?

1 Answers1

2

The most straightforward way would be to put x into the red channel, y into the green channel, and z into the blue channel of each pixel.

You could also make a 1 channel image where intensity is used to describe height. This is called a height map. Usually the x and y of the mesh are the same as the x and y of the image, so no need to store them in any way.

user1118321
  • 3,401
  • 11
  • 14
  • is it possible to generate a height map using 3d software such as maya or blender rather than trying to create one manually using python? and does the generated map store the 3d coordinates in each channel like you have described? – Mark Markrowave Charlton Jun 14 '17 at 01:59
  • 1
    I haven't done it that way before, but I believe you can. (I'm usually generating them in code.) There is a Blender Stack Exchange where you could ask about that. The Video Production Stack Exchange may have info on Maya or other apps. In my experience height maps are usually just grayscale images where brightness represents height rather than putting all 3 coordinates into the r, g, and b channels, so I'd expect most apps to output that way. – user1118321 Jun 14 '17 at 02:33
  • @MarkMarkrowaveCharlton Yes all you have to do is choose a format that allows writing the zbuffer and check ot under camera settings. If really need this in a rgb image you can just write the distance to the pixel value using a node (sampler info in maya) – joojaa Jun 14 '17 at 05:36