Re: [osg-users] Questions about mip maps
No, OpenGL requires all dimensions to be reduced by half at each level. Sent from my cell phone Aurelien Albert wrote: Thanks a lot for this very precise answer ! Just one more question, you said : > each successive level should be an integer quotient of > the previous level's size and two So, for n-th level, the size should be : (size of n-1 level) / (2*k) with arbitrary k ? Is it possible to have multiple levels with the same size ? For example : Texture : 512x512 Level 1 : 256x256 Level 2 : 256x256 Level 3 : 256x256 Level 4 : 256x256 Level 5 : 128x128 Level 6 : 128x128 Level 7 : 128x128 Level 8 : 128x128 Level 9 : 1x1 Mipmaps levels stop here. I know this is a little weird, but my procedural textures can be generated for any size and any "distance", so in my case tghis should be interesting to have mulitple levels with the same texture resolution, but different "spatial resolution" inside the texture. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51594#51594 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Questions about mip maps
Thanks a lot for this very precise answer ! Just one more question, you said : > each successive level should be an integer quotient of > the previous level's size and two So, for n-th level, the size should be : (size of n-1 level) / (2*k) with arbitrary k ? Is it possible to have multiple levels with the same size ? For example : Texture : 512x512 Level 1 : 256x256 Level 2 : 256x256 Level 3 : 256x256 Level 4 : 256x256 Level 5 : 128x128 Level 6 : 128x128 Level 7 : 128x128 Level 8 : 128x128 Level 9 : 1x1 Mipmaps levels stop here. I know this is a little weird, but my procedural textures can be generated for any size and any "distance", so in my case tghis should be interesting to have mulitple levels with the same texture resolution, but different "spatial resolution" inside the texture. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51594#51594 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Questions about mip maps
On 12/14/2012 07:16 PM, Jason Daly wrote: 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. Actually, this isn't exactly correct. You should create mipmaps until you get to a size with a 1 pixel dimension, and then you should stop, so, for example, a 63x21 texture would have mipmaps of 31x10, 15x5, 7x2, and 2x1 (but not 1x1). --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Questions about mip maps
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