[osg-users] RTT using slave cameras (osgfpdeth example)
Hello, I'm trying to learn the intracacies of rendering to textures using osg, and I've dissected the osgfpdepth example to do it. I've been largely successful at resolving the code into a much simpler example for rendering using the color buffer only. Anyway, my goal was to have both the main camera and the RTT camera rendering the same geometry. The RTT camera, of course, would have different state in it's path that would create a different effect on the geometry. However, it seems the osgfpdepth example isn't set up to do this. That is, depth buffering is enabled on the root node with the code: Code: osg::Depth* depth = new osg::Depth( osg::Depth::GEQUAL, 1.0, 0.0); sceneSS->setAttributeAndModes(depth,(osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE)); Why depth buffering has to be enabled for the slave camera to render-to-texture I'm not sure, but I do know that doing so means the geometry isn't rendered by the main camera view. That is, either the main camera or the RTT camera renders the geometry, but not both. Thus the need to create a second texture slave camera to render the RTT output to the screen. Given that I'm new to render-to-texture methods and techniques, I've no doubt there's some obvious reasoning that I've missed. Nevertheless, I'd appreciate any comments that might illuminate the issue. Thanks, Joel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48005#48005 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Set Viewport background color as transparent
Hello Vishwa, Can you please elaborate what you are trying to achieve? You can set the viewers camera's clear color with an alpha value less than one. (.setClearColor(r,g,b,a)) But I (and possibly others) don't understand what you are trying to do with this, as the background is basically drawn first (i.e. the viewport is set to this color). cheers Sebastian Am 02.06.2012 13:30, schrieb shekhar vishwa: Hi, I am using the OSG, but I unable to set the viewport or view backgraund color as transparent. Please help me to resolve this issue. Thanks Vishwa ___ 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] Set Viewport background color as transparent
Hi, I am using the OSG, but I unable to set the viewport or view backgraund color as transparent. Please help me to resolve this issue. Thanks Vishwa ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] dotosg wrappers not thread safe
Hi, I noticed crashing in dotosg wrappers when try to use osgDB::readNodeFile from multiple threads. Crash occurs when I try to load .osg file from two threads. For example callstack of crashed thread: osg80_osgDB!concrete_wrapper::matches+0x4 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x527 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x28 osgdb_deprecated_osg!Drawable_readLocalData+0xa1 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readDrawable+0xe1 osgdb_deprecated_osg!Geode_readLocalData+0x90 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1 osgdb_deprecated_osg!Group_readLocalData+0x71 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1 osgdb_deprecated_osg!Group_readLocalData+0x71 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1 osgdb_osg!OSGReaderWriter::readNode+0xfe osgdb_osg!OSGReaderWriter::readNode+0x31c osg80_osgDB!osgDB::Registry::ReadNodeFunctor::doRead+0x28 osg80_osgDB!osgDB::Registry::read+0x5e4 osg80_osgDB!osgDB::Registry::readImplementation+0x34c osg80_osgDB!osgDB::Registry::readNodeImplementation+0x6a osg80_osgDB!osgDB::Registry::readNode+0xfc osg80_osgDB!osgDB::readNodeFile+0x4e [...] second thread callstack: msvcp90!std::basic_istream msvcp90!std::basic_istream osg80_osgDB!osgDB::FieldReader::_readField+0x3f8 osg80_osgDB!osgDB::FieldReaderIterator::field+0x19d osgdb_deprecated_osg!Array_readLocalData+0xbfb osgdb_deprecated_osg!Geometry_readLocalData+0x991 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readDrawable+0xe1 osgdb_deprecated_osg!Geode_readLocalData+0x90 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1 osgdb_deprecated_osg!Group_readLocalData+0x71 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1 osgdb_deprecated_osg!Group_readLocalData+0x9a osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1 osgdb_deprecated_osg!Group_readLocalData+0x9a osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1 osgdb_deprecated_osg!Group_readLocalData+0x71 osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1 osgdb_osg!OSGReaderWriter::readNode+0xfe osgdb_osg!OSGReaderWriter::readNode+0x31c osg80_osgDB!osgDB::Registry::ReadNodeFunctor::doRead+0x28 osg80_osgDB!osgDB::Registry::read+0x5e4 osg80_osgDB!osgDB::Registry::readImplementation+0x34c osg80_osgDB!osgDB::Registry::readNodeImplementation+0x6a osg80_osgDB!osgDB::Registry::readNode+0xfc osg80_osgDB!osgDB::readNodeFile+0x4e [...] code: struct concrete_wrapper: basic_type_wrapper { virtual ~concrete_wrapper() {} concrete_wrapper(const osg::Object *myobj) : myobj_(myobj) {} bool matches(const osg::Object *proto) const { return myobj_->isSameKindAs(proto); (obj); static ref_ptr s_drawstate = new osg::StateSet; if (StateSet* readState = static_cast(fr.readObjectOfType(*s_drawstate))) { drawable.setStateSet(readState); iteratorAdvanced = true; } [...] so problem is in static ref_ptr s_drawstate = new osg::StateSet; MSVC 2008 x64 compiler (maybe gcc too) generate this code as: static bool s_drawstate_init = false; static ref_ptr s_drawstate = NULL; bool Drawable_readLocalData(Object& obj, Input& fr) { bool iteratorAdvanced = false; Drawable& drawable = static_cast(obj); if(!s_drawstate_init) { s_drawstate_init = true; s_drawstate = new osg::StateSet; } if (StateSet* readState = static_cast(fr.readObjectOfType(*s_drawstate))) { drawable.setStateSet(readState); iteratorAdvanced = true; } [...] and this code is not thread safe as you can see. Possible solution is to move static variables to global scope to avoid lazy initialization. Mikhail. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org