Hi,
I'm having a small issue with the osgText::Text that I can't figure out.
There is difference in how bright the text looks when I compare a osgText::Text
drawn on screen, and the same one, but then drawn on a framebuffer, and then
(the buffer) drawn on screen. Should be exactly the same right, if the bg color
is the same?
I attached a small part of a screenshot to show the difference. Other things
that I draw on the framebuffer do not appear darker, so it seems to be related
to osgText::Text.
Here are some parts of the code:
camera for gui on screen:
Code:
osg::ref_ptr<osg::Camera> camera = new osg::Camera();
camera->setViewport(new osg::Viewport(0,0,width,height));
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
camera->setRenderOrder(osg::Camera::POST_RENDER,0);
camera->setProjectionMatrixAsOrtho2D(0,width,height,0);
//camera->setViewMatrix(camera->getViewMatrix() *
osg::Matrixd::scale(1,-1.f,1));
camera->getOrCreateStateSet()->setMode(GL_BLEND,
osg::StateAttribute::ON); //blend
camera->getOrCreateStateSet()->setMode(GL_DEPTH_TEST,
osg::StateAttribute::OFF);
camera->getOrCreateStateSet()->setMode(GL_ALPHA_TEST,
osg::StateAttribute::OFF);
camera->getOrCreateStateSet()->setMode(GL_LIGHTING,
osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
camera->getOrCreateStateSet()->setMode(GL_FOG,
osg::StateAttribute::OFF);
camera for rendering to a framebuffer:
Code:
osg::ref_ptr<osg::Camera> camera = new osg::Camera();
camera->setViewport(new osg::Viewport(0,0,width,height));
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setClearColor(osg::Vec4(0,0,0,0));
camera->setRenderOrder(osg::Camera::PRE_RENDER,0);
camera->setProjectionMatrixAsOrtho2D(0,width,height,0);
camera->getOrCreateStateSet()->setMode(GL_BLEND,
osg::StateAttribute::ON); //blend
camera->getOrCreateStateSet()->setMode(GL_LIGHTING,
osg::StateAttribute::OFF);
camera->getOrCreateStateSet()->setMode(GL_DEPTH_TEST,
osg::StateAttribute::OFF);
camera->getOrCreateStateSet()->setMode(GL_ALPHA_TEST,
osg::StateAttribute::OFF);
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0),
texture);
texture used for framebuffer:
Code:
osg::ref_ptr<osg::TextureRectangle> rect = new osg::TextureRectangle;
rect->setTextureSize(width, height);
rect->setInternalFormat(GL_RGBA32F_ARB);
rect->setSourceFormat(GL_RGBA);
rect->setSourceType(GL_FLOAT);
rect->setFilter(osg::TextureRectangle::MIN_FILTER,osg::TextureRectangle::NEAREST);
rect->setFilter(osg::TextureRectangle::MAG_FILTER,osg::TextureRectangle::NEAREST);
quad used to render the framebuffer onscreen:
Code:
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
geode->getOrCreateStateSet()->setMode(GL_LIGHTING,
osg::StateAttribute::OFF);
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
geom->setSupportsDisplayList(false);
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
osg::ref_ptr<osg::Vec2Array> texcoords = new osg::Vec2Array;
vertices->push_back(osg::Vec3d(0,0,0));
texcoords->push_back(osg::Vec2(0,height));
vertices->push_back(osg::Vec3d(0,height,0));
texcoords->push_back(osg::Vec2(0,0));
vertices->push_back(osg::Vec3d(width,height,0));
texcoords->push_back(osg::Vec2(width,0));
vertices->push_back(osg::Vec3d(width,0,0));
texcoords->push_back(osg::Vec2(width,height));
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
colors->push_back(color);
geom->setVertexArray(vertices);
geom->setTexCoordArray(0,texcoords);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::QUADS,0,vertices->size()));
geode->addDrawable(geom);
Does anyone have an idea what could cause this? I've looked at the source of
osgText::Text, but it seems very complicated, and it also uses a custom
rendering so it doesn't seem to be affected much by the render states (for
example I don't think you can turn blending off trough the stateset when
rendering text?), so I have no clue at this point...
Thank you!
Cheers,
Bram
Code:
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60357#60357
Attachments:
http://forum.openscenegraph.org//files/textproblem_940.png
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org