[osg-users] Polygon offset for line geometries, Z-fighting of edges and triangles

248 views
Skip to first unread message

Peter Bako

unread,
Jul 14, 2016, 6:56:46 AM7/14/16
to osg-...@lists.openscenegraph.org
Hi,

In my application, I am manipulating solid 3D models with edges represented by GL_LINES primitiveSet on an osg::Geometry.
The problem is that I cannot use osg::PolygonOffset, to "highlight" the edges (to avoid dashed edges caused by Z-fighting). This was not working at all, I don't see any difference.

Then I checked the osgFX::Scribe effect and I have realized that there is a triangle model renedered with LINE polygon mode

Code:
osg::PolygonMode* polymode = new osg::PolygonMode;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);



I've tried to simulate the edges using triangles with (almost) no surface and set the polygon mode to LINE ...
The result is that now I see complete and "not dashed" lines, but the edges are sometimes blinking and "highlighted" through triangles, even they shouldn't be visible. Please check the attached video.

If it is possible, I would like to avoid using offects with multiple passes to achieve my goal.

I am using osg 3.1.3

Thank you!

Cheers,
Peter

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




Attachments:
http://forum.openscenegraph.org//files/edge_rendering_problem_191.zip
http://forum.openscenegraph.org//files/dashed_255.png


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

Sebastian Messerschmidt

unread,
Jul 14, 2016, 8:03:16 AM7/14/16
to osg-...@lists.openscenegraph.org
Am 14.07.2016 um 13:05 schrieb Peter Bako:
> Hi,
>
> In my application, I am manipulating solid 3D models with edges represented by GL_LINES primitiveSet on an osg::Geometry.
> The problem is that I cannot use osg::PolygonOffset, to "highlight" the edges (to avoid dashed edges caused by Z-fighting). This was not working at all, I don't see any difference.
Yes it is expected to have no effect on lines, since it is call
Polygon-Offset ;-)
You can do it the other way round and use a negative polygon offset on
your solid object and render the lines normally. That should work.
If it is not working you can also modify the projection matrix for the
second set of objects by adding some small offset to the near and far
plane. But I'd recommend not to do this, unless you're using shaders
anyways.
Third option is to physically move the lines along the normal vector of
the first geometry.

>
> Then I checked the osgFX::Scribe effect and I have realized that there is a triangle model renedered with LINE polygon mode
>
> Code:
> osg::PolygonMode* polymode = new osg::PolygonMode;
> polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
>
>
>
> I've tried to simulate the edges using triangles with (almost) no surface and set the polygon mode to LINE ...
> The result is that now I see complete and "not dashed" lines, but the edges are sometimes blinking and "highlighted" through triangles, even they shouldn't be visible. Please check the attached video.
Nay.. Don't do this. Degnerate triangles might end up totally unexpected.
>
> If it is possible, I would like to avoid using offects with multiple passes to achieve my goal.
>
> I am using osg 3.1.3
Cheers
Sebastian
Reply all
Reply to author
Forward
0 new messages