# 3d Volume from 2d Texture

is it somehow possible to generate volumetric information from a 2D Image Texture?

I experimented already quite a bit, but with no succes. I thought about using the RGB, or better said, the BW-Information to generate the missing vector.

An alternative which i thought would work, was to use the image as a input Position for a gradient (spheric), since the gradients are all volumetric by themselves. Also, with no succes.

The mockup was created by using an empty and its object coordinates as gradient input vector.

• I have just been playing with this. Use a Gradient Texture Node but set it to Quadratic Sphere. – rob Jan 17 '19 at 15:47
• A very good question. I would love to figure this out or find an answer to this as well. That would be quite useful. – Martynas Žiemys Jan 18 '19 at 14:33

Here's a clunky sort of first step (maybe not towards where you want to go):

Make a height-map of the subject (Mist Pass, 0-1, front to back of a containing cube)

Set up a node tree something like this:

Where each shading point asks whether, in 0-1 generated texture coordinate space, its Z value is close to the R value in the depth map for its XY. If it is, it lights up.

(Sorry to be confusing, but here, XY has been mapped to XZ, and Y checked against the map, to get Suzanne facing down Y)

The 'Close to' node group just returns 1 if Value1 and Value2 are within Delta of one another, 0 otherwise.

The 'Less Than' node checks if the Y value is close to 1, to get rid of the background, 'beyond everything' values in the depth map.

This is the result:

I tried projecting height-maps down X and Z as well, which could be encoded in G and B of the texture, but they were not automatically calibrated for position or scale, I may just have slipped up somewhere.

But I thought , anyway, it would be better to go for a spherical height map: bake a displacement map of the subject from an enclosing sphere, and store it as, say, a Mercator projection? And then, instead of using Z as the lookup, use the shading point's angles, theta and phi from the origin, to look up the point in the texture to check against.

Then you could use Alpha to store depth, and R,G and B to store R,G and B, to get colored (but not fully covered) volumes.

But since there will be lots of gotchas, and I'm not @Rich Sedman, that may take a while.

• I just figured out why the X and Z mist-passes weren't calibrated.. they were quadratic, not linear. No time right now.. – Robin Betts Jan 19 '19 at 20:50
• Wow, thats already great! I thought about baking a texture of the object-space colours, each pixel would essentially describe a xyz value. Would it be possible to cast lines from the origin of the cube and check them against those values? – Chris Jan 21 '19 at 7:55
• @Chris If you bake to a UV map, then, without a 3D mesh, there's no mapping from the shading point, no lookup into the texture, and we're trying to avoid 3D info ( otherwise we could just use a Point Density texture). If we bake to a known projection of some sort, then 2 dimensions are implicit in the location of the pixel in the texture, making 2 dimensions of its object-space color redundant? There has to be some sort of lookup, with the shading point as key. Unless you want a full search of the texture file on every sample, for a pixel matching the shading point... which you don't :) – Robin Betts Jan 21 '19 at 13:45
• @Robin Betts hmh, you're right. I probably have thought something not entirely trough^^. In my mind i had it layed out somewhat like this: Based on the normal of the surface a line gets cast perpendicular to the inside of the mesh (not the origin). To get the depth i wanted to use the white levels of the texture that previously were painted in texture paint. So there would be a 3D Mesh to cast from. – Chris Jan 21 '19 at 20:25
• There might well be a way we haven't thought of ... when I saw your idea I was very tempted... even skirted around with how holograms work... after all the surface of an object is 2D,.. it's a lovely question. – Robin Betts Jan 21 '19 at 22:18

Default Cube with a Color Ramp powered from the Gradient Texture set to Quadratic Sphere

Now with the Generated Texture coordinates tweaked to place the center at the centre of the Default Cube

Using Emission Shader because it looks cool.

• Procedural Gradient texture in Blender is 3d. The question is about a 2d image. – Martynas Žiemys Jan 18 '19 at 14:14