[osg-users] osggeometryshaders example question

Robert Osfield robert.osfield at gmail.com
Tue Sep 12 09:27:24 PDT 2017


Hi Mike,

I have just done a quick experiement with the osgshadersexample and found
the with one vertex I wouldn't see anything.

With only a single vertex the bounding box would just be zero sized so the
scaling of the camera would likely be a bit off as well as small feature
culling wanting to cull this drawable as it would percieve it to be an
invisibly small point. To test possibility out I added the line:

        setInitialBound(osg::BoundingBox(0.0f,0.0f,0.0f,1.0f,1.0f,1.0f));

After the set up of the geometry to force the bounding box to a sensible
initial size and then it works fine with just a single vertex.  Ideally
you'd set the size that the geometry could end up once you apply the
vertex/geometry shader modifications so that culling can properly take into
account the range the geometry could end up in.

Another approach is you can disable the small feature culling by setting
the culling mode to just use the frustum sides (or other modes without
SMALL_FEATURE_CULLING see include/osg/CullSettings for details):


viewer.getCamera()->setCullingMode(osg::CullSettings::VIEW_FRUSTUM_SIDES_CULLING);

You'd also need to set the camera home position as well, but given you will
likely have other elements in a real scene graph this is likely not
required.

The setInitalBound() or using your own ComputeBoundCallback is probably the
most general helpful way to handle position modifications, the Camera
settings are really just high level workarounds to this special case of a
zero sized scene graph.

Robert.


On 12 September 2017 at 16:12, Mike Greene <mgreene at hiwaay.net> wrote:

> Hi,
>
> In reference to the osggeometryshaders example, I have a question about a
> seeming problem when only passing one point to the geometry shader:
>
> If I comment out all but the first push back:
>
> Code:
> osg::Vec3Array* vAry = new osg::Vec3Array;
> setVertexArray( vAry );
> vAry->push_back( osg::Vec3(0,0,0) );
> /*vAry->push_back( osg::Vec3(0,1,0) );
> vAry->push_back( osg::Vec3(1,0,0) );
> vAry->push_back( osg::Vec3(1,1,0) );
> vAry->push_back( osg::Vec3(0,0,1) );
> vAry->push_back( osg::Vec3(0,1,1) );
> vAry->push_back( osg::Vec3(1,0,1) );
> vAry->push_back( osg::Vec3(1,1,1) );*/
>
>
>
>
> Nothing shows up. But if I do two, three or more points, every thing works
> fine. It seems a minimum of two points in the DrawArrays array is required?
>
> Thank you!
>
> Cheers,
> Mike[/code]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=71697#71697
>
>
>
>
>
> _______________________________________________
> 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/20170912/8f0ce352/attachment.htm>


More information about the osg-users mailing list