Colored mipmaps

Started by
10 comments, last by discman1028 17 years, 10 months ago
I'd like to have a chain of mipmaps with different colors, so I can see which levels are mostly useless. Must I load them manually? If so, is there a good tutorial on this? I can only find D3D code that does automatic mipmap generation. Or, if there's a way to do each mip level within an editor and save the whole chain (in a dds, say), that would be optimal. Thanks.
--== discman1028 ==--
Advertisement
Quote:Original post by discman1028
Must I load them manually? If so, is there a good tutorial on this?
Simply using IDirect3DTexture9::GetLevelCount() to iterate through each IDirect3DTexture9::GetSurfaceLevel() should do the trick. If your texture is also a render target you can use a ColorFill() operation, otherwise you can use a trivial D3DXFillTexture() - even a regular Lock() might work well if you know the pixel format.

Quote:Original post by discman1028
Or, if there's a way to do each mip level within an editor and save the whole chain (in a dds, say), that would be optimal.
I'm pretty sure the "DirectX Texture Tool" (dxtex.exe) should be able to load up individual images and export as a mip-chain. Might be worth looking into the Nvidia photoshop plugins (if you have Photoshop, or compatible, available)...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by jollyjeffers
Quote:Original post by discman1028
Or, if there's a way to do each mip level within an editor and save the whole chain (in a dds, say), that would be optimal.
I'm pretty sure the "DirectX Texture Tool" (dxtex.exe) should be able to load up individual images and export as a mip-chain. Might be worth looking into the Nvidia photoshop plugins (if you have Photoshop, or compatible, available)...


Yep, the Texture Tool has a Generate Mip Maps option on the Format menu. You can then save the texture as a DDS file. The DDS format stores the mip map chain for you.

What's more, the source code to the DirectX Texture Tool comes with the DirectX SDK! - take a look in the Utilities\Source\dxtex folder of DirectX SDK. [smile]

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Quote:Original post by S1CA
Yep, the Texture Tool has a Generate Mip Maps option on the Format menu. You can then save the texture as a DDS file. The DDS format stores the mip map chain for you.

What's more, the source code to the DirectX Texture Tool comes with the DirectX SDK! - take a look in the Utilities\Source\dxtex folder of DirectX SDK. [smile]


I know that I can generate mipmaps from the original image. The question is, can I modify individual mipmaps, so that one size is red, the other blue, or write my name on one of them :), etc.

jollyjeffers's func calls should do it, I'll look into it. But a tool would be nice.
--== discman1028 ==--
To save yourself from future headaches you should not try to bring colored mipmaps to your game with an external tool chain. Write a function that will change the color of already created textures and add a hotkey (or console command) that allows calling it for all textures that you use.

Throwing away mipmaps based on your personal observations is a bad idea. There are too many factors that control the mipmap selection. To make things even more worse there are some that you can’t control. The user can overwrite the filter settings as an example.

If you want to optimize you should provide a “Texture detail” setting and create downscaled versions of your textures. This means that if your texture is 512*512 with the highest setting you should go back to 256*256 if the setting is set one level down.
http://www.codesampler.com/dx9src/dx9src_3.htm#dx9_texture_mipmapping
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
Quote:Original post by Demirug

Throwing away mipmaps based on your personal observations is a bad idea. There are too many factors that control the mipmap selection. To make things even more worse there are some that you can’t control. The user can overwrite the filter settings as an example.

If you want to optimize you should provide a “Texture detail” setting and create downscaled versions of your textures. This means that if your texture is 512*512 with the highest setting you should go back to 256*256 if the setting is set one level down.


My problem is an unusual one: I need to optimize for the size of the release.

And how could the user overwrite the filter settings to request a larger texture than I even have in the mip chain?

Quote:Original post by Demirug
To save yourself from future headaches you should not try to bring colored mipmaps to your game with an external tool chain. Write a function that will change the color of already created textures and add a hotkey (or console command) that allows calling it for all textures that you use.


Can you mofidy the loaded textures within D3D, AFTER having D3D automatically create mipmaps from a large texture? Or must you pre-process the images?

EDIT: Nevermind, the link posted answers this second question. The bolded question above remains though.
--== discman1028 ==--
Quote:Original post by discman1028
My problem is an unusual one: I need to optimize for the size of the release.

And how could the user overwrite the filter settings to request a larger texture than I even have in the mip chain?


If you have already removed it can’t.

It was meant in the other way. It is possible that you test with filter settings that don’t show anything of your larger mipmap. But there could other filter settings that use the larger mipmaps if they are there.
But when you need to trim your distribution size and have already compressed anything to maximum you have not many options left.



Quote:Original post by discman1028
Quote:Original post by S1CA
Yep, the Texture Tool has a Generate Mip Maps option on the Format menu. You can then save the texture as a DDS file. The DDS format stores the mip map chain for you.

What's more, the source code to the DirectX Texture Tool comes with the DirectX SDK! - take a look in the Utilities\Source\dxtex folder of DirectX SDK. [smile]


I know that I can generate mipmaps from the original image. The question is, can I modify individual mipmaps, so that one size is red, the other blue, or write my name on one of them :), etc.

jollyjeffers's func calls should do it, I'll look into it. But a tool would be nice.


Yeah, I probably didn't make my post probably wasn't as clear as I should have.

I was kinda going off Jack's comment about the DirectX Texture Tool being able to generate mips and your comment about doing it in an editor that could save the whole mip chain [smile]

It was more a suggestion that since you already have the source code to the DirectX Texture Tool, you could modify/hack the "Generate Mip Maps" functionality of it to colour in each level of the mip chain. That modification would likely involve using the functions Jack suggested.

It's handy functionality to have, particularly for demonstrating to artists that only, say, the 128x128 mip level of their 2048x2048 masterpiece texture is ever seen in normal game situations [wink]

[Edited by - S1CA on June 14, 2006 6:21:57 PM]

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Quote:Original post by S1CA
Yeah, I probably didn't make my post probably wasn't as clear as I should have.


Same with that sentence! [wink]

Quote:Original post by S1CA
It was more a suggestion that since you already have the source code to the DirectX Texture Tool, you could modify/hack the "Generate Mip Maps" functionality of it to colour in each level of the mip chain. That modification would likely involve using the functions Jack suggested.


That would be a cool improvement... I'll put it in my list things to do. [smile]

Quote:Original post by S1CA
It's handy functionality to have, particularly for demonstrating to artists that only, say, the 128x128 mip level of their 2048x2048 masterpiece texture is ever seen in normal game situations


Exactly why it's useful. [smile]

--== discman1028 ==--

This topic is closed to new replies.

Advertisement