Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Generating mipmaps in DirectX 11


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
8 replies to this topic

#1 craigbrad   Members   -  Reputation: 119

Like
0Likes
Like

Posted 12 March 2014 - 08:48 AM

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



Sponsor:

#2 imoogiBG   Members   -  Reputation: 1247

Like
4Likes
Like

Posted 12 March 2014 - 02:30 PM

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



#3 Jason Z   Crossbones+   -  Reputation: 5450

Like
1Likes
Like

Posted 12 March 2014 - 08:12 PM

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.



#4 Reitano   Members   -  Reputation: 553

Like
0Likes
Like

Posted 14 March 2014 - 05:32 AM

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.



#5 L. Spiro   Crossbones+   -  Reputation: 14447

Like
5Likes
Like

Posted 14 March 2014 - 07:09 AM

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#6 craigbrad   Members   -  Reputation: 119

Like
0Likes
Like

Posted 16 March 2014 - 03:30 PM

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!



#7 craigbrad   Members   -  Reputation: 119

Like
0Likes
Like

Posted 16 March 2014 - 03:33 PM

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!



#8 L. Spiro   Crossbones+   -  Reputation: 14447

Like
2Likes
Like

Posted 16 March 2014 - 06:41 PM

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, 16 March 2014 - 06:46 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#9 craigbrad   Members   -  Reputation: 119

Like
0Likes
Like

Posted 17 March 2014 - 10:53 AM

 

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






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.



PARTNERS