Generating mipmaps in DirectX 11

Started by
7 comments, last by craigbrad 10 years, 1 month ago

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

Advertisement

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476426(v=vs.85).aspx maybe?

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.

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.

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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

I had looked at that, 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. Thanks anyway!

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!

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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

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 :)

This topic is closed to new replies.

Advertisement