Wireframe display

447 views
Skip to first unread message

Adrien Grandemange

unread,
Apr 15, 2013, 7:01:31 PM4/15/13
to os...@googlegroups.com
Hello!

First of all, kudos on the impressive work!
osgjs brings the advantages of osg's clean and flexible API using idiomatic javascript, it's a real pleasure to use!

Now for my question: I'm looking for a way to render generated meshes as wireframe, for debugging purpose.
With osg, I would use something like this:

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

However in WebGL, you can't control the polygon mode. I was wondering if osgjs provided a clean alternative to that.
I came across this paper describing how to perform shader-based wireframe drawing. Is there something like this available in osgjs?
If not, is there any existing plan to do add such functionality?

I'm willing to contribute this feature if there are no plans already, since I very much need it, and I'm pretty sure it could be useful to many people besides me.
I'm still very new to osgjs, so I might need some directions on how to integrate this in an elegant way.

Thanks.
Adrien

Cedric Pinson

unread,
Apr 16, 2013, 8:58:38 PM4/16/13
to os...@googlegroups.com
Hi Adrien,

On Apr 15, 2013, at 19:01 , Adrien Grandemange <itsm...@gmail.com> wrote:

Hello!

First of all, kudos on the impressive work!
osgjs brings the advantages of osg's clean and flexible API using idiomatic javascript, it's a real pleasure to use!

Now for my question: I'm looking for a way to render generated meshes as wireframe, for debugging purpose.
With osg, I would use something like this:

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

However in WebGL, you can't control the polygon mode. I was wondering if osgjs provided a clean alternative to that.
I came across this paper describing how to perform shader-based wireframe drawing. Is there something like this available in osgjs?
If not, is there any existing plan to do add such functionality?
There is a flag in the osg exporter to generate only the wireframe model, maybe it can helps. It's how I use it
osgconv -O "useExternalBinaryArray mergeAllBinaryFiles enableWireframe" file.osg wireframe.osgjs


I'm willing to contribute this feature if there are no plans already, since I very much need it, and I'm pretty sure it could be useful to many people besides me.
I'm still very new to osgjs, so I might need some directions on how to integrate this in an elegant way.

Thanks.
Adrien
Cheers,
Cedric

--
You received this message because you are subscribed to the Google Groups "osgjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osgjs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Adrien Grandemange

unread,
Apr 17, 2013, 5:03:46 PM4/17/13
to os...@googlegroups.com
Hi Cedric,

Well, the thing is: I'm generating geometry on the fly directly in javascript, the main use for wireframe would be debugging the generated geometry.
Thus, going through osg and the exporter would only make things more complex. Alternatively, I could generate lines from the triangle.

But I'm thinking, having a wireframe shader available as a utility might be of some use to other people beyond me.
It would be convenient to be able to switch display mode on the fly, without intrusive code to do so.

If there is no plan for such utility and if you don't have any objection, I'll just move forward and implement that.

Adrien

Cedric Pinson

unread,
Apr 17, 2013, 5:40:24 PM4/17/13
to os...@googlegroups.com

Adrien Grandemange

unread,
Apr 27, 2013, 3:49:46 PM4/27/13
to os...@googlegroups.com
Hello,

So, I looked into the link you provided, and the paper it was inspired from, and a problem appeared.
I'm using indexed geometry, and thus it is impossible to generate baricentric information for all triangles as a vertex attribute.
In some cases where a particular vertex is shared among multiple triangles, there are constraints which are impossible to resolve.

The original paper implemented this with a geometry shader, which both fixes this particular issue in addition to removing the need for an additional vertex attribute.
However, since geometry shaders are not available in OpenGL ES, this solution can't be applied.

I will stick to generating GL_LINES primitives instead.

Thanks for the replies anyway.
Reply all
Reply to author
Forward
0 new messages