Re: [osg-users] How to disable Antialiasing of an osg::Text
Hi Lv, It looks like you are position the text in a 3D scene and leaving it to scale in object coordinates, which is fine, but it does mean that the scale will and orientation will vary, this is very different challenge for rendering clear text than rendering a fixed font to a fixed 2D projection like you have with a typical Qt application. You simple can't compare fonts working in 3D and 2D domains. That aside to get the best quality of text in a 3d scene you'll typically want to aim for a font resolution around the on screen resolution that the text will typically be rendered at, in full 3D scene this scaling obviously varies so there won't be one ideal resolution, you'll just have to pick the best one for your the size of your text and the distances you view them at. Disabling of placing text into the transparent bin could cause real problems as the blending of the text could be broken. Text is put in the transparent bin to make sure it's rendered after the rest of the 3D scene to make sure that the transparent parts of the text are correctly blending and the quads text doesn't interfere with with the zbuffer. I don't know whether this is affecting quality for you as you don't say anything about what you by "decluttering". Robert. On 14 March 2017 at 17:07, Lv Qingwrote: > Hi, > > Thx Robert! > >I use one of osgEarth fuction to rendering my text. > > > > Code: > > > osg::ref_ptr PowerPlaceNode::createPlaceNodeTextDrawable(const > std::string& text, > const TextSymbol* symbol, const osg::Vec3& positionOffset) > { > osg::ref_ptr < osgText::Text > t = new osgText::Text(); > osgText::String::Encoding text_encoding = > osgText::String::ENCODING_UNDEFINED; > if (symbol && symbol->encoding().isSet()) > { > switch (symbol->encoding().value()) > { > case TextSymbol::ENCODING_ASCII: > text_encoding = osgText::String::ENCODING_ASCII; > break; > case TextSymbol::ENCODING_UTF8: > text_encoding = osgText::String::ENCODING_UTF8; > break; > case TextSymbol::ENCODING_UTF16: > text_encoding = osgText::String::ENCODING_UTF16; > break; > case TextSymbol::ENCODING_UTF32: > text_encoding = osgText::String::ENCODING_UTF32; > break; > default: > text_encoding = osgText::String::ENCODING_UTF8; > break; //editby lvqing 20140509 > } > } > > t->setText(text, osgText::String::ENCODING_UTF8); > > > if (symbol && symbol->pixelOffset().isSet()) > { > t->setPosition( > osg::Vec3(positionOffset.x() + > symbol->pixelOffset()->x(), > positionOffset.y() + > symbol->pixelOffset()->y(), positionOffset.z())); > } > else > { > t->setPosition(positionOffset); > } > > osgText::Font* font = 0L; > if (symbol && symbol->font().isSet()) > { > font = osgText::readFontFile(*symbol->font()); // read font*/ > } > > t->setFontResolution(256,256); > > t->setAutoRotateToScreen(false); > t->setCharacterSizeMode(osgText::Text::OBJECT_COORDS); > > if (symbol != NULL) > { > if (symbol->size() != NULL) > { > t->setCharacterSize( symbol && symbol->size().isSet() > ? *symbol->size() : 20.0f ); > } > else > { > t->setCharacterSize( 20.0f ); > } > } > > if (!font) > font = Registry::instance()->getDefaultFont(); > if (font) > { > t->setFont(font); > } > > t->setColor(symbol && symbol->fill().isSet() ? > symbol->fill()->color() : Color::White); > > if (symbol) > { > // they're the same enum. > osgText::Text::AlignmentType at = > (osgText::Text::AlignmentType) symbol->alignment().value(); > t->setAlignment(at); > } > > if (symbol && symbol->halo().isSet()) > { > t->setBackdropColor(symbol->halo()->color()); > t->setBackdropType(osgText::Text::OUTLINE); > > if (symbol->haloOffset() != NULL) > { > if (symbol->haloOffset().isSet()) > { > t->setBackdropOffset(*symbol->haloOffset(), > *symbol->haloOffset()); > } > } > } > else if (!symbol) > { >
Re: [osg-users] How to disable Antialiasing of an osg::Text
Hi Lv, > You mention A 1:1 ratio will likely minimize these effects.Which > function excatly I should call? There isn't a single function that you can use to do, as well, it's impossible to implement in a general purpose 3d text implementation. Only if you have screen aligned text can you start to think about setting the font resolution (Text::setFontResolution(..) to match the on screen resolution, You haven't said anything about you are rendering your text really can't provide any specific recommendations. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to disable Antialiasing of an osg::Text
robertosfield wrote: > HI Lv, > > osgText::Text renders into a 3D scene using OpenGL, which is quite > different than Qt rendering to a 2D window where font resolutions can > exactly matched to the pixels on screen, so you can't really compare > the two. > > osgText::Text itself doesn't implement anti-aliasing, anti-aliasing is > a property of the GraphicsWindow that you've created. For the > blurriness you reporting it's unlikely to be an high level > anti-aliasing issue. > > My guess is that it's more likely an issue of undersampling of the > glyph texture (magnification) if the size of glyph on screen is lower > than the font resolution, or possible magnification if the glyph on > screen is smaller than the font resolution. A 1:1 ratio will likely > minimize these effects. > > You don't provide any guidance on how you are rendering so I can't > provide any more details than this. > > Robert. > > On 2 March 2017 at 17:41, Lv Qing <> wrote: > > > Hi, > > > > In linux we are using osg::Text to display some chinese characters.Then > > we find the osg::Text looks a little blur when the size of characters is > > small.Or,the Black characters seems a little gray when the character size > > is small.I have setFontSolution(128,128),it not help. > > > > Then I fond our old app which using QT to draw text,and with the same > > font,QT text looks better than osg::Text. > > > > I fond QT use QPaint to loading font and drawing text ,and It can enable or > > disable Antialiasing of text like below. > > > > > > > > Code: > > class Q_GUI_EXPORT QPainter > > { > > Q_DECLARE_PRIVATE(QPainter) > > Q_GADGET > > Q_FLAGS(RenderHint RenderHints) > > > > public: > > enum RenderHint { > > Antialiasing = 0x01, > > TextAntialiasing = 0x02, > > SmoothPixmapTransform = 0x04, > > HighQualityAntialiasing = 0x08, > > NonCosmeticDefaultPen = 0x10 > > }; > > > > > > > > > > So my question is ,does osg can enable or disable Antialiasing to an > > osg::Text? > > > > > > > > > > ... > > > > Thank you! > > > > Cheers, > > Lv > > Code: > > > > > > > > > > -- > > Read this topic online here: > > http://forum.openscenegraph.org/viewtopic.php?p=70395#70395 > > > > > > > > > > > > ___ > > osg-users mailing list > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > ___ > osg-users mailing list > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- > Post generated by Mail2Forum Thx! robert! You mention A 1:1 ratio will likely minimize these effects.Which function excatly I should call? ThX again! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70406#70406 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to disable Antialiasing of an osg::Text
HI Lv, osgText::Text renders into a 3D scene using OpenGL, which is quite different than Qt rendering to a 2D window where font resolutions can exactly matched to the pixels on screen, so you can't really compare the two. osgText::Text itself doesn't implement anti-aliasing, anti-aliasing is a property of the GraphicsWindow that you've created. For the blurriness you reporting it's unlikely to be an high level anti-aliasing issue. My guess is that it's more likely an issue of undersampling of the glyph texture (magnification) if the size of glyph on screen is lower than the font resolution, or possible magnification if the glyph on screen is smaller than the font resolution. A 1:1 ratio will likely minimize these effects. You don't provide any guidance on how you are rendering so I can't provide any more details than this. Robert. On 2 March 2017 at 17:41, Lv Qingwrote: > Hi, > > In linux we are using osg::Text to display some chinese characters.Then > we find the osg::Text looks a little blur when the size of characters is > small.Or,the Black characters seems a little gray when the character size is > small.I have setFontSolution(128,128),it not help. > >Then I fond our old app which using QT to draw text,and with the same > font,QT text looks better than osg::Text. > >I fond QT use QPaint to loading font and drawing text ,and It can enable > or disable Antialiasing of text like below. > > > > Code: > class Q_GUI_EXPORT QPainter > { > Q_DECLARE_PRIVATE(QPainter) > Q_GADGET > Q_FLAGS(RenderHint RenderHints) > > public: > enum RenderHint { > Antialiasing = 0x01, > TextAntialiasing = 0x02, > SmoothPixmapTransform = 0x04, > HighQualityAntialiasing = 0x08, > NonCosmeticDefaultPen = 0x10 > }; > > > > > So my question is ,does osg can enable or disable Antialiasing to an > osg::Text? > > > > > ... > > Thank you! > > Cheers, > Lv > Code: > > > > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=70395#70395 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to disable Antialiasing of an osg::Text
Hi, In linux we are using osg::Text to display some chinese characters.Then we find the osg::Text looks a little blur when the size of characters is small.Or,the Black characters seems a little gray when the character size is small.I have setFontSolution(128,128),it not help. Then I fond our old app which using QT to draw text,and with the same font,QT text looks better than osg::Text. I fond QT use QPaint to loading font and drawing text ,and It can enable or disable Antialiasing of text like below. Code: class Q_GUI_EXPORT QPainter { Q_DECLARE_PRIVATE(QPainter) Q_GADGET Q_FLAGS(RenderHint RenderHints) public: enum RenderHint { Antialiasing = 0x01, TextAntialiasing = 0x02, SmoothPixmapTransform = 0x04, HighQualityAntialiasing = 0x08, NonCosmeticDefaultPen = 0x10 }; So my question is ,does osg can enable or disable Antialiasing to an osg::Text? ... Thank you! Cheers, Lv Code: -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70395#70395 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org