I've gone through the archives and thought I had done the right thing, but
I still get clamped values.
The osgscreencaptuer example uses pbuffers in a unique way (not simply as a
camera setRenderTargetImplementation). I'm wondering if there's something
special about how they're being used.
Here are the highlights:
// image creation
image = new osg::Image;
image->setInternalTextureFormat(GL_RGBA32F);
image->allocateImage(w, h, 1, GL_RGBA, GL_FLOAT);
// disable clamping
osg::ClampColor* clamp = new osg::ClampColor();
clamp->setClampVertexColor(GL_FALSE);
clamp->setClampFragmentColor(GL_FALSE);
clamp->setClampReadColor(GL_FALSE);
sceneroot->getOrCreateStateSet()->setAttribute(clamp,
osg::StateAttribute::ON |
osg::StateAttribute::OVERRIDE |
osg::StateAttribute::PROTECTED);
// write float data in fragment shader
uniform float val;
gl_FragData[0] = vec4(val,val,val,val);
// read pbuffer
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo);
glReadPixels(0, 0, w, h, GL_RGBA, GL_FLOAT, 0);
src = ext->glMapBuffer(GL_PIXEL_PACK_BUFFER,GL_READ_ONLY);
// copy to image
memcpy(image->data(), src, image_size);
ext->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
Thanks,
Brian
[email protected] wrote: -----
To: [email protected]
From: "Art Tevs" <[email protected]>
Sent by: [email protected]
Date: 07/24/2009 04:39PM
Subject: Re: [osg-users] osgscreencapture offscreen rendering - clamping
floats
Hi Brian,
yes, you need to disable the OpenGL color value clamping. This can be done
by this, I think:
Code:
// disable color clamping, because we want to work on real hdr values
osg::ClampColor* clamp = new osg::ClampColor();
clamp->setClampVertexColor(GL_FALSE);
clamp->setClampFragmentColor(GL_FALSE);
clamp->setClampReadColor(GL_FALSE);
// make it protected and override, so that it is done for the whole
rendering pipeline
node->getOrCreateStateSet()->setAttribute(clamp,
osg::StateAttribute:ShockedN |
osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED);
cheers,
art
Brian R Hill wrote:
> Folks,
>
> I've been working with the osgscreencapature example to use pbuffers for
> offscreen rendering. I'm having a problem with floating point values
being
> clamped [0.0 - 1.0].
>
> Any ideas on how to turn the clamping off?
>
> Brian
>
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=15426#15426
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org