Sign in to follow this  
danromeo

Texture class confusion....Texture, Texture2d, Texture3d, TextureCollection, Texture Sampler arrays

Recommended Posts

danromeo    238
Hello. I can't seem to find a lot of info about this. I'm using XNA 4.0 for Windows for what it matters.

1. The Texture2d class is defined as a collection of texels. The Texture class is defined as a Texture resource. Very helpful. What is the relationship between Texture and Texture2D?

2. I need to refer to an array of texture samplers in PixelShader 2.0 by a variable indice....i.e., tex2D(TextureSamplerArray[i], texcoords), where [i] is not defined at compile time. Which is not supported. Should I use Texture3d or a TextureCollection to pull this off? I can't find any info about TextureCollection at all besides MS's barebones definition and would rather not have to code myself into a corner to find out.

Thanks for the help.

Share this post


Link to post
Share on other sites
MJP    19754
[quote name='danromeo' timestamp='1310531075' post='4834620']
Hello. I can't seem to find a lot of info about this. I'm using XNA 4.0 for Windows for what it matters.

1. The Texture2d class is defined as a collection of texels. The Texture class is defined as a Texture resource. Very helpful. What is the relationship between Texture and Texture2D?

2. I need to refer to an array of texture samplers in PixelShader 2.0 by a variable indice....i.e., tex2D(TextureSamplerArray[i], texcoords), where [i] is not defined at compile time. Which is not supported. Should I use Texture3d or a TextureCollection to pull this off? I can't find any info about TextureCollection at all besides MS's barebones definition and would rather not have to code myself into a corner to find out.

Thanks for the help.
[/quote]

1. Texture is an abstract base class. It just contains functionality common to the 3 texture types (Texture2D, Texture3D, and TextureCube).

2. TextureCollection is not a resource type. It has the name "collection" as in the kind of collections you find in System.Collections. It's basically just an array of Texture's. The class exists for the Textures property of GraphicsDevice.

What you're trying to accomplish is most commonly achieved using a texture atlas. You can probably dig up some resources on terrain rendering that implement something similar.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this