Removing lines that are invisible in a wireframe

Started by
17 comments, last by gonssas 17 years, 5 months ago
Hello, can someone give some points about invisible line removal? What are the best algorithms for this? Example: theres a wireframe of a 3d object. The lines that are on the background are "covered" by the "faces" in front of them. So those covered lines are not drawn as if the object was filled. Thanks.
Advertisement
Render the object to only the depth buffer (color writes disabled), then render the wireframe with less-equal z comparison?
In OpenGL, its just a matter of doing:

glPolygonMode(GL_FRONT, GL_LINE);

No idea how to do it in DirectX, though it will be something similar.
Hello,

Thanks for your comments.

Quote:Original post by Zymph
In OpenGL, its just a matter of doing:

glPolygonMode(GL_FRONT, GL_LINE);

No idea how to do it in DirectX, though it will be something similar.


only using a simpler graphics library (Borland). Rendering is done "manually" with lines connection points that are kept in a matrix.

Thanks.
Quote:Original post by Zymph
In OpenGL, its just a matter of doing:

glPolygonMode(GL_FRONT, GL_LINE);

No idea how to do it in DirectX, though it will be something similar.
The OP is asking how to perform hidden line removal, not how to render polygons in wireframe.
Wouldn't that result in the same thing, though? If you're rendering triangles, you can get backface culling through the standard means. Even in wireframe mode, it will still cull the backfaces of the triangles, but end up rendering the front faces as lines. Viola, you've just removed the hidden lines in a wireframe mesh. :D

EDIT: I just saw his response to that, but here's a thought. Can you store your own triangles? Is it ONLY points, or can you get a list of triangles from that? You can always perform your own backface culling, then only pass what's left to be rendered as lines.
Quote:Original post by xycsoscyx
Wouldn't that result in the same thing, though?

Only if the objects are convex, concave objects will still show hidden lines.

IMHO the best solution if you're doing it all manually would be to implement a software zbuffer or similar and use the method _swx_ suggested. Although there are other methods of doing this, the zbuffer method tends to be simple to implement whereas other methods usually have lots of awkward special cases.
Ok, heres an idea...
No clue if its a real thing or not...
but you said you were using a 'simple library'

Assuming you have the ability to create a copy of the screen (buffer) and render back pieces of it in a stencil-like manner...

make a copy of the scene
associate each line in the mesh with a face
render the faces (lines making them up) in back to front order; and for each face also copy from the buffer as a floodfill for the face center

since each succeseive face floodfills the background as it's body, it ends up covering up portions of previous lines that are 'behind' it


Think that might work?


details of implementation depend on what you have... floodfill, stencil, whatever...
P.S.

I think I (above) was just describing the "Painter's Algorithm", however modified to use an image of the background instead of solid color polygons.
Hello and thanks for your comments.

Quote:Original post by _swx_
Render the object to only the depth buffer (color writes disabled), then render the wireframe with less-equal z comparison?


Question: since the program only draws the wireframe (the lines), there's nothing physically "in front" of the backlines.

So that would need the pixels that make up each "face" to get filled in some color in the depth buffer, in order to get something to compare the lines against,, correct?

Thanks.

This topic is closed to new replies.

Advertisement