Jump to content

  • Log In with Google      Sign In   
  • Create Account

D3D11 multitexturing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Ryan_001   Prime Members   -  Reputation: 1397

Like
0Likes
Like

Posted 18 May 2013 - 04:55 AM

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?


Sponsor:

#2 hdxpete   Members   -  Reputation: 470

Like
0Likes
Like

Posted 18 May 2013 - 05:06 AM

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

 

i never use if statements in a shader



#3 Ryan_001   Prime Members   -  Reputation: 1397

Like
0Likes
Like

Posted 18 May 2013 - 05:25 AM

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



#4 Hodgman   Moderators   -  Reputation: 30388

Like
0Likes
Like

Posted 18 May 2013 - 08:56 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS