Hi, Robert. I'll try to explain my intentions. I develop Mahjong game ( http://opengamestudio.org/wp-content/gallery/ogs-mahjong/mj-bin-2012-09-10-20-35_1.png). To create tiles on the table, I use single Tile.mesh and several Texture.png files. Since Mahjong rules require 43 different tiles, I need 43 textures. Also, one can switch among different tile themes. Those are currently organized simply as directories of textures, so you can imagine the file bloat when there are 3 themes: it's 43 * 3 = 129 files! I want to have a single tile theme texture (atlas) which will contain all 43 textures.
Do I understand correctly that I should do something like that: // Reading atlas. std::vector<osg::Texture2D*> textures = readMyAtlasFile(fileName); osgUtil::Optimizer::TextureAtlasBuilder atlasBuilder; for (each texture) atlasBuilder.addSource(texture); // Using atlas. for (i in atlasBuilder) tileNodes[i]->getOrCreateStateSet()->setTextureAttributeAndModes(0, atlasBuilder.getSourceTexture(i)); Is it so? Thanks. 2013/2/15 Robert Osfield <robert.osfi...@gmail.com> > Hi Michael, > > There really isn't much to do with texture atlas once you have built > the scene graph - the osg::Geometry and osg::Texture/osg::Image you > use are all the same type as you'd use for none texture atlas usage, > the only difference is the contents of the osg::Image and the texture > coordinates used on the osg::Geometry. You can create and save out > texture atlas and associated geometry just as normal OSG scene graphs. > > Texture atlases are useful for enabling one to group all the geometry > and imagery together for particular objects together as a single unit, > for instance a house rendered with separate textures for each of the > walls and the roof would require 5 images, 5 textures and 5 > geometries, while a texture atlas would allow you to use a single > image, single texture and a single geometry. As CPU overhead of cull > and draw is often a bottleneck then merging 5 sets of state and > geometry into a single unit can be a big saving. If you aren't CPU or > GPU batch limited then using a texture atlas will help very little. > > Robert. > > On 14 February 2013 09:23, michael kapelko <korn...@gmail.com> wrote: > > Hi. > > I want to be able to have to specify several textures which will be > mapped > > using the same UV, a collection of textures. > > I want to put them into a single file, texture atlas. > > I've grepped OSG examples on 'tlas' word. Didn't find any example. > > I've googled for OSG atlas and only found > > osgUtil::Optimizer::Optimizer::TextureAtlasBuilder. > > As I understood, I can only build a runtime atlas (not save it) with OSG > > from separate textures. > > Can I use the builder to create an OSG texture atlas from my atlas file? > > Will OSG texture atlas usage reduce draw calls/increase draw performance? > > Thanks. > > > > _______________________________________________ > > 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 >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org