Re: [osg-users] osgUtil::LineSegmentIntersector performance issues

2018-12-05 Thread Chris Hanson
If you are achieving .01ms with your current hardware and model, and you
are happy with that, by ALL means, you should not put further effort into
it.

I remarked as much for other's benefit and for those who might read the
thread in the future and wonder about strategies for working with more
complex models where first-hit is sufficient and utilizing the GPU to do
the heavy lifting can be a big win.

Glad it works for you.

On Wed, Dec 5, 2018 at 5:47 PM Andrea Martini 
wrote:

> Hi Chris Hanson,
> thank you for your suggestion and your advanced solution.
> However, the Robert Osfield's answer solved completely issues concerning
> my unclear question.
> At the moment i find very hard to improve (using my equipment) performance
> beyond  0.01 ms.
> Anyway, i will take in consideration your  useful suggenstions for next
> challenges.
>
> Cheers,
> Andrea
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75284#75284
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgUtil::LineSegmentIntersector performance issues

2018-12-05 Thread Andrea Martini
Hi Chris Hanson,
thank you for your suggestion and your advanced solution.
However, the Robert Osfield's answer solved completely issues concerning my 
unclear question.
At the moment i find very hard to improve (using my equipment) performance 
beyond  0.01 ms.
Anyway, i will take in consideration your  useful suggenstions for next 
challenges.

Cheers,
Andrea

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgUtil::LineSegmentIntersector performance issues

2018-12-05 Thread Chris Hanson
Here's one take on the matter:

http://ogldev.atspace.co.uk/www/tutorial29/tutorial29.html
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgUtil::LineSegmentIntersector performance issues

2018-12-05 Thread Chris Hanson
Do you only need drawable-level discrimination? You can spend a lot of
effort intersection testing each polygon on the CPU. You can also offload a
lot of the work onto the GPU, but OSG doesn't do this for you. If you only
need the ray hit closest to the Eye, you can also use a variant of Picking
-- set a 1x1 pixel viewport around the ray frustum and shovel the geometry
through the rasterizer to record which fragment is closest. With various
techniques you can assign fragment IDs on whatever granularity (Drawable,
polygon, or something else) you wish. This can be quite quick because the
GPU is optimized to do this and you can rasterize to an FBO.

Maybe explain better what you are trying to ACCOMPLISH, rather than just
the current technique you are trying to use to accomplish it. Many times
people don't even know the right question to ask to get the best solution.

On Wed, Dec 5, 2018 at 9:18 AM Andrea Martini 
wrote:

> Hi Robert,
> thank you for your suggestion.
> After using of :
>
>
> osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::Options::BUILD_KDTREES);
>
> and
>
> osgUtil::IntersectionVisitor iv(intersector.get());
> iv.setUseKdTreeWhenAvailable(true);
>
> intersector visitor performances are good again.
>
> Now, the code:
>
> subgraph->accept(iv);
>
> requires (in the same scenes yesterday described) only 0.01 ms.
>
>
> Thank you
>
> Cheers,
> Andrea
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75279#75279
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgUtil::LineSegmentIntersector performance issues

2018-12-05 Thread Andrea Martini
Hi Robert,
thank you for your suggestion.
After using of :  

osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::Options::BUILD_KDTREES);

and 

osgUtil::IntersectionVisitor iv(intersector.get());
iv.setUseKdTreeWhenAvailable(true);

intersector visitor performances are good again.

Now, the code:

subgraph->accept(iv);

requires (in the same scenes yesterday described) only 0.01 ms. 


Thank you 

Cheers,
Andrea

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgUtil::LineSegmentIntersector performance issues

2018-12-04 Thread Robert Osfield
Hi Andrea,

The osg::KdTree is design for the purpose of accelerating intersection
testing.  What you need to do is run the KdTreeBuilder visitor on your
subgraph to generate KdTree for each osg::Geometry in the subgraph, these
then get assigned automaticaly to each osg::Geometry as a Shape.  The
intersection traversals then automatically detect the KdTree when available
and use it instead of the raw primitive data into the Geometry.

I would also strongly recommend upgrading 3.6.3, it even contains some nice
improvement for KdTree building and intersections.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osgUtil::LineSegmentIntersector performance issues

2018-12-04 Thread Andrea Martini
Hello everyone,
i spent my last weeks to find a reasonable cause concerning 
osgUtil::LineSegmentIntersector on some osgt file.
In detail, i would like to identify objects in the scene, using line isector 
(ray casting) starting from a certain point with a ray of 3 meter length .
Following the code i used for detecting object in front of camera (i'm using 
osg 3.5.3 and Oculus Rift device)


Code:


osg::ref_ptr intersector = new 
osgUtil::LineSegmentIntersector(startPoint, endPoint);  

osgUtil::IntersectionVisitor iv(intersector.get());

//intersector->setIntersectionLimit(osgUtil::Intersector::LIMIT_NEAREST);
//intersector->setPrecisionHint(osgUtil::Intersector::PrecisionHint::USE_FLOAT_CALCULATIONS);

//for debugging: evaluation of visitor processing time
osg::Timer_t timer_tstart = mGlobalHighResTimer->tick();

iv.setTraversalMask(vrGame::INTERACTIVE);

subgraph->accept(iv);


//for debugging: evaluation of visitor processing time
osg::Timer_t timer_tend = mGlobalHighResTimer->tick();
double  timer_tfinal = mGlobalHighResTimer->delta_m(timer_tstart, timer_tend);
std::cout << " Collision Visitor Time Computed :  " << 
std::to_string(timer_tfinal) << std::endl;






This code works correctly in terms of dected object but some times i noticed 
low performance when camera points in a space region near the object but not on 
its geometry. I mean, if camera points the geometry of the object, performance 
is ok. When camera points near the object (on an empty region) but not on its 
geometry, performance drop down.

Some numbers: When camera points on empty area near the object, Oculus passes 
from 90Hz to 45Hz framerate and the computation of 

subgraph->accept(iv);

requires from 2.8 to 4 milliseconds for each frame. 
I also investigated on osgUtil::IntersectionVisitor class, and it seems that 
(in my specific situation), 

IntersectionVisitor::apply(osg::Transform& transform) 

needs from 2.8 to 4 ms computation time when processes the following code lines:

 // now push an new intersector clone transform to the new local oordinates
push_clone();
traverse(transform);
// pop the clone.
pop_clone();



Another doubt is related to why, even if i set 

iv.setTraversalMask(0x0001001)

for avoiding to process nodes which have that mask (and the investigated object 
has this mask), visitor continues to process at each frame something that 
requires a lot computation time.

The object comes from blender (osgt export), and has One group as root, a 
MatrixTransform as child, a Geode as child and 3 drawables with 64K vertices on 
the whole. The osgt file has 18 Mbytes size


My question is: Is there some solution I might adopt to improve these 
performances? Can you give me some suggestions?


Thank you!

Cheers,
Andrea

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org