Hi all,
On my quest to reduce the amount of statesets and draw calls in my
graph, I've started building texture atlases with the
osgUtil::Optimizer::TextureAtlasVisitor. Now, when I build the texture
atlas(es) for a given model, I then save a .ive file of that model which
includes the textures, and thus the atlas(es) too. So far so good.
Unfortunately, I'm seeing an issue in our simulator that looks like OSG
is using the same texture atlas for any model that uses texture atlases
(i.e. the first texture atlas that was loaded is applied to any model
that uses texture atlases). Indeed, if I dump the scene to a .osg file
and examine it, I can see that there's one state set with a texture
called "atlas_0.rgb", and then all other objects have "Use Texture2D_20"
in their state sets, where Texture2D_20 is that atlas.
I had noticed that osgUtil::Optimizer::TextureAtlasVisitor named its
atlases atlas_0.ext, atlas_1.ext etc., but I thought that since I was
saving to .ive there would be no problem, it would use the texture from
the file when loading and all would be fine. What's weird is that I
can't reproduce the problem in plain osgViewer - the textures are not
mixed up if I load the .ive files (with atlases) all together in
osgviewer. So it must be something in our app.
To try and eliminate this, I disabled our use of the
osgDB::SharedStateManager and our ReadFileCallback that would cache
loaded files and share them. So now, all files should be loaded from
disk and state should not be shared between files. But still this
problem happens.
I debugged into the ive loader's loading of images, and it seems to be
loading them directly from the bits of the loaded file, so I don't see
how the textures could be shared...
Did anyone ever have this kind of problem? Where else could I look to
find the problem? Will OSG or the ive loader do any sharing of loaded
resources by itself?
I guess I could do a kludge where I would traverse the graph just before
saving, and add a model-dependent prefix to the filename of any image
named atlas_*.* ... But since this works out of the box in osgviewer,
I'd like to find out why it doesn't work in our app and fix it
correctly... :-)
Thanks in advance,
J-S
--
______________________________________________________
Jean-Sebastien Guay [email protected]
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org