glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
WireColor(1,1,1);
glLineWidth(1);
Draw(GL_POLYGON); //draw the wireframe with GL_POLYGON
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(2.0, 2.0);
WireColor(0,0,0);
Draw(GL_POLYGON); //draw the wireframe with GL_POLYGON
glDisable(GL_POLYGON_OFFSET_FILL);
hidden line removal (NOT done yet...)
hi.
I use this algorithm for the red book for hidden line removal and yet it does not work well.
is there something i'm missing?
do i have to disable/enable some stuff when i use this?
can someone please point me to a code of a working example?
[Edited by - white skies on December 26, 2005 3:06:56 PM]
yet it does not work well. [\quote]
Can u tell what happens ? A picture will be helpfull
Original post by _gl_coder_one_Quote: yet it does not work well. [\quote]
Can u tell what happens ? A picture will be helpfull
Here a picture:
http://img324.imageshack.us/img324/8316/wiredal9dq.jpg
As you can see, Some of the hidden lines are not being drawn (for example in his
hands and arms.
but we can see the lines in the connection points in the shoulders and that thing in his mid section that should be hidden inside. :/
http://img332.imageshack.us/img332/9774/wiredal28br.jpg
And here - those 3 circles are supposed to be in the front - but we can them through the back.
From what I can tell, you need to make some kind of occlusion to happen, since what you got now is standard backface-culling.
BUT, you've probably already noted this yourself.. hehe.
Is it really worth the bother to remove the "hidden" lines...? I dont think any of the major graphics programs do what you're trying to achive! :)
Also, creating occlusion volumes for all objects will slow down performance a LOT more than actually drawing the hidden lines!
Cheers!
and
Merry Christmas! :D
BUT, you've probably already noted this yourself.. hehe.
Is it really worth the bother to remove the "hidden" lines...? I dont think any of the major graphics programs do what you're trying to achive! :)
Also, creating occlusion volumes for all objects will slow down performance a LOT more than actually drawing the hidden lines!
Cheers!
and
Merry Christmas! :D
This as interesting problem, and you're half there already.
Unfortunately, I've never used glPolygonOffset, so I don't have any kind of intuitave understanding of what it's arguments should be.
I would try to figure it out step by step:
1) Just draw your object with solid polygons: no wireframe, no offset, etc
2) Use existing examples online to draw your wireframe on top of the object (see 'polyoff' at http://www.opengl.org/resources/code/basics/redbook/). You results should look just like that.
From there, it's just a matter of filling in the depth buffer without actually drawing any color. This can be accomplished easily with a glColorMask added before step 1, and undoing the color mask between steps 1 and 2.
One other note, I don't see any stencil buffer usage in your sample code, so why are you enabling it?
Unfortunately, I've never used glPolygonOffset, so I don't have any kind of intuitave understanding of what it's arguments should be.
I would try to figure it out step by step:
1) Just draw your object with solid polygons: no wireframe, no offset, etc
2) Use existing examples online to draw your wireframe on top of the object (see 'polyoff' at http://www.opengl.org/resources/code/basics/redbook/). You results should look just like that.
From there, it's just a matter of filling in the depth buffer without actually drawing any color. This can be accomplished easily with a glColorMask added before step 1, and undoing the color mask between steps 1 and 2.
One other note, I don't see any stencil buffer usage in your sample code, so why are you enabling it?
ok.. i'll check it out.
it looks like what i need [smile]
but i have a few question
1. How should i draw my object? GL_POLYGON\GL_FILL...?
I tried using GL_FILL - but it paint my object white.
2. I didn't quite understand step 2 and this glMaskColor - what is it used for?
ah... and the stencil buffer stuff - just remained there from something else i tried :)
[Edited by - white skies on December 26, 2005 1:07:20 PM]
it looks like what i need [smile]
but i have a few question
1. How should i draw my object? GL_POLYGON\GL_FILL...?
I tried using GL_FILL - but it paint my object white.
2. I didn't quite understand step 2 and this glMaskColor - what is it used for?
ah... and the stencil buffer stuff - just remained there from something else i tried :)
[Edited by - white skies on December 26, 2005 1:07:20 PM]
aaah... that should do it! :)
Draw a z-pass first, with solid geometry - color/textures doesn't matter.
glColorMask(false, false, false, false); etc...
then
enable colormask, disable depthwriting ( glDepthMask(false) )
and draw the wireframe overlay.. :)
this way things will only be drawn where it's visible to the user. :)
You might need to offset/enlarge the geometry slightly thou, just in case it gets drawn "behind" the z-depth values...
Peace, and hope it works out! :)
Draw a z-pass first, with solid geometry - color/textures doesn't matter.
glColorMask(false, false, false, false); etc...
then
enable colormask, disable depthwriting ( glDepthMask(false) )
and draw the wireframe overlay.. :)
this way things will only be drawn where it's visible to the user. :)
You might need to offset/enlarge the geometry slightly thou, just in case it gets drawn "behind" the z-depth values...
Peace, and hope it works out! :)
Quote:Original post by Rasmadrak
aaah... that should do it! :)
Draw a z-pass first, with solid geometry - color/textures doesn't matter.
glColorMask(false, false, false, false); etc...
then
enable colormask, disable depthwriting ( glDepthMask(false) )
and draw the wireframe overlay.. :)
this way things will only be drawn where it's visible to the user. :)
You might need to offset/enlarge the geometry slightly thou, just in case it gets drawn "behind" the z-depth values...
Peace, and hope it works out! :)
it gives me almost the same result.
(it still looks like a wireframe with back-face culling but now it only deletes some parts of some lines when i change the point of view but not all the needed ones) :(
SetWireColor(0,0,0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glColorMask(false, false, false, false);
WireDraw(GL_POLYGON);
glColorMask(true, true, true, true);
glDepthMask(false);
SetWireColor(1,1,1);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
WireDraw(GL_POLYGON);
[Edited by - white skies on December 28, 2005 12:15:13 PM]
im not an avid opengl user, but purhaps the wireframe rendering your method uses is not testing itself against the values in the zbuffer? I wouldnt be surprised since it would not make sense to update the zbuffer, with wireframe values. I know in directx wireframe mode the line geometry is affected by the z-buffer, so this method should be exactly what you are looking for. Purhaps try rendering the solid geometry (instead of your wireframe pass) with some transparancy. This would tell you that the first filling of zbuffer values is correctly working and that your second pass is correctly being tested against the zbuffer.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement