D3D11 multitexturing

Started by
2 comments, last by Hodgman 10 years, 11 months ago
I'm attempting to play around with signed distance field rendering in D3D11, and I need to access multiple textures from the same pixel shader. The thing is, these are volume (3d) textures, not standard 2d textures, and I need to access them dynamically (ie. I need to be able to select the texture by an index or variable).
I'd love to use texture arrays, but to my knowledge there is no such thing as a 3d texture array.
I could use a set of if statements something like:

if (index == 0) texture0.Sample(sampler_state,location);
if (index == 1) texture1.Sample(sampler_state,location);
// ect...
but I can't see that being that fast.
My next option is to use 1 large 3d texture and simply use the index as an offset, but I risk hitting the limits on the texture dimensions, and total texture size.
I plan on using the textures as a sort of mipmap, but each subsequent texture won't be smaller than the last (they will all be the same size), rather each subsequent texture (or mip level) will cover a larger area. So I can't just use a 3d texture with mipmapping enabled (unless there is someway to specify the size of each mip level that I am unaware of).
Any suggestions or ideas?
Advertisement

(1 - index) * texture0.Sample(sampler_state, location) + index * texture1.Sample(sampler_state, location)

i never use if statements in a shader

(1 - index) * texture0.Sample(sampler_state, location) + index * texture1.Sample(sampler_state, location)

i never use if statements in a shader

From what I understand, on any modern card that'd be much slower than a series of if statements. In that case every texture would be accessed regardless, at least with multiple if statements every texture would be accessed only when every texture was accessed simultaneously on a given warp.

Before texture arrays existed, we emulated the behaviour for 2D texture using texture atlases -- storing many 2d sub-textures within a single large texture.

You could do the same with your 3D textures, which would replace the branching with some code to simply offset/scale the tex-coords.

This topic is closed to new replies.

Advertisement