Texturing a surface from a volume

I need to texture a surface (z=f(x,y)) with texels from a 3D volume, extracted at (x,y,z). I.e. I want the surface to show the
values of the volume at the position of the surface.

The volume is huge, so hardware 3D texturing is not an option. I need several tiled textures.

My problem is: How do I efficiently store and use the resulting texture(s)?

Keep in mind that very little memory should be wasted, and that the surface can be partly very steep and partly very flat, and that as few intersected voxels as possible should be lost.

I have a few ideas of my own, but I’d like to fish for some others first.

Booga

Since your function is of the form z = f(x,y), you can simply generate a standard 2d texture, where the color at (x, y) of the texture is the color at the point (x, y, f(x,y)). You’d probably have to do the necessary scaling to bring the x and y coordinates to the [0,1] ranges of textures.

Of course, if you have enough vertices, you can just use vertex colors. This has the advantage that you don’t need any texture memory, but you have to recompute these colors (as well as the coordinates) each time you want to redraw, plus it could end up being a ton of vertices.

–Won

I pointed out a couple of facts that make this quite a bit harder:

  1. The volume is huge (I should have said explicitly that the dimensions can well be larger than the maximum texture size on many cards)

  2. The surface can have very steep parts, as well as very flat parts. This implies that along a triangle strip, there can be both steep (|dz| >> |dx| or |dy|) and flat (|dz| ~ |dx| and |dy|) triangles. Clearly, the steep triangles require more texels to represent the intersected voxels than the flat ones.

Point 1 implies that I’ll need more than one OpenGL texture for the entire surface.

Point 2 implies that using one texture for one triangle strip (say) could potentially lead to wasted space if it has to contain texels for both steep and flat triangles.

My main requirements are

  • quality (as many intersected voxels as possible should be represented by texels)
  • efficiency in memory and CPU requirements

My current thoughts are along the following:

I need several textures for one or both of two reasons:

  1. the volume size (if it has more than, say, 1024 voxels in one direction, I need to tile textures)

  2. the complexity of the surface (if it has both steep and flat parts, determined by some tolerance, I need at least one texture for steep parts, and one texture for flat parts, to cater for the voxel density in vertical and horizontal directions)

Any thoughts?

Booga