Hello folks
I use SlimDx and I'm trying to create a texture3d object out of a texture2d array.
Each texture2d object has a height and a width of the variable "scale" and there are "scale" texture2d objects in the array.
But there is a problem. I can't get the data out of that array to write it into that texture3d object. So the texture3d object is always black when I draw it.
Here's my code:
[source lang="csharp"] byte[] data = new byte[textures.Length * scale * scale * 16]; for (int i = 0; i < textures.Length; i++) { System.IO.Stream stream = System.IO.Stream.Null; Texture2D.ToStream(device.ImmediateContext, textures[i], ImageFileFormat.Png, stream); stream.Read(data, i * (int)stream.Length, (int)stream.Length); } DataBox b = new DataBox(16 * scale, 16 * scale * scale, new DataStream(data, true, true)); volume = new Texture3D(device, new Texture3DDescription() { Width = scale, Height = scale, Depth = scale, MipLevels = 1, Format = SlimDX.DXGI.Format.R32G32B32A32_Float, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, Usage = ResourceUsage.Default }, b);[/source]
I hope someone can help me.
Problem by creating texture3d out of a texture2d array
Started by _undex, Dec 12 2012 09:46 AM
3 replies to this topic
Sponsor:
#4 Members - Reputation: 1605
Posted 22 December 2012 - 05:06 PM
I'm not that surprised System.IO.Stream.Null as a temporary stream produces black pixels.
Also: Texture2D.ToStream will write whatever image format you specified, not the raw texture data.
Alternative: Setup a suitable rendering with render targets into the 3D texture.
Also: Texture2D.ToStream will write whatever image format you specified, not the raw texture data.
Alternative: Setup a suitable rendering with render targets into the 3D texture.






