[osg-users] Texture not clear in far view

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Sun Sep 7 10:46:37 PDT 2008


Hello Fangqin,

> As you can see, in the first picture, the texture of building is not 
> clear. It is not quite far. The texture performance is not acceptable. 
> But when you get a little closer, it becomes better (the second picture).
> Is this because of not setting mip-map?

No, you are using mip mapping since the texture changes (and I bet you 
can see where the texture changes by moving slowly closer to the 
building - it will switch mip levels all of a sudden). Anyways, mip 
mapping is on by default.

Mipmaps are built from textures automatically by OSG when they are 
needed, using GLU functions. The problem is that the resuling mipmap 
levels generally have too much filtering/blurring. So what you can do is 
generate mip levels yourself using an image processing tool to resize 
and filter the images using a higher quality filtering algorithm, and 
store the texture with its precomputed mip levels in a DDS texture. This 
way you have control over the appearance of your texture at every mip 
level. There may even be a class in the osgUtil::Optimizer or somewhere 
else to do this, I don't remember.

You could also try to enable anisotropic filtering to see if it makes 
things better. In general it will, but you'll have to try it out 
yourself (for example, by using osgUtil::Optimizer::TextureVisitor to 
set the anisotropy parameter to something like 16 - try out some 
different values to see what works for you). This however takes a bit 
more time on the GPU, but not that much on modern cards.

Obviously, generating the mip levels yourself in a DDS texture as 
described above gives you more control and takes no extra GPU time at 
runtime, but takes some time upfront to generate them and find the right 
settings. Conversely, using anisotropic filtering takes some time on the 
GPU, but does not require any changes to your art pipeline and no time 
upfront apart from finding the right settings for each texture (unless 
you're happy just setting them all at 16).

Hope this helps. Sorry for rambling.

J-S
-- 
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/



More information about the osg-users mailing list