Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Problem by creating texture3d out of a texture2d array

4: Adsense

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 _undex   Members   

325
Like
0Likes
Like

Posted 12 December 2012 - 09:46 AM

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.

#2 MJP   Moderators   

19599
Like
0Likes
Like

Posted 12 December 2012 - 01:55 PM

Moving this to the DirectX forum

#3 _undex   Members   

325
Like
0Likes
Like

Posted 22 December 2012 - 03:49 PM

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



#4 unbird   Members   

8310
Like
0Likes
Like

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.




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.