[osg-users] Draw instance quads not working

Raymond de Vries reedev at xs4all.nl
Tue May 23 01:50:13 PDT 2017


Thanks for the feedback.

Cheers
Raymond



On 23-5-2017 10:44, Bruno Oliveira wrote:
> I found out what my problem was. Since I was adding to vectors, I 
> needed to set vec.w = 1;
>
> Thanks anyway!
>
> 2017-05-22 20:31 GMT+01:00 Raymond de Vries <reedev at xs4all.nl 
> <mailto:reedev at xs4all.nl>>:
>
>     Hi Bruno,
>
>     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 ;-)
>
>     Cheers,
>     Raymond
>
>
>
>
>     On 5/22/2017 8:17 PM, Bruno Oliveira wrote:
>>     Hi,
>>
>>
>>     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:
>>
>>
>>
>>                 "#version 120\n"
>>                 "#extension GL_EXT_draw_instanced : enable\n"
>>                 "\n"
>>                 "uniform sampler2D texVert;\n"
>>                 "uniform sampler2D texColor;\n"
>>                 "uniform float texSize;\n"
>>                 "\n"
>>                 "void main() {\n"
>>                 "\n"
>>                 "  float row   = float(gl_InstanceID) / texSize;\n"
>>                 "\n"
>>                 "  vec2  uv    = vec2(fract(row), floor(row) /
>>     texSize);\n"
>>                 "  vec4  vert  = gl_Vertex + texture2D(texVert, uv);\n"
>>                 "\n"
>>                 "  gl_Position = gl_ModelViewProjectionMatrix * vert;\n"
>>                 "\n"
>>                 "}\n"
>>
>>
>>
>>     *This is my code for creating 1000 quads:*
>>
>>     this->setUseDisplayList(false),
>>         this->setUseVertexBufferObjects(true);
>>
>>         // Build Geometry
>>         // Simple Quad
>>       osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(4);
>>       (*vertices)[0].set(-500, -500, 0.f );
>>       (*vertices)[1].set( 500, -500, 0.f );
>>       (*vertices)[2].set( 500,  500, 0.f );
>>       (*vertices)[3].set(-500,  500, 0.f );
>>
>>       this->setUseDisplayList(false);
>>       this->setUseVertexBufferObjects(true);
>>       this->setVertexArray(vertices.get());
>>       this->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4, 1000));
>>
>>
>>     *IMPORTANT NOTE*: *If I use simple GL_POINTS, my code works fine
>>     and renders correclty 1000 points:
>>     *
>>
>>       osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(1);
>>       (*vertices)[0].set(0, 0, 0.f );
>>
>>       this->setVertexArray(vertices);
>>
>>         this->addPrimitiveSet( new osg::DrawArrays(GL_POINTS, 0, 1,
>>     1000) );
>>
>>
>>
>>
>>     ------------------------------------------------------------------------
>>     AVG logo <http://www.avg.com/internet-security> 	
>>
>>     This email has been checked for viruses by AVG antivirus software.
>>     www.avg.com <http://www.avg.com/internet-security>
>>
>>
>>     <#m_6652820044422372515_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>>
>>     _______________________________________________
>>     osg-users mailing list
>>     osg-users at lists.openscenegraph.org
>>     <mailto:osg-users at lists.openscenegraph.org>
>>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>     <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>     _______________________________________________ osg-users mailing
>     list osg-users at lists.openscenegraph.org
>     <mailto:osg-users at lists.openscenegraph.org>
>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>     <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170523/bca3bec4/attachment-0003.htm>


More information about the osg-users mailing list