OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

bug: osgText doesn't work on MacOSX GL4.x with VAO

Goto page 1, 2  Next
 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Fri Jan 20, 2017 7:53 pm    Post subject:
bug: osgText doesn't work on MacOSX GL4.x with VAO
Reply with quote

Hi,

I can't render osgText on MacOSX Core Profile:

text->setTextBackdropType(osgText::Text::BackdropType::NONE);
text->setTextBackdropImplementation(osgText::Text::BackdropImplementation::DELAYED_DEPTH_WRITES);

text->setBackColor( Color( Color::Black, 0.8 ) );
text->setHorizAlign( Control::ALIGN_RIGHT );
text->setVertAlign( Control::ALIGN_BOTTOM );
text->setVisible( true );

I've also tried to apply a default shader. But it doesn't work at all.

Cheers,
Remo
Back to top
View user's profile Send private message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 703

PostPosted: Fri Jan 20, 2017 8:45 pm    Post subject:
bug: osgText doesn't work on MacOSX GL4.x with VAO
Reply with quote

Hi Remo,

A more detailed description on how it fails would be helpful.
If you're seeing non-textures quads instead of your glyphs you need to
adapt your shader as the text-rendering isn't using a normal blending.
I've attached my default core-profile shader which uses pre-multiplied
alpha.
Additionally I add a default sampler at camera root for the osg_Texture
and I do:

for (auto index = 0u; index < mMainViewer->getNumViews(); ++index )
{
getCamera(index)->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(true);
getCamera(index)->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(true);
}

nsRenderer::Helpers::addTexture(
stats_handler->getCamera()->getOrCreateStateSet(), "osg_Texture",new
osg::Texture2D(nsRenderer::Helpers::getDefaultImage(false)), 0);

Hope that helps
Sebastian
Quote:
Hi,

I can't render osgText on MacOSX Core Profile:

text->setTextBackdropType(osgText::Text::BackdropType::NONE);
text->setTextBackdropImplementation(osgText::Text::BackdropImplementation::DELAYED_DEPTH_WRITES);

text->setBackColor( Color( Color::Black, 0.8 ) );
text->setHorizAlign( Control::ALIGN_RIGHT );
text->setVertAlign( Control::ALIGN_BOTTOM );
text->setVisible( true );

I've also tried to apply a default shader. But it doesn't work at all.

Cheers,
Remo

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70020#70020










------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Fri Jan 20, 2017 10:06 pm    Post subject:
Reply with quote

Hi Sebastian

Thank you for your help. Yes i don't see the glyphs. I use osgEarth, but this should not be a problem Smile

I've tried the following according your sample:

Code:

ControlCanvas* canvas = ControlCanvas::getOrCreate( view );
    view->getCamera()->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(true);
    view->getCamera()->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(true);
   
    osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
    osg::ref_ptr<osg::Image> image = new osg::Image();
    image->allocateImage(512, 512, 1, GL_RGBA, GL_UNSIGNED_BYTE);
   
    texture->setImage(image);

    view->getCamera()->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
   
    LabelControl* label = new LabelControl();
    osg::Program* textProgramObject = new osg::Program;
    osg::Shader* textVertexObject =
    new osg::Shader( osg::Shader::VERTEX );
    osg::Shader* textFragmentObject =
    new osg::Shader( osg::Shader::FRAGMENT );
    textProgramObject->addShader( textFragmentObject );
    textProgramObject->addShader( textVertexObject );
    textFragmentObject->setShaderSource(frag);
    textVertexObject->setShaderSource(vert);
    label->getOrCreateStateSet()->setAttributeAndModes(textProgramObject, osg::StateAttribute::ON);
   
    label->setTextBackdropType(osgText::Text::BackdropType::NONE);
    label->setTextBackdropImplementation(osgText::Text::BackdropImplementation::DELAYED_DEPTH_WRITES);
   
    label->setBackColor( Color( Color::Black, 0.8 ) );
    label->setHorizAlign( Control::ALIGN_RIGHT );
    label->setVertAlign( Control::ALIGN_BOTTOM );
    label->setVisible( true );



But i don't see any glyphs.

Cheers,
Remo[/code]
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Sat Jan 21, 2017 11:23 am    Post subject:
Reply with quote

Hi Sebastian,

Sorry, please ignore my post. The code is wrong. I need to test it first Smile


Cheers,
Remo
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Tue Jan 24, 2017 12:52 pm    Post subject:
Reply with quote

Hi Sebastian

I'm wondering if you have a running osgText on MacOSX Core Profile. Your shader-code is not compatible with it. I've written a partial working version of this shader. I also found that the Glyph Texture is created with red. But i think something is wrong with the texturecoordinates. I don't see any glyph.

Code:
uniform sampler2D glyphTexture;
in vec2 texCoord;
out vec4 color;
void main()
{
  color = vertexColor * texture(glyphTexture, texCoord).r;
}


I'm not sure the code of "Text::drawForegroundText" can work with VAO (It's required on MacOSX)

Here you find a draw dump from MacOSX:



Cheers,
Remo[/img]
Back to top
View user's profile Send private message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 703

PostPosted: Tue Jan 24, 2017 1:27 pm    Post subject:
bug: osgText doesn't work on MacOSX GL4.x with VAO
Reply with quote

Hi Remo
Quote:
Hi Sebastian

I'm wondering if you have a running osgText on MacOSX Core Profile. Your shader-code is not compatible with it. I've written a partial working version of this shader. I also found that the Glyph Texture is created with red. But i think something is wrong with the texturecoordinates. I don't see any glyph.
I'm not using MacOSX, but I'm running on core profile under Windows and
the shader seems to work for osgText there.
Quote:


Code:
uniform sampler2D glyphTexture;
in vec2 texCoord;
out vec4 color;
void main()
{
color = vertexColor * texture(glyphTexture, texCoord).r;
}

Basically the font should be white and modulated by the vertex color. I
would have to dive into the implementation to see, why your information
is in the red-channel. It might very well be, that the osgText is using
GL_RED or something else which I can access via the .a swizzle in my
driver.

Quote:




I'm not sure the code of "Text::drawForegroundText" can work with VAO (It's required on MacOSX)
I'm not sure if the VAO path is used on my side. So I can't help you
with this one.

Cheers
Sebastian
Quote:

Here you find a draw dump from MacOSX:

[Image: http://forum.openscenegraph.org/files/dump_202.png ]

Cheers,
Remo[/img]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70036#70036









------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Fri Jan 27, 2017 1:59 pm    Post subject:
Reply with quote

Hi (Robert Smile

I've tried a lot of things to get osgText working on MacOSX with VAO. GL3 on OSX Core Profile requires VAOs.

osgText doesn't setup the VAO path correctly on MacOSX. I can show glyphs when I use a osg::Geometry as a Wrapper to draw geometries from text glyphs like so:

Code:
   
class ExtText : public Text {
    friend class VAOText;
};

class VAOText : public osg::Geometry
{
private:
    osg::ref_ptr<ExtText> _t;

...
    void redraw()
    {
        unsigned int contextID = 0; // renderInfo.getState()->getContextID();
       
        if ( !_t->_textureGlyphQuadMap.empty() )
        {
            const ExtText::GlyphQuads& glyphquad = (_t->_textureGlyphQuadMap.begin())->second;
            if (!glyphquad._transformedCoords[contextID].valid() || glyphquad._transformedCoords[contextID]->empty() )
            {
                _t->computePositions(contextID);
            }
        }
       
        for(ExtText::TextureGlyphQuadMap::iterator titr=_t->_textureGlyphQuadMap.begin();
            titr!=_t->_textureGlyphQuadMap.end();
            ++titr)
        {
            const ExtText::GlyphQuads& glyphquad = titr->second;
            const ExtText::GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID];
            if (transformedCoords.valid() && !transformedCoords->empty())
            {
               
                setVertexArray(transformedCoords.get());
                setTexCoordArray(0, glyphquad._texcoords.get());
               
                getOrCreateStateSet()->setTextureAttributeAndModes(0, titr->first.get(),osg::StateAttribute::ON);
                addPrimitiveSet(glyphquad._quadIndices);
            }
        }
    }


But it doesn't work with plain osgText. So something is wrong in osgText / VAO.

Cheers,
Remo
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10784

PostPosted: Fri Jan 27, 2017 2:05 pm    Post subject:
bug: osgText doesn't work on MacOSX GL4.x with VAO
Reply with quote

Hi Remo,

On 27 January 2017 at 13:59, Remo Eichenberger <> wrote:
Quote:
I've tried a lot of things to get osgText working on MacOSX with VAO. GL3 on OSX Core Profile requires VAOs.

I don't have an OSX system so can't comment on the specifics of VAO
support on MacOSX, I have rely upon OSX users to provide testing and
guidance on it.

The only thing I can add is to ask which version of the OSG you are
using, and whether you've tested the new VAO support in OSG master.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Fri Jan 27, 2017 2:15 pm    Post subject:
Reply with quote

Hi Robert

I use OSG master 255a86cbe22ba436ab162bd2a2e7cc0341140050

Cheers,
Remo
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10784

PostPosted: Fri Jan 27, 2017 2:21 pm    Post subject:
bug: osgText doesn't work on MacOSX GL4.x with VAO
Reply with quote

On 27 January 2017 at 14:15, Remo Eichenberger <> wrote:
Quote:
I use OSG master 255a86cbe22ba436ab162bd2a2e7cc0341140050

Have you enabled the new VAO support?

The env var OSG_VERTEX_BUFFER_HINT should be used and set to VAO.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Fri Jan 27, 2017 2:29 pm    Post subject:
Reply with quote

yes,

OSG_VERTEX_BUFFER_HINT=VAO
OSG_GEOMETRY_IMPLEMENTATION=VAO
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10784

PostPosted: Fri Jan 27, 2017 2:52 pm    Post subject:
bug: osgText doesn't work on MacOSX GL4.x with VAO
Reply with quote

HI Remo,

On 27 January 2017 at 14:29, Remo Eichenberger <> wrote:
Quote:
OSG_VERTEX_BUFFER_HINT=VAO
OSG_GEOMETRY_IMPLEMENTATION=VAO

Oh well, that exhausts one possibility of a fix.

I don't really know if it's worth trying to fix osgText::Text, when I
made the changes to support VAO I got things working under Linux, or
at least it appeared to be working, but osgText::Text implementation
is a real mess internally due to several early design decisions based
on limitations of hardware 15 years back then a series of contribution
that added extra features to Text but also with lots of complexities.

To properly fix it I feel that it might even be worth making
osgText::Text and full node and have it generate a subgraph (made with
standard osg::Geometry etc.) to do the actual rendering rather than
embed it all in a custom Drawable as is done now. The problem would
be backwards compatibility.

I have too much other work on right now to dive into topic, but have a
think about the issues when I do have time.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10784

PostPosted: Sat Feb 04, 2017 3:02 pm    Post subject:
bug: osgText doesn't work on MacOSX GL4.x with VAO
Reply with quote

Hi Remo,

As a first step to resolving the osgText issues with VAO I have
created a text_refactor branch off OSG master.

All I have done so far is add the ability of osgText::TextBase to have
NodeList _children that it traverses automatically, this _children
list is intended for the Text and Text3D classes to populate with
standard scene graph elements such as osg::Geometry/osg::StateSet to
render the text in conventional ways rather the the custom render code
that these classes currently have.

The next step will be to adapt osgText::Text to create the appropriate
subgraph to render the text and add this into the _children list.
osgText::Text is not a straight forward class so I expect we'll need
to slow fill in all the functionality bit by bit. I welcome efforts
from the community in this effort.

Cheers,
Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Sat Mar 11, 2017 4:53 pm    Post subject:
Reply with quote

Hi Robert

I've tested the latest branch on MacOSX 10.11.6:
https://github.com/openscenegraph/OpenSceneGraph/commit/f1f6d23eebda16a9d4560a0a130580d65edf7401

Non of the stock samples works because of not applied shader. MacOSX needs a default shader.

But simple text works when i add a shader on my sample code.

Then i've added the Statshandler. It doesn't show the statistics.

Cheers,
Remo
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 34

PostPosted: Tue Mar 14, 2017 5:01 pm    Post subject:
Reply with quote

Update: Stock sample "examples_osgtext" partial works with:

font->setMinFilterHint(osg::Texture::LINEAR);

on MacOSX GL3 Core Profile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts problems getting shadow demo to work Lee Butler General 1 Mon Feb 20, 2017 4:02 am View latest post
No new posts osgText::Text fix for GLES2 (OpenScen... Konstantin Submission 0 Tue Feb 14, 2017 6:37 pm View latest post
No new posts Version 3.5.6 osgText::Text bounding ... dcfennell General 0 Tue Jan 31, 2017 5:40 pm View latest post
No new posts Text following lines shaders with osg... kragnfroll General 1 Mon Jan 02, 2017 1:25 pm View latest post
No new posts bug: Android cross compile (windows) ... remoe Build system [build] 0 Sat Oct 29, 2016 7:51 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP