• Advertisement
Sign in to follow this  

Generating mipmaps in DirectX 11

This topic is 1404 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

I'm wanting to generate a full chain of mip-maps right down to 1x1 so that I can get the average luminosity of my rendered scene.

How would I go about doing this in DirectX 11?

I have setup the D3D11_TEXTURE2D_DESC with the right misc flags and was wondering what mipmap levels i should use. 

Does setting the mip levels to 0 create a full chain or do you have to manually set the number? 

My last question is my scene is rendered in widescreen 16:9 so the texture isnt square will I be able to go as low as 1x1?

 

Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement

imoogiBG has the right link to get you started.  This page also confirms about setting the number of levels to 0 for a full mip chain.  The mip chain will extend to 1x1 at the lowest level, even if your dimensions aren't square.

Share this post


Link to post
Share on other sites

Related to mipmapping, are there standard rules for rounding the width and height of the mipmap levels of non-power-of-2 textures ? I could not find any information in the DirectX documentation on that and no relevant API method either (only a GetDesc for the texture, not the sub surfaces). In my engine I manually lock and fill the mip levels of some textures but I don't feel too confident about the assumptions I've made regarding the dimension of the locked surfaces.

Thanks.

Share this post


Link to post
Share on other sites

The width and height are always halved and integer-truncated (a simple unsigned integer VAL >>= 1), then max’ed with 1 until both the width and height are 1. After that, there are no more mipmaps.


L. Spiro

Nice to know, Thanks!

Share this post


Link to post
Share on other sites

the problem is I need to extract the 1x1 mipmap and send the data over to a shader. I can't figure out how to extract the mipmap.

tex2Dlod
Specify the level of the 1×1 mipmap in t.w and sample coordinate [0.5, 0.5] (t.xy = vec2(0.5,0.5);).

Or you can activate only the lowest mipmap when you set the texture.
When calling CreateShaderResourceView(),
Set D3D11_SHADER_RESOURCE_VIEW_DESC::Texture2D::MostDetailedMip to the last mipmap level (D3D11_SHADER_RESOURCE_VIEW_DESC::Texture2D::MipLevels - 1).


L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites

 

the problem is I need to extract the 1x1 mipmap and send the data over to a shader. I can't figure out how to extract the mipmap.

tex2Dlod
Specify the level of the 1×1 mipmap in t.w and sample coordinate [0.5, 0.5] (t.xy = vec2(0.5,0.5);).

Or you can activate only the lowest mipmap when you set the texture.
When calling CreateShaderResourceView(),
Set D3D11_SHADER_RESOURCE_VIEW_DESC::Texture2D::MostDetailedMip to the last mipmap level (D3D11_SHADER_RESOURCE_VIEW_DESC::Texture2D::MipLevels - 1).


L. Spiro

 

Thanks a lot, really appreciated! I will go with the first option :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement