On 12/14/2012 06:08 PM, Aurelien Albert wrote:
Hi,

I have a set of pre-computed procedurals textures, and my texture generation 
system can produce high-quality downsampled textures.

So I would like to use them as mipmaps for my textures :

- is it possible to allocate and load mipmaps from CPU, just like we load an 
osg::Image into an osg::Texture2D ?

Yes. As far as I know, the way to do it is to pass the entire set of images (with the mipmaps) to osg::Image::setData(), then call osg::Image::setMipmapLevels() with a vector indicating the byte offset to the start of each of the mipmaps.


- is there any example of that ?

The only example I know of off the top of my head is in the DDS plugin (search for the call to setMipmapLevels to see where). There are probably others, too.


- is it mandatory that each mipmap level is exactly half size of the previous ?

Not exactly, but each successive level should be an integer quotient of the previous level's size and two. They don't need to be powers of two either, as long as you're targeting relatively recent hardware.

Essentially, you take the floor of size/2 to get the size of the next level. Say you start with a size of 999. The mip levels would then be 499, 249, 124, 62, 31, 15, 7, and 3.

The textures also don't need to be square. The mip levels stop when any of the dimensions reaches 1, so you shouldn't create any mipmaps that are, for example, 4x1.

Hope this helps!

--"J"
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to