Re: [osg-users] what should I dirty when I change ColorArray on the fly?
Hi Claudio, it depends how your Geometry is setup. You might need to call osg::Geometry->dirtyDisplayList() or if you use VertexBufferObjects you might need to call colorArrays->getBufferObject()->dirty() On Mon, Oct 14, 2019 at 11:16 PM Claudio Benghi wrote: > Hello All, > > I have implemented a colour change visitor along the lines of the class > found at: > http://www.vis-sim.com/osg/code/osgcode_color1.htm > > While debugging I note that the following code is executed, including the > colorArrays->dirty(), but the colour in the render is not affected. > > Could it depend from the way in which the colorArray is initialliy > instantiated? > Should I mark some state as Dynamic? > > > Code: > > void XbimNodeColorVisitor::apply(osg::Geometry ) > { > osg::Vec4Array *colorArrays = dynamic_cast *>(curGeom.getColorArray()); > if (colorArrays) { > for (unsigned int i = 0; i < colorArrays->size(); i++) { > osg::Vec4 *color = >operator [](i); > color->set(m_color._v[0], m_color._v[1], m_color._v[2], > m_color._v[3]); > } > colorArrays->dirty(); > } > else { > // code never enters this path > } > } > > > > > > Thank you! > > Cheers, > Claudio > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=76829#76829 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] what should I dirty when I change ColorArray on the fly?
Hi again, I think I've solved my issue. I've worked out that BufferObject::dirty() does not yield a result because _glBufferObjects[i].valid() is false. This is probably because I was not using VBOs on those geometries. If I create the geometry with setUseVertexBufferObjects(true) the code works. Otherwise I've found that curGeom.dirtyDisplayList(); updates the geometry if setUseVertexBufferObjects() is not invoked. Just writing it here in case it helps somebody else. Thank you! Cheers, Claudio -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76830#76830 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] what should I dirty when I change ColorArray on the fly?
Hello All, I have implemented a colour change visitor along the lines of the class found at: http://www.vis-sim.com/osg/code/osgcode_color1.htm While debugging I note that the following code is executed, including the colorArrays->dirty(), but the colour in the render is not affected. Could it depend from the way in which the colorArray is initialliy instantiated? Should I mark some state as Dynamic? Code: void XbimNodeColorVisitor::apply(osg::Geometry ) { osg::Vec4Array *colorArrays = dynamic_cast(curGeom.getColorArray()); if (colorArrays) { for (unsigned int i = 0; i < colorArrays->size(); i++) { osg::Vec4 *color = >operator [](i); color->set(m_color._v[0], m_color._v[1], m_color._v[2], m_color._v[3]); } colorArrays->dirty(); } else { // code never enters this path } } Thank you! Cheers, Claudio -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76829#76829 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem reading unclamped float values and non-standard internal formats PBO
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. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org