Jump to content
  • Advertisement
Sign in to follow this  
Ryan_001

D3D11 multitexturing

This topic is 1862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

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

 

i never use if statements in a shader

Share this post


Link to post
Share on other sites

(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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!