PDA

View Full Version : Hidden lines removal



09-21-2000, 11:57 PM
I try to implement hidden lines removal technique as described in http://www.sgi.com/software/opengl/advanced97/notes/node202.html

The code was follow:

glClear (GL_DEPTH_BUFFER_BIT );
glClear (GL_COLOR_BUFFER_BIT);

glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glDisable(GL_DEPTH_TEST);

glEnable(GL_STENCIL_TEST);
glClear (GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
DRAW_OBDJECT();

glEnable(GL_DEPTH_TEST);

glStencilFunc(GL_EQUAL,1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
DRAW_OBDJECT();

glDisable(GL_STENCIL_TEST);

glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glColor3f (0.0, 0.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

DRAW_OBDJECT();

And what I see: hidden lines removed - OK,
but visible lines somewhere appears as dash lines. How to resolve this problem?

Relic
09-22-2000, 03:04 AM
You draw the black polygons on the same z depth as the front lines. The depth comparison decides which pixels are drawn.
You do not draw some of the line pixels with the last step because of the dept func. GL_LEQUAL should give better results than GL_LESS.

A different and two-pass only algorithm would be to use PoygonOffset like here: http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/001406.html


[This message has been edited by Relic (edited 09-22-2000).]