Hi,

I now managed to get true float values out of the render buffer by
specifying
>>      image = new osg::Image;
>>      image->allocateImage(width, height, 1, GL_RGB, GL_FLOAT);
>>      image->setInternalTextureFormat(GL_RGB32F_ARB);
>>      viewer->getCamera()->attach(osg::Camera::COLOR_BUFFER, image.get());

But the values are still clamped to 1.0. Any idea to get around that?

regards Ralph

Ralph Kern schrieb:
> hi folks,
> 
> I'm looking for some way to get unclamped floating point values out of a
> render buffer. My goal is to produce HDRI images.
> 
> I can fetch the image as rgb byte pixels, but I'm wondering how to get
> float values which may be greater than 1.0.
> 
> I'm working on a ATI Radeon X1600.
> 
> My current framework is like that:
> 
>> int width = 512;
>> int height = 512;
>> osg::ref_ptr<osg::GraphicsContext::Traits> traits = new 
>> osg::GraphicsContext::Traits;
>> traits->x = 0;
>> traits->y = 0;
>> traits->width = width;
>> traits->height = height;
>> traits->windowDecoration = false;
>> traits->doubleBuffer = false;
>> traits->sharedContext = 0;
>> traits->pbuffer = true;
>>
>> osg::ref_ptr<osg::GraphicsContext> gc = 
>> osg::GraphicsContext::createGraphicsContext(traits.get());
>>
>> if (!gc.valid())
>> {
>>      osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to 
>> normal graphics window."<<std::endl;
>>
>>      traits->pbuffer = false;
>>      gc = osg::GraphicsContext::createGraphicsContext(traits.get());
>> }
>>
>> if (gc.valid()) 
>> {
>>      gc->realize();
>>      gc->makeCurrent();
>>      osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
>>      viewer->getCamera()->setGraphicsContext(gc.get());
>>      viewer->getCamera()->setViewport(0,0,width,height);
>>      viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
>>
>>      // Init the main Root Node/Group
>>      osg::ref_ptr<osg::Group> _root = new osg::Group;
>>      osg::Shape *shape = new osg::Cylinder(Vec3f(0.5,0.5,-0.5), .4, .2);
>>      osg::ShapeDrawable *drawable = new osg::ShapeDrawable(shape);
>>      drawable->setColor(Vec4(1,1,0,1));
>>      osg::Geode *geode = new osg::Geode();
>>      geode->addDrawable(drawable);
>>
>>      _root->addChild(geode);
>>      _root->getOrCreateStateSet()->setMode(GL_LIGHTING, 
>> osg::StateAttribute::OFF);
>>
>>      viewer->setSceneData(_root.get());
>>
>>      image = new osg::Image;
>>      image->allocateImage(width, height, 1, GL_RGB, GL_UNSIGNED_BYTE);
>>      viewer->getCamera()->attach(osg::Camera::COLOR_BUFFER, image.get());
>>      
>> viewer->getCamera()->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
>>      viewer->getCamera()->setClearColor(Vec4(.7,0,0,0));
>>      viewer->getCamera()->setProjectionMatrixAsOrtho(0, 1, 0, 1, 0, 1);
>>      viewer->getCamera()->setViewMatrix(matrix);
>>
>>      viewer->frame();
>>      viewer->getCamera()->detach(osg::Camera::COLOR_BUFFER);
>>
>>      osgDB::writeImageFile(*image,std::string("C:\\tmp\\buffer.tif", NULL);
>> }
> 
> 
> regards Ralph Kern
> 

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

Reply via email to