Jump to content
  • Advertisement
Sign in to follow this  
Magos

D3DXCreateTexture and mip maps

This topic is 4835 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

Correct me if I'm wrong, but it seems that D3DXCreateTexture() does NOT create a mip map chain by itself (like D3DXCreateTextureFromFileInMemoryEx() does). Setting miplevels to 1 makes it work (but look ugly on distances), but setting it to 0 or D3DX_DEFAULT doesn't create a proper mip-map chain like the docs says. It makes the faces disappear or fade out when looked at in certain angles or distances. Do you have to manually create the mip-map chain? How?

Share this post


Link to post
Share on other sites
Advertisement
Correct.. you either have to load the data into the lower miplevels yourself.. or call D3DXFilterTexture to do it for you.

xyzzy

Share this post


Link to post
Share on other sites
CreateTextureFromFileEx also allows you to specify a mip-levels value, where 0=auto, 1=disabled, and anything else is the number of levels. I've found this quite useful as certain textures definitely look better/worse depending on this setting. Text, for instance, definitely requires tinkering. (Sorry if this has nothing to do with your question!)

Share this post


Link to post
Share on other sites
If you set the Levels parameter of IDirect3DDevice9::CreateTexture to 0, then D3D will create a texture with all the mip levels you need, down to 1x1. However, you still need to lock each mip level in turn and fill it with data.

It seems that D3D fills the mip levels with 0x00000000 (I'm surprised the debug runtime doesn't fill it with gibberish). Which means the alpha is zero, which means that your texture has big transparent bits at lower mip levels.

That's my best guess anyway.

Share this post


Link to post
Share on other sites
What I was saying is, why not just load your textures with D3DXCreateTextureFromFileEx since it DOES fill in the data for you at the requested number of mip levels? I guess maybe some people write better filtering algorithms or something...

Share this post


Link to post
Share on other sites
Quote:
Original post by MasterWorks
What I was saying is, why not just load your textures with D3DXCreateTextureFromFileEx since it DOES fill in the data for you at the requested number of mip levels? I guess maybe some people write better filtering algorithms or something...
I agree, D3DXCreateTextureFromFileEx or D3DXCreateTextureFromFileInMemoryEx would be what I use. But there are some circumstances under which you'd want to use D3DXCreateTexture and fill the mip levels yourself, such as if you wanted different filtering as you suggested, you wanted a totally different image on each mip level, or you don't actually have files stored in memory anywhere, and you only have raw bit data.

Share this post


Link to post
Share on other sites
Thanks, D3DXFilterTexture was exactly what I needed.

D3DXCreateTextureFromFileInMemoryEx was out of the question since I'm using a somewhat custom image format.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!