Hidden Line Removal

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Hidden Line Removal

Post by aheymann »

Hallo

I would like to display a scene, but with hidden lines removed. I have read various articles about enabling Z buffers and/or stencil buffers. Here is a 'definition' of hidden line removal :

http://en.wikipedia.org/wiki/Hidden_line_removal

Can anybody please provide me with some ideas?

Thanks

Anton
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Simply enable the wireframe mode, which will give you that effect automatically.
Bob Finnie
Posts: 49
Joined: Tue Jan 23, 2007 12:36 pm
Location: Bedford, UK

Post by Bob Finnie »

Does this hide the lines that shouldnt be visible though? I thought the wireframe mode showed all lines...
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Why not take 5 seconds to modify one of the example programs and see for yourself?

Travis
Bob Finnie
Posts: 49
Joined: Tue Jan 23, 2007 12:36 pm
Location: Bedford, UK

Post by Bob Finnie »

I did and it dosen't.

smartarse
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

A simply approach for the fixed pipeline: Use an invisible version of the mesh, scaled by 0.999 in all dimensions, and turn of the color write.This should fill the zbuffer in order to avoid painting the wires at positions invisible from the current viewpoint. Pretty much the same as for the outline rendering, just that the inner mesh is invisible this time.
Not rendering the full tris of the wireframe is not possible without much manual rendering, though, and lots of edge detection and stuff AFAIK.
Bob Finnie
Posts: 49
Joined: Tue Jan 23, 2007 12:36 pm
Location: Bedford, UK

Post by Bob Finnie »

Hi Hybrid,
This may be something I will implement as I too need 'retro style' wireframe graphics..
Just a couple of questions though:

1/ You mention 'color write', what is color write and how do I turn it off?
2/ When you say invisible mesh for the inner part - presumably you dont mean:

Code: Select all

 scenenode->setVisible(false);
as this would not render anything.. could you clarify please?

Many Thanks,
Bob
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

Scaling would not be the proper operation to get the hidden-line effect, but to shift the vertices along the normals a bit inside the object, and then, proceed exactly as Hybrid has suggested.

Or a 2 passes effect, where the first renders only the Zbuffer of the scene, and, without clearing the Zbuffer, the next renders only the wireframe lines.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, I meant the latter: First render the mesh into the zbuffer, then render the wireframe.
ColorMask can be set in SMaterial in SVN/trunk (i.e. Irrlicht 1.6).
Bob Finnie
Posts: 49
Joined: Tue Jan 23, 2007 12:36 pm
Location: Bedford, UK

Post by Bob Finnie »

Thanks Hybrid. I guess I'll wait for the official 1.6 release then to try it.

Just out of curiosity, Why hasn't Irrlicht got a basic Hidden line removal algortihm in? Is it harder to implement than I imagine?

In any case I think it would be a great addition to a great renderer.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I guess it's of not much use for usual games. And it's also not a typical material property. So it's up the some user to prepare such an effect, could be added to irrExt then maybe.
cassini
Posts: 68
Joined: Thu May 12, 2005 2:40 pm

Post by cassini »

Actually it is not necessary to do any scaling at all, two passes do the trick very well.
First past a zbuffer write with alpha test set to never write to the color buffer,
The second pass set to write if buffer is equal or less.
If you do a line thickness in OpenGl the resulting image looks just like Maya, or Xsi wire frame render.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, guess I should try now :)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, just as cassini suggested. Works right away, just render the mesh two times. First with ColorMask set to ECP_NONE, then with wireframe enabled, ZBuffer set to ECF_LESSEQUAL (to avoid missing lines where the mesh is intersecting the wireframe) and Thickness set tom something larger than 1.f for better recognizable effect (the latter only works under OpenGL). Looks terrific 8)
Post Reply