Hi Sebastian
2012/10/30 Sebastian Messerschmidt <sebastian.messerschm...@gmx.de> > Hello, > > I'm trying to implement an advanced HDR lighting algorithm where I need > the average luminance of the last frame(s). > Currently I've encountered two major problems: > > 1. Is there a possibility to get only the last mipmap-level from > texture/image bound to a FBO? > I can get the whole image via readImageFromCurrentTexture in a > postDrawCallback, but this unfortunately copies the complete texture. > Looking at the code, I see that all mipmap levels are copied, and my > question is if it would be feasible to either create a special function to > copy only a specific mipmap-level or add an additional parameter to the > function to specifiy the mipmap level? > I don't see any code in OSG to just read specific mipmap level, but with "readImageFromCurrentTexture" code as model, this will not be difficult to do appropriate function. > 2. I have trouble getting correct values from floating point buffers. It > works if get the values as GL_UNSIGNED_BYTE (the values are indeed scaled > to 0 -255) but this, of course, won't be precise enough as the buffer holds > the logarithmic luminance. check this : - be sure to bind correct texture in Texture 0 : state->applyTextureAttribute(0, myTextureToRead); - be sure to active correct Texture Unit : state->setActiveTextureUnit(0); - be sure current texture have FLOAT internal Type : osg::Image::computeFormatDataType(myTextureToRead->getInternalFormat()) == GL_FLOAT And when you did double data = *image->getMipmapData(0); you read the buttom left pixel of the complet image, average luminance is in the last mipmap level double averageLuminance = *reinterprete_cast<double*>( image->getMipmapData(image->getNumMipmapLevels() - 1) ); HTH David Below you find a snippet of my PostDrawCallback, maybe I'm doint something > fundamentally wrong. > I'm running on OSG 3.0.1. > > virtual void operator () (osg::RenderInfo& render_info) const > { > //state->apply(render_info.**getCurrentCamera()->**getStateSet()); > //state->**applyTextureAttribute(0,**mTexture); > //mTexture->apply(*state); > osg::ref_ptr<osg::Image> image=new osg::Image(); > mTexture->getImage()->**readImageFromCurrentTexture(** > render_info.getContextID(),**true, GL_UNSIGNED_BYTE); //works , doesn't > work with GL_FLOAT > double data = *image->getMipmapData(0); > std::cout << "luminance " << data << std::endl; > //osgDB::writeImageFile(***image,"snap.bmp"); > } > > > cheers > Sebastian > > ______________________________**_________________ > osg-users mailing list > osg-users@lists.**openscenegraph.org <osg-users@lists.openscenegraph.org> > http://lists.openscenegraph.**org/listinfo.cgi/osg-users-** > 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