Two mip-mapping questions

Problems building or running the engine, queries about how to use features etc.
Post Reply
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43
Contact:

Two mip-mapping questions

Post by Oogst »

For The Blob I am using a lot of textures and I have some questions about the mipmapping of those.

The first is about creating different graphics settings. I want a low, medium and high graphics setting and for this I want to lower the texture-resolutions by dropping the highest mipmap of most textures. I took a look at the Texture-class but I do not see anything that hints at how to do this. Can someone give a hint about how to drop the highest mipmap on a texture/several textures easily and on load, so that video memory is not cluttered with the highest mipmap level?

The other question is about loading times. Currently all textures are TGA's and loading takes quite long (something like 15 seconds). Mipmaps are generated on load, so it takes some time at least. What I am wondering about, is whether it would differ a whole lot if I would use DDS-files with pre-created MIPMAP's, or whether the loading time would only get a minor improvement by that.

If DDS's would help greatly, is there some simply way to create materials so that if a DDS is available it is used, but if it is not, the TGA with the same name is used? This way my artists can temporarily use TGA's while working on things.

Thanks in advance!
Last edited by Oogst on Sat May 27, 2006 4:39 pm, edited 1 time in total.
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

1) You would be better to create discrete versions of the texture at each size, and use material schemes to switch between them, for 2 reasons. Firstly, OGRE uses hardware mipmap generation if available (which it is on most modern cards), which means that only the top-level texture is sent to the card anyway, we don't calculate it ourselves. Secondly, the box-filter performed by default mipmap generation isn't the best option, you would be much better to use your image tools to resize the texture using better filters.


2) DDS will be faster in D3D, but not in GL.

3) Easiest way is a find / replace ;)
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43
Contact:

Post by Oogst »

We are not using GL, so the question is only about DX.

If the mipmaps are in the DDS-file, would they still not be sent to the GPU and be generated by the GPU anyway? In that case, what is the use of creating mipmaps by hand anyway?

And with those mipmaps in the DDS, can the loader be told to ignore the highest mipmap-level and not even read it, just go on to the other mipmap-levels? I suppose this should be possible, right? Is it a feature somehow?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Oogst wrote:If the mipmaps are in the DDS-file, would they still not be sent to the GPU and be generated by the GPU anyway?
No, if they're in the DDS they will be used, no regeneration.
And with those mipmaps in the DDS, can the loader be told to ignore the highest mipmap-level and not even read it, just go on to the other mipmap-levels? I suppose this should be possible, right? Is it a feature somehow?
No. DDS is a raw surface dump therefore all of it is loaded or none of it is. You can potentially frig the DDS data before you load it I suppose but it's a lot simpler to do it the way I suggested.
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43
Contact:

Post by Oogst »

I do want to use pre-generated mipmaps to decrease the loading time, which tends to grow to half a minute right now. So DDS is the way to go, I think. Thinking about this, I remember that during my internship at a games studio (as a modeller that was) the loading times went from 2 minutes to 30 seconds when using DDS's instead of TGA's.

I do not want to use too much space for a downloadable game. Would it be possible to create a DDS with only the highest mipmap and a DDS with all the other mipmaps and then put these together in code? This way I could simply use the DDS with all the lower resolutions when the graphics setting is low.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Oogst wrote:I do not want to use too much space for a downloadable game. Would it be possible to create a DDS with only the highest mipmap and a DDS with all the other mipmaps and then put these together in code? This way I could simply use the DDS with all the lower resolutions when the graphics setting is low.
Yes, like I said you'll have to get down & dirty with the DDS format which isn't that much fun, but if you want to....
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43
Contact:

Post by Oogst »

OK, so I cannot ask Ogre to put them together in one texture? In that case this feature will be skipped, because I have only one week left for this project. I suppose I will just be adding DDS for the sake of performance and loading times and not do lower texture resolutions.

A related question: what happens if the GPU does not have enough memory for all the textures? Will they be swapped with AGP-memory, or something else?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Yes, they will be swapped out. I believe the best solution is a low-quality texture mode with pre-shrunk textures using whatever expensive offline filtering mode you need to make them look good.
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43
Contact:

Post by Oogst »

OK, I switched most textures from TGA to DDS with either DXT1 or 5-5-5 or 5-6-5-1. This reduced the memory usage from 220mb to 110mb. :D I did not notice any loading time decrease, though, but that is because too many things where changing at the same time (I am not the only programmer in the team and this was not the only thing I was doing at that moment) and I did not really time stuff.

As for low-res textures: I think I am still going to implement that, because I do not want a 128mb minimum of video memory required. As I do not want to increase download times too much, I think I am just going to make everything halve the resolution and DXT1, which hopefully means downloading size will only increase by some 10mb (ZIPped, that is).
Post Reply