[osg-users] Straight lines are broken during rotation

Robert Osfield robert.osfield at gmail.com
Sat Jan 27 03:13:07 PST 2018


Hi Adrian,

You tests confirm it's a z fighting issue.  There will be lots of
discussions about zfighting in the osg-users/forum archives as well as
on general internet, go do a google search.

The ComputeNearFarMode setting the OSG provide control how the OSG
computes the near and far distances used when setting up the
projection matrix.  For best precision of the depth buffer you want to
maximum the near/far ratio, this means pulling in the far distances as
much as possible, and pushing out the near distances are much as
possible - the ComputeNearFar modes control the way that  OSG attempts
to optimize this ratio, it's not fall proof though.

If you know exactly what near/far distances are appropriate for your
scene you can just disable the CompureNearFar and set the projection
matrix yourself.

Another approach can be to depth partition your scene, or to use a non
linear depth buffer.  This are both topics that have been discussed
here on osg-users/forum and on the internet so go search these topics.

Robert.




On 27 January 2018 at 03:32, Adrian Jelffs <adrian.jelffs at makai.com> wrote:
> Hi Robert,
>
> Many thanks for your reply. I found that when I add the following lines it fixes the 2D terrain problem.
>
>
> Code:
>
> camera->setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
>         camera->setCullingMode(osg::CullSettings::NO_CULLING);
>
>
>
>
> If I add the following line of code then the problem is much worst:
>
>
> Code:
>
> camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
>
>
>
>
> Would it be possible for you to explain what these are doing or send me a link where I can read about it? I find that the online information is not descriptive enough.
>
> If I add a 3D terrain underneath the 2D terrain then the problem comes back again and the problem looks like the attached image. Even when I add a significant offset to the 2D terrain from the 3D terrain I still get the same results.
>
> I put an offset on the line to check if it was a precision issue and the problem still happens to the line. So I am thinking it must be a Z fighting issue. However, the problem doesn't go away when I zoom in so I thought Z fighting would only be an issue when I zoom out.
>
> When I turn off the 3D and 2D terrains then the single line is fine.
>
> Is there a way to fix this line breaking up issue?
>
> Many thanks for your help!!!
>
> Adrian
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72875#72875
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


More information about the osg-users mailing list