PDA

View Full Version : mipmap generation with out glu?



doodlemunch
02-24-2006, 01:53 PM
hi is it possibel to generate mipmaps fast with out glu32 ?? any exampels i can use to learn from?

thanks

dorbie
02-24-2006, 02:03 PM
Yes you can simply do a box sum if you like. I've actually used Photoshop to generate all images from my original with a bicubic filter and loaded all levels from disk, not fast but not particularly slow considering the time to load a single level anyway. And you'll find that quality is high and the gamma of your display is built into the downsize filter thanks to photoshop's correct treatment of color space(something everyone unfortunately ignores).

doodlemunch
02-24-2006, 05:00 PM
hi thank you dorbie!!!!!
one last question (I hope its the last one :)

is it possibel to use a thread to do this stuff? or even to upload the mipmaps once they are processed? because i want something fast but with nice quality

i can do nearest nighboor and manage to get some fair results but well i dont know much about gl commands yet :( so i wouldnt know how to upload the mipmaps!

also how can i set the main texture level ? for example if i wanted to render half amount of texels i'd pass the first level to be the second one right? like displaying the first mipmap as the base layer ... ?

am i explaining myself correcty? or at least letting you guys know what i mean? it is hard for me to talk about this things :(

shelll
02-25-2006, 04:36 AM
you can try sgis_generate_mipmap (http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt)

doodlemunch
02-25-2006, 07:47 AM
thank you bud.
However is this supportet by all cards?
I want the fast way for making nice mipmaps and also the way that would work if the other fast method wouldnt.. how wuld you go for that? just asking need help thx

dorbie
02-25-2006, 09:58 PM
Well you may need some fallback if you used that method (glu if the extension isn't reported?) but it's supported on a whole bunch of cards:

http://www.delphi3d.net/hardware/extsupport.php?extension=GL_SGIS_generate_mipmap

Many cards just fallback to software for this so it's easy to support which is probably the reason there is broad support, but some will accelerate it in hardware and that's a good philosophy; the cards and drivers that do a good job get a chance to run a bit faster than other cards which don't. They also get to implement quality features if they're smart, like appropriate filters and color space conversions in and out of their filter arithmetic (I doubt any of them are that smart).

Understand that when you use this feature you're rewarding the companies who do a good job implementing the feature, and the customers who buy those cards, with the potential for a small performance boost when running your software.

doodlemunch
02-26-2006, 07:00 AM
But am I cursing the other people with cheaper cards? would it run slower than glu routines?

Thansk for your explaination now im willing to try this out a little more :)

shelll
02-26-2006, 09:54 AM
it has also big advantage, that when you change the texture on the fly, mipmaps will be also changed automatically :)

it should be fast, but when falling bakc to SW, it could be slower then GLU..

doodlemunch
02-26-2006, 05:27 PM
no one ever did an actual benchmark though?

dorbie
02-26-2006, 09:16 PM
Why would their experience be worse (cursed)? You have a fallback MIP map generator that will be as good as your current options without the extension. There's no magic bullet.

Feel free to measure performance.

V-man
02-27-2006, 06:24 AM
it has also big advantage, that when you change the texture on the fly, mipmaps will be also changed automatically huh?


it should be fast, but when falling bakc to SW, it could be slower then GLU..Depends on what algorithm the driver uses in software.
The glu that comes with Windows is very slow.
Most likely the driver will beat it.

doodlemunch
02-27-2006, 07:54 AM
Well then using GLU is a no-go compared to this method? but if the extension is not existant how can i still use this ?? possible ?!? or i should really go to glu in that case?

just lots of questions ive got :(

V-man
02-27-2006, 09:08 PM
What's the problem?

If GL 1.4 or more is supported, then this feature is core. If GL_SGIS_generate_mipmap is supported, then you can still use it.

All you have to do...


bool IsAutomaticMipmapSupported;

if(GLVersion>="1.4")
{
IsAutomaticMipmapSupported=true;
}
else if(extensionList=="GL_SGIS_generate_mipmap")
{
IsAutomaticMipmapSupported=true;
}
else
{
IsAutomaticMipmapSupported=false;
}When you want to load a texture



glBindTexture(GL_TEXTURE_2D, textureID);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ....);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ....);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
if(IsAutomaticMipmapSupported==true)
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

glTexImage2D(....);
}
else
{
gluBuild2DMipmaps(.....)
}As you can see, if automipmaps is supported, then it gets used, else we fall back to GLU.