Problem by creating texture3d out of a texture2d array

Started by
2 comments, last by unbird 11 years, 3 months ago
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, 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.
Advertisement
Moving this to the DirectX forum

Can someone help me?
I can't solve this problem -.-

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.

This topic is closed to new replies.

Advertisement