[osg-users] Problem reading unclamped float values and non-standard internal formats PBO
Omar Álvarez
omar.alvarez at cinfo.es
Mon Oct 14 07:19:56 PDT 2019
Hi,
I am trying to render to texture and read the results with an osg::Image.
When I use standard internal formats like GL_RGB it works ok. The problem
appears when I try to for example use GL_FLOAT with GL_RGB16, etc.
When I get my image back the internal format is not what I want (the one
that I set up in the texture) and I see errors like:
error pixelFormat = 805b
ContextData::incrementContextIDUsageCount(0) to 2
Warning: detected OpenGL error 'invalid value' at after
stateset.compileGLObjects in GLObjectsVisitor::apply(osg::StateSet&
stateset)
Here is my PBO setup code:
osg::Camera::RenderTargetImplementation renderTargetImplementation
= renderTargetImplementation = osg::Camera::PIXEL_BUFFER;
_camera->setName(label);
// viewport set in configure() method
_camera->setClearColor(osg::Vec4(0., 1., 1., 1.));
_camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
_camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
_camera->setRenderOrder(osg::Camera::POST_RENDER);
_camera->setRenderTargetImplementation(renderTargetImplementation);
_camera->setViewport(new osg::Viewport(0,0,viewport_size.x(),
viewport_size.y()));
_camera->getOrCreateStateSet()->setAttribute(new
osg::ClampColor(GL_FALSE, GL_FALSE, GL_FALSE),
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE |
osg::StateAttribute::PROTECTED);
// Render to texture
_texture = new osg::Texture2D();
_texture->setTextureSize(viewport_size.x(), viewport_size.y());
_texture->setInternalFormat(GL_RGB16);
_texture->setSourceType(GL_FLOAT);
_texture->setSourceFormat(GL_RGB);
_texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::NEAREST);
_texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::NEAREST);
_texture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE);
_texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE);
_texture->setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP_TO_EDGE);
// attach the texture and use it as the color buffer.
_camera->attach(osg::Camera::COLOR_BUFFER, _texture);
I am also having trouble with clamped values, when it does work, values are
clamped in the range [0,1] although I have disabled clamping.
Anyone knows how to setup a PBO to read unclamped values in non-standard
formats (GL_RGBUI16, GL_RGB16F...)?
Is this supported in OSG?
Cheers,
Omar.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20191014/1be2b750/attachment.html>
More information about the osg-users
mailing list