Volume texture interpolation, HLSL, and efficiency

Started by
2 comments, last by Dethtoll 17 years, 5 months ago
I'm fairly new to DirectX and HLSL, and I have a question about volume textures. I'm working on an image composition project that requires weighted sums of 16 (or potentially more) equally-sized floating-point textures. My program would be cleaner and more flexible if I had control over the number of textures instead of simply creating 16+ samplers that differ only by their texture. Only a single mipmap texture is required per texture. My idea is to pack all the textures into a single volume texture, which would be sampled at integer depth values. This leads to my main question: + Are volume textures less efficient than standard 2D textures if they're sampled at integer depths? In other words, if I sample the volume at integer depth n, will the textures at depth n-1 and n+1 still be sampled? Maybe more clearly: Can I point sample the depth and still filter the height and width bilinearly?
Advertisement
Alright, looks like I was confused about a few things there. The depth value of texture volumes has a range of [0,1], so I can't sample at integer depths anyways.

Is there any way to have a set of textures in HLSL without creating a sampler for each? It just seems messy to have to manually create n samplers, and it would be nice to be able to iterate over the textures in a for loop rather than repeating code.

Would it be possible to use the tex2Dlod intrinsic for this purpose? Is it even possible to create mipmap levels with the same dimensions as the original image?

Thanks in advance.
Is it necessary to even create a volume texture? What about just arranging them in a 4x4 pattern on a single flat texture, and using texture coordinate offsets to do the sub-indexing?

Of course, you could break the process down into binding/sampling, say, 4 textures at a time and using an intermediate texture result. Or 1 at a time, for that matter. All depends on exactly what you're doing.
That's actually what I ended up doing. I just packed them into a single texture, with a 1-pixel extended border around each for correct bilinear filtering.

Not sure why I was so eager to jump into 3 dimensions...

This topic is closed to new replies.

Advertisement