Sign in to follow this  
jajcek

How to generate 3D texture with mipmaps

Recommended Posts

Hi,

 

I'd like to create 3D texture with mipmaps.for my terrain in dds format. I have made short research on this and found out that DirectXTex is able to create volume textures (texassemble), but it doesn't support mipmaps. However the texconv is able to generate mipmaps but...

 

I have generated the volume texture and it looks all right (I am viewing it in the DDS plugin for photoshop): stzu.png

 

but when I use texconv to generate mipmaps for it it looks wrong, because there are mipmaps only for the first texture:

 

slji.png

 

Is it a bug in DDS plugin, or maybe the texconv doesn't support generating mipmaps for volume textures? (I have usedd it like: texconv -m 3 my.dds)

 

EDIT: Acutally by taking a deeper look on this image, the mipmap is somehow blended from these 2 main textures. Why?

 

Thank you for any help!

Edited by jajcek

Share this post


Link to post
Share on other sites

If the z dimension is 2, the next smaller mip level dimension is 1. And the contents of that 1 level represents an average of the two larger levels (linearly interpolated between them, with t = 0.5). So, I believe the texconv output is correct.

Edited by Nik02

Share this post


Link to post
Share on other sites

@GameCreator By saying DDS plugin for photoshop I meant the one you are talking about.

 

@Nik02 Is that so? I thought it's a bug not a feature. But searching a bit more I have found this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205579(v=vs.85).aspx

 

I wonder how such texture will look on a mesh. This approach of interpolating mipmaps is quite dangerous I think. Some unexpected textures might be visible when looking further.

Edited by jajcek

Share this post


Link to post
Share on other sites

Volume textures are filtered in all 3 dimensions, which is definitely not what you want for a texture atlas. What you should use instead is a Texture2DArray. This is basically an array of 2D textures, with each array slice having its own completely separate mip chain. Texassemble can generate one for you, and from what I can tel texture arrays are fully supported in DirectXTex/Texconv/DDSTextureLoader.

Share this post


Link to post
Share on other sites

What about interpolating between them? In 3D texture I could use simple weights like:

 

1.0 - rock

0.5 - grass

0.0 - sand

 

and 0.25 would be mix of grass and sand.

Edited by jajcek

Share this post


Link to post
Share on other sites

What about interpolating between them? In 3D texture I could use simple weights like:

 

1.0 - rock

0.5 - grass

0.0 - sand

 

and 0.25 would be mix of grass and sand.

That may seem easier to implement, but the efficiency will likely be poor compared to a texture atlas due to the filtering requirements on a 3D texture.  But you can still try it out and see how it looks, then you can tinker with the 3D texture and see how it performs.

Share this post


Link to post
Share on other sites

More often than not a naive blend between a rock and grass texture looks really bad. You want something more like a crease blend where grass will start to bleed through cracks of the rock before it starts to take over. That's better done via separate textures rather than simple hardware blending. So in that regard I don't think the 3D texture idea is worth it.

Share this post


Link to post
Share on other sites

It's hard to make it without such interpolation, since my terrain is infinite and automatically generated using perlin noise.

 

I have actually no idea on how to use the texture array to make interpolations between them ([0] - [1] - [2] - ... - [N] and so on) without sending N weights to every vertex to tell the shader which texture it should sample.

 

Could you help me with that, please?

 

// edit

 

Is it possible to give texture index a float value and get blending this way? E.g:

 

Texture2DArray myTex;

myTex.Sample( sampler, float3( u, v, 0.5f ) );

Edited by jajcek

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this