NeTBaPb

xna help:

To use the Texture3D.GetData or Texture3D.SetData methods, Texture3D.ResourceManagementMode must be ResourceManagementMode.Manual and Texture3D.ResourceUsage must be ResourceUsage.Dynamic.

the problem is that texture3d constructor dont have resoursemanagement parameter (while texture2d has)!

is this a bug




Re: XNA Framework what is best way to render scene with great number of textures?

Kyle0654

I figured you might have some problems with 3D textures - I know I did the first time I tried using them.  Here's a bit of code I ended up using to get Texture3D creation to work:

    // Set up the texture
   3DTexture = new Texture3D(device, sizex, sizey, sizez, 1, ResourceUsage.AutoGenerateMipMap, SurfaceFormat.Color);
   3DTexture.SetData(0, 0, 0, size, size, 0, size, byteData, 0, byteData.Length, SetDataOptions.None);


Note that I specified AutoGenerateMipMap.  It's the only creation method I've been able to get to work, but it will not automatically generate a mipmap - you have to generate mipmaps yourself if you want to.  However, for your purposes, I'm sure you won't want mipmaps (you'll want to make sure your shader knows this).  If you wanted to use mipmaps, you'd need to do something like multiplying the depth by how many levels of detail you wanted, and then including that many of each texture on the first level (so when you get to the lowest level you'll still be sampling the single texture, but at a lower resolution).

Hope that helps.  I didn't change any parameters on the device or anything (that I can remember), so you shouldn't need to.




Re: XNA Framework what is best way to render scene with great number of textures?

NeTBaPb

im currently trying following:

TextureCreationParameters tcp = new TextureCreationParameters(128, 128, 128, 1, SurfaceFormat.Color, ResourceUsage.Dynamic, ResourceManagementMode.Manual, Color.White, FilterOptions.None, FilterOptions.None);

tsz = Texture3D.FromFile(graphics.GraphicsDevice, "tex3d", tcp);

i've successfully loaded texture, i hope i'll be able to get/set data on it.

anyway this is obviosly a bug in 3d textures, coz it's impossible to create manual resource texture via contructor.

--

btw, i've got an exception on this:
tsz = new Texture3D(graphics.GraphicsDevice, 32, 32, 32, 1, ResourceUsage.AutoGenerateMipMap, SurfaceFormat.Color);
invalid method call :/






Re: XNA Framework what is best way to render scene with great number of textures?

The ZMan

[I pulled this part of the thread out on its own since it looks like a potential/bug ommision in the texture3d constructor]




Re: XNA Framework what is best way to render scene with great number of textures?

Shawn Hargreaves - MSFT

It's correct that Texture3D doesn't let you specify the resource management mode. That's because there is never any reason to make a Texture3D in anything other than the automatic pool: none of the reasons you'd want a manual pool texture apply to 3D data.

The docs are incorrect in saying you can only GetData/SetData on manual pool textures.





Re: XNA Framework what is best way to render scene with great number of textures?

NeTBaPb

ye, i already figured that out. i created usual texture with None usage and get/set works fine :) also i noticed that i can't create 3d texture with dimension non power of 2. is this depends on video card or it's 3d texture feature






Re: XNA Framework what is best way to render scene with great number of textures?

Shawn Hargreaves - MSFT

Non power of two texture support depends on your video card.