Hi,

I have implemented the global tonemapping operator (Reinhard). For this task I 
use a downsampling pass which downsamples the input texture (with log luminance 
per pixel) to a 1x1 texture computing the avarage log luminance of the input 
texture. The next step, I try to do, is to copy the avarage log luminance from 
the 1x1 texture from the GPU to an array in the main application. I have to 
store the average log luminance for the last n frames. These values can then be 
used to compute the adaptive temporal tonemapping. 



Code:

// first create the 1x1 output texture for the avarage log luminance
osg::ref_ptr<osg::Texture2D> tmLogLumAvarageTex = new osg::Texture2D();
tmLogLumAvarageTex->setTextureSize(1, 1);
tmLogLumAvarageTex->setInternalFormat(GL_LUMINANCE16F_ARB);
tmLogLumAvarageTex->setSourceFormat(GL_RGBA);
tmLogLumAvarageTex->setSourceType(GL_FLOAT);

// downsampling pass
// ....

// capture the state set from the final downsampling pass
osg::ref_ptr< osg::StateSet > currentStateSet = new osg::StateSet();
currentStateSet = 
tmTexDownSampPass->getPassByIndex(tmTexDownSampPass->getNumOfPasses()-1)->getCamera()->getStateSet();
// capture the state from the final downsampling pass' state set
osg::ref_ptr< osg::State > currentState = new osg::State();
currentState->captureCurrentState(*currentStateSet);

float pixelData[4];

// create pixelbuffer object to copy the content from texture 
// and copy the buffer's content to a data pointer
osg::PixelDataBufferObject* pdbo = new osg::PixelDataBufferObject();
// bind buffer in write mode and copy texture content into the buffer (write to 
buffer)
pdbo->bindBufferInWriteMode(*currentState); // GL_PIXEL_PACK_BUFFER_ARB
currentState->applyTextureAttribute(/*unit*/ 0, /*texture*/ 
tmLogLumAvarageTex.get()); 
        // copy content from texture to the pbo 
        glGetTexImage(GL_TEXTURE_2D, 0, GL_LUMINANCE16F_ARB, GL_FLOAT, 
pixelData);
pdbo->unbindBuffer(currentState->getContextID()); 





The screen stays black and I get the following message when I run my program:
"Warning: TextureRectangle::apply(..)  failed, texture rectangle is not support 
by your OpenGL drivers"

Please help!!!

Thank you!

Cheers,
Dan

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=36103#36103





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to