<div dir="ltr"><div>I found out what my problem was. Since I was adding to vectors, I needed to set vec.w = 1;<br><br></div>Thanks anyway!<br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-22 20:31 GMT+01:00 Raymond de Vries <span dir="ltr"><<a href="mailto:reedev@xs4all.nl" target="_blank">reedev@xs4all.nl</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hi Bruno,<br>
    <br>
    Can you provide more information about your setup? Platform, gfx
    card, osg version, etc. Have you seen and tried the osg example
    osgdrawinstanced? Writing "not working" is probably too little info
    for people to help you ;-)<br>
    <br>
    Cheers,<br>
    Raymond<div><div class="h5"><br>
    <br>
    <br>
    <br>
    <div class="m_6652820044422372515moz-cite-prefix">On 5/22/2017 8:17 PM, Bruno Oliveira
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">
        <div>
          <div>
            <div>Hi,<br>
              <br>
              <br>
            </div>
            I want to render several simple quads ( a simple rectangle).
            I pass the quad centers via a 2D texture, and try to render
            them with the following vertex shader:<br>
            <br>
            <br>
            <br>
                        "#version 120\n"<br>
                        "#extension GL_EXT_draw_instanced : enable\n"<br>
                        "\n"<br>
                        "uniform sampler2D texVert;\n"<br>
                        "uniform sampler2D texColor;\n"<br>
                        "uniform float          texSize;\n"<br>
                        "\n"<br>
                        "void main() {\n"<br>
                        "\n"<br>
                        "  float row   = float(gl_InstanceID) /
            texSize;\n"<br>
                        "\n"<br>
                        "  vec2  uv    = vec2(fract(row), floor(row) /
            texSize);\n"<br>
                        "  vec4  vert  = gl_Vertex + texture2D(texVert,
            uv);\n"<br>
                        "\n"<br>
                        "  gl_Position = gl_ModelViewProjectionMatrix *
            vert;\n"<br>
                        "\n"<br>
                        "}\n"<br>
            <br>
            <br>
            <br>
          </div>
          <b>This is my code for creating 1000 quads:</b><br>
          <br>
          this->setUseDisplayList(false)<wbr>,<br>
              this-><wbr>setUseVertexBufferObjects(<wbr>true);<br>
          <br>
              // Build Geometry<br>
              // Simple Quad<br>
            osg::ref_ptr<osg::Vec3Array> vertices = new
          osg::Vec3Array(4);<br>
            (*vertices)[0].set(-500, -500, 0.f );<br>
            (*vertices)[1].set( 500, -500, 0.f );<br>
            (*vertices)[2].set( 500,  500, 0.f );<br>
            (*vertices)[3].set(-500,  500, 0.f );<br>
          <br>
            this->setUseDisplayList(false)<wbr>;<br>
            this-><wbr>setUseVertexBufferObjects(<wbr>true);<br>
            this->setVertexArray(vertices.<wbr>get());<br>
            this->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4,
          1000));<br>
          <br>
          <br>
        </div>
        <b>IMPORTANT NOTE</b>: <b>If I use simple GL_POINTS, my code
          works fine and renders correclty 1000 points:<br>
        </b><br>
        <br>
          osg::ref_ptr<osg::Vec3Array> vertices = new
        osg::Vec3Array(1);<br>
          (*vertices)[0].set(0, 0, 0.f );<br>
        <br>
          this->setVertexArray(vertices)<wbr>;<br>
        <br>
            this->addPrimitiveSet( new osg::DrawArrays(GL_POINTS, 0,
        1, 1000) );<br>
        <br>
          <br>
      </div>
      </div></div><div id="m_6652820044422372515DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2">
        <br>
        <br>
        <hr style="border:none;color:#909090;background-color:#b0b0b0;height:1px;width:99%">
        <table style="border-collapse:collapse;border:none">
          <tbody>
            <tr>
              <td style="border:none;padding:0px 15px 0px 8px"> <a href="http://www.avg.com/internet-security" target="_blank"> <img src="http://static.avast.com/emails/avg-mail-stamp.png" alt="AVG logo" border="0"> </a> </td>
              <td>
                <p style="color:#3d4d5a;font-family:"Calibri","Verdana","Arial","Helvetica";font-size:12pt"> This email has been checked for
                  viruses by AVG antivirus software. <br>
                  <a href="http://www.avg.com/internet-security" target="_blank">www.avg.com</a>
                </p>
              </td>
            </tr>
          </tbody>
        </table>
        <br>
        <a href="#m_6652820044422372515_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div>
      <br>
      <fieldset class="m_6652820044422372515mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
osg-users mailing list
<a class="m_6652820044422372515moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.<wbr>openscenegraph.org</a>
<a class="m_6652820044422372515moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a>
</pre>
    </blockquote>
    <br>
  </div>

<br>______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.<wbr>openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a><br>
<br></blockquote></div><br></div>