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?

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.


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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to