<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Sebastian,<br>
    <br>
    that's great. It works with the shader you suggested.<br>
    Strange is, that just using vertex color doesn't work. It seems
    alpha is set to transparent (0).<br>
    Also a texture is set but only alpha has a meaning. Texture color is
    black.<br>
    That looks odd to me.<br>
    <br>
    But anyway, I'm happy now.<br>
    <br>
    - Werner -<br>
    <br>
    <div class="moz-cite-prefix">Am 24.02.2017 um 13:16 schrieb
      Sebastian Messerschmidt:<br>
    </div>
    <blockquote cite="mid:7f9679d8-1c79-3c44-fa7e-cd31dfb8dd41@gmx.de"
      type="cite">
      <br>
      <br>
      Am 2/24/2017 um 12:57 PM schrieb Werner Modenbach:
      <br>
      <blockquote type="cite">Dear all,
        <br>
        <br>
        my project needs gl3 features and so I use the following
        methods:
        <br>
        <br>
        <br>
camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3);
        <br>
        <br>
camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3);
        <br>
        <br>
        Of course I need my own shaders then.
        <br>
        But I also like having built-in functionality like StatsHandler.
        <br>
        To set a simple shader for the StatsHandlers camera I do like
        that:
        <br>
        <br>
        osgViewer::StatsHandler*sthd=newosgViewer::StatsHandler;
        <br>
        <br>
        view->addEventHandler(sthd);
        <br>
        <br>
        if(useGL3){
        <br>
        stateSet=sthd->getCamera()->getOrCreateStateSet();
        <br>
        <br>
stateSet->getOrCreateUniform(BASE_TEXTURE_UNIFORM,osg::Uniform::INT_SAMPLER_2D)->set(BASE_TEXTURE_UNIT);
        <br>
        <br>
stateSet->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,textur_weiss.get(),osg::StateAttribute::ON);
        <br>
        <br>
        installDefaultShader(stateSet);
        <br>
        <br>
        }
        <br>
        <br>
        The shaders are really simple:
        <br>
        VERTEX
        <br>
        <br>
        uniformmat4osg_ModelViewProjectionMatrix;
        <br>
        uniformmat4osg_ModelViewMatrix;
        <br>
        <br>
        uniformmat3osg_NormalMatrix;
        <br>
        <br>
        uniformvec3lightPosition0=vec3(0.0f,0.0f,1.0f);
        <br>
        <br>
        invec4osg_Vertex;
        <br>
        <br>
        invec4osg_Normal;
        <br>
        <br>
        invec4osg_Color;
        <br>
        <br>
        invec4osg_MultiTexCoord0;
        <br>
        <br>
        outvec3normal;
        <br>
        <br>
        outvec3lightDir;
        <br>
        <br>
        outvec4vertexColor;
        <br>
        <br>
        outvec2textureCoord;
        <br>
        <br>
        voidmain(){
        <br>
        <br>
        normal=normalize(osg_NormalMatrix*osg_Normal.xyz);
        <br>
        <br>
        vec3vertexPos=vec3(osg_ModelViewMatrix*osg_Vertex);
        <br>
        <br>
        lightDir=normalize(lightPosition0-vertexPos);
        <br>
        <br>
        vertexColor=osg_Color;
        <br>
        <br>
        textureCoord=osg_MultiTexCoord0.xy;
        <br>
        <br>
        gl_Position=osg_ModelViewProjectionMatrix*osg_Vertex;
        <br>
        <br>
        }
        <br>
        <br>
        <br>
        FRAGMENT
        <br>
        <br>
        uniformsampler2DbaseTexture;
        <br>
        <br>
        invec3normal;
        <br>
        invec3lightDir;
        <br>
        <br>
        invec4vertexColor;
        <br>
        <br>
        invec2textureCoord;
        <br>
        <br>
        outvec4fragData;
        <br>
        <br>
        voidmain(){
        <br>
        <br>
            vec4textureColor=texture2D(baseTexture,textureCoord);
        <br>
        fragData=vertexColor*textureColor;
        <br>
        <br>
        }
        <br>
        <br>
        <br>
        That works fine for the graphics but all text is black.
        Obviously text
        <br>
        does not set osg_Color .
        <br>
      </blockquote>
      <br>
      osg_Color is an alias for the color-vertex attribute. Colors are
      set in
      <br>
      void Text::drawForegroundText ~line 1628. So there should be
      colors.
      <br>
      <br>
      My fragment shader looks like this:
      <br>
      <br>
      #version 440
      <br>
      #extension GL_ARB_enhanced_layouts : enable
      <br>
      #extension GL_ARB_separate_shader_objects : enable
      <br>
      <br>
      layout (location=0) out vec4 FragmentData;
      <br>
      <br>
      layout(location=1) in block
      <br>
      {
      <br>
          mediump vec2 tex_coord;
      <br>
          mediump vec4 color;
      <br>
      } In;
      <br>
      <br>
      <br>
      uniform sampler2D osg_Texture;
      <br>
      <br>
      void main()
      <br>
      {
      <br>
      <br>
          vec4 diffuse_color = In.color;
      <br>
      <br>
          diffuse_color *=  texture2D(osg_Texture, In.tex_coord).a;
      <br>
      <br>
          FragmentData = diffuse_color;
      <br>
      }
      <br>
      <br>
      which seems to work. As you can see I'm using the alpha channel
      only.
      <br>
      <br>
      Cheers
      <br>
      Sebastian
      <br>
      <br>
      <br>
      <blockquote type="cite">Unfortunately I failed discovering the
        reason in the sources of osg.
        <br>
        <br>
        Can anyone give me a hint on how to solve this?
        <br>
        <br>
        Many thanks in advance
        <br>
        <br>
        - Werner -
        <br>
        <br>
        <br>
        <br>
        _______________________________________________
        <br>
        osg-users mailing list
        <br>
        <a class="moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
        <br>
<a class="moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a>
        <br>
        <br>
      </blockquote>
      _______________________________________________
      <br>
      osg-users mailing list
      <br>
      <a class="moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
      <br>
<a class="moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a>
      <br>
    </blockquote>
    <br>
    <div class="moz-signature">-- <br>
      <b>TE<span style="color:red;">X</span>ION Software Solutions,
        Rotter Bruch 26a, D-52068 Aachen</b><br>
      Phone: +49 241 475757-0<br>
      Fax: +49 241 475757-29<br>
      Web: <a class="moz-txt-link-freetext" href="http://texion.eu">http://texion.eu</a><br>
      eMail: <a class="moz-txt-link-abbreviated" href="mailto:info@texion.eu">info@texion.eu</a><br>
    </div>
  </body>
</html>