How to create a 3D Texture?
Hello everyone,
i am trying to figure out how to create and use 3D textures.
I am using a Texture atlas for my terrain textures which are spread over the whole terrain. For the detail-textures i would like to use a 3d texture where each level has one texture without mip-maps since the detail textures wont be shown in the distance anyways.
I guess once i loaded the 3D texture and set it for the texture state i can just sample it with tex2D() and set the uv.w coordinate to the texture i want.
What i don't know how to do though is how i would create such a Texture?
If anyone had some hints for me it would really be great!
Thx a lot in advance!
IDirect3DDevice9::CreateVolumeTexture.
As for getting data into it, you'd usually load multiple 2D textures and Lock and fill each layer of the volume texture. There's no D3DXCreateVolumeTextureFrom*() functions or anything.
EDIT: I'm talking bollocks. There's D3DXCreateVolumeTextureFromFile
[Edited by - Evil Steve on March 4, 2009 7:04:36 AM]
As for getting data into it, you'd usually load multiple 2D textures and Lock and fill each layer of the volume texture. There's no D3DXCreateVolumeTextureFrom*() functions or anything.
EDIT: I'm talking bollocks. There's D3DXCreateVolumeTextureFromFile
[Edited by - Evil Steve on March 4, 2009 7:04:36 AM]
Oh thx a lot:-)
I actually thought there was a tool or something like the atlas-tool that created a .dds file that includes all the textures.
So i just load every 2D Texture and add it to the 3D texture. Fair enough.
Thx again
I actually thought there was a tool or something like the atlas-tool that created a .dds file that includes all the textures.
So i just load every 2D Texture and add it to the 3D texture. Fair enough.
Thx again
Quote:Original post by Roziks_WorldActually, the DirectX texture tool can create a volume texture in a .dds file, but I've no idea how you'd get the volume texture out of the dds file without manually parsing the file.
Oh thx a lot:-)
I actually thought there was a tool or something like the atlas-tool that created a .dds file that includes all the textures.
So i just load every 2D Texture and add it to the 3D texture. Fair enough.
Thx again
EDIT: As per my above edit, I'm talking out of my arse. There's D3DXCreateVolumeTextureFromFile which will do the job adequately.
Ok i tried this now and i am having a little problem:-)
What i did is this: I created two textures and used to D3D Texture Tool to create a Volume Texture out of the two like described here: http://msdn.microsoft.com/en-us/library/bb219744(VS.85).aspx
then i load the texture with D3DXCreateVolumeTextureFromFile
and set the texture in the effect.
and in HLSL i try to sample the texture like this to ge the first slice:
float3 c0 = tex3D(Tex0S, float3(tiledTexC.x, tiledTexC.y, 1.0)).rgb;
But what i get is all slices blended together.
Anyone know how i acces each slice of the volume texture independently?
Thx again:-)
EDIT:
Found the problem. If anyone cares to know. I had to set the Addressmodes in the sampler to u = rwarapping v = wrapping and w=border and disable mipmaps.
[Edited by - Roziks_World on March 5, 2009 2:25:04 AM]
What i did is this: I created two textures and used to D3D Texture Tool to create a Volume Texture out of the two like described here: http://msdn.microsoft.com/en-us/library/bb219744(VS.85).aspx
then i load the texture with D3DXCreateVolumeTextureFromFile
and set the texture in the effect.
and in HLSL i try to sample the texture like this to ge the first slice:
float3 c0 = tex3D(Tex0S, float3(tiledTexC.x, tiledTexC.y, 1.0)).rgb;
But what i get is all slices blended together.
Anyone know how i acces each slice of the volume texture independently?
Thx again:-)
EDIT:
Found the problem. If anyone cares to know. I had to set the Addressmodes in the sampler to u = rwarapping v = wrapping and w=border and disable mipmaps.
[Edited by - Roziks_World on March 5, 2009 2:25:04 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement