What is the easiest way to get a clean wireframe over the same mesh that has its polys filled?

At the moment, (because of z-fighting i assume) a simple fill version draw then wire version draw has patchy wireframe lines. Apart from displacing the wireframe ever-so-slightly from the filled surface, is there a way of getting clean wires?

dletozeun

02-11-2009, 03:49 PM

Instead of scaling the object, you can move each vertex along its normal when drawing the wired object. This way you are sure that whatever the object dimensions, all its vertices with displaced of the same distance. (This is not the case with a uniform scale).

MaxH

02-11-2009, 05:51 PM

One quick and dirty solution is to set the line thickness to 3 or more pixels.

Simon Mihevc

02-12-2009, 01:32 AM

Moving wireframe mesh a little towards the camera works really well.

Jan

02-12-2009, 01:41 AM

The best and easiest that i have been able to come up with is to write a vertex-shader, that moves the vertices into the direction of the viewer. This is pretty simple to do, render you mesh as when you fill it only with fill-mode set to lines. Then use this vertex shader:

This first transforms the vertex into camera space, than scales it, such that it moves to the camera, and finally applies the projection. Results are perfect because since it is a scaling it moves the vertex more at the far-plane and less at the front-plane.

Hope that helps,
Jan.

appleGuy

02-12-2009, 05:39 AM

Good Answers :)

Thanks guys

Dark Photon

02-12-2009, 06:40 AM

glPolygonOffset?

pjcozzi

02-12-2009, 04:45 PM

Also, check out this one page paper: Single-pass Wireframe Rendering (http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/4884/pdf/imm4884.pdf). A fragment shader is used to compute the shortest distance from a fragment the triangle's edges. This distance is then mapped to an intensity. Sounds pretty straightforward to implement although I've never coded it.

Patrick

appleGuy

02-14-2009, 01:51 PM

Also, check out this one page paper: Single-pass Wireframe Rendering (http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/4884/pdf/imm4884.pdf). A fragment shader is used to compute the shortest distance from a fragment the triangle's edges. This distance is then mapped to an intensity. Sounds pretty straightforward to implement although I've never coded it.

Patrick

That looks like a clever, but simple solution .. Thanks For That Link!