Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Wireframe problems

1 view
Skip to first unread message

Oane Mizguel

unread,
Aug 22, 2005, 6:19:43 PM8/22/05
to
Hi

I'm drawing some meshes, and I've got a Direct3D.Line array
representing wireframe of my objects.
My problem is I don't know how to setup z-buffer to work properly with
lines :(
If I turn z-buffer on some of edge-placed lines are 'floating'.
If I turn z-buffer off I see a mess on screen (too many lines).
Is there any way to decrease all z-buffer values by some small value?
Or should I change projection matrix or sth...

Zman

unread,
Aug 22, 2005, 9:21:52 PM8/22/05
to
with Wirefream you would normally expect to see all the lines. The ZBuffer
shouldn't have much effect other than making sure the pixels of lines that
overlap are in the right order.

Are you trying to draw the lines over the top of a render of the object?

Can you send a couple of picture (or links to a web site) so we can
understand what you are getting and what you expect to see.

--
Zman (mailto:zm...@thezbuffer.com)
http://www.thezbuffer.com
News and Resources for Managed DirectX


"Oane Mizguel" <oanem...@gmail.com> wrote in message
news:1124749183.8...@g44g2000cwa.googlegroups.com...

Oane Mizguel

unread,
Aug 23, 2005, 5:37:57 AM8/23/05
to
with zbuffer off this simple building gets unclear:
http://thinker.virtual.pl/rys/bad_wf1.png
with zbuffer on edges are floating:
http://thinker.virtual.pl/rys/bad_wf2.png

what I want, is to have zbuffer on and get clear edges

(sorry if I write something with mistakes, english isn't my native
language)

Zman

unread,
Aug 23, 2005, 1:38:53 PM8/23/05
to
Thanks that clears things up.

So you are drawing the back faces of your objects and then overlaying the
wireframe edges on the boxes.

The effect you are seeing is called ZFighting and occurs when the Z values
for the pixel that is already rendered is very very close to the one you are
trying to render. If they are equal the pixel doesn't draw, if its slightly
bigger (or smaller I can never remember if z goes into or out of the screen)

Several way to fix it.
1. Use ZBias - this means give priorities to the lines and so they will draw
if the values are equal. I gather not all cards support this though.
2. Change the projection matrices as in Tom Forsyths FAQ entry
http://tomsdxfaq.blogspot.com/2002_07_01_tomsdxfaq_archive.html#79344425


--
Zman (mailto:zm...@thezbuffer.com)
http://www.thezbuffer.com
News and Resources for Managed DirectX


"Oane Mizguel" <oanem...@gmail.com> wrote in message

news:1124789877.5...@f14g2000cwb.googlegroups.com...

Oane Mizguel

unread,
Aug 29, 2005, 8:49:35 AM8/29/05
to
Thx for informations Zman.
It's a shame I couldn't found a sample in C# for that.

Zman

unread,
Aug 29, 2005, 1:07:58 PM8/29/05
to
When you have yours working, why not post it somewhere. I"ll link from
theZBuffer (or if you don't have a website I'll happily host it too)

--
Zman (mailto:zm...@thezbuffer.com)
http://www.thezbuffer.com
News and Resources for Managed DirectX


"Oane Mizguel" <oanem...@gmail.com> wrote in message

news:1125319775.4...@f14g2000cwb.googlegroups.com...

Oane Mizguel

unread,
Aug 29, 2005, 2:12:22 PM8/29/05
to

Zman wrote:
> When you have yours working, why not post it somewhere. I"ll link from
> theZBuffer (or if you don't have a website I'll happily host it too)
>

It could be a long while ;]
I have big project and that my first one in C# and .NET, so I have a
real mess in source code.

btw:
you are kind of supporting person on this group or just you like to
help people? u write here a lot I see ;)

Zman

unread,
Aug 29, 2005, 6:20:28 PM8/29/05
to
I'm nothing official, helping folks here helps me laern things I've not done
before (see the clipping planes thread), helps me create a reputation, gives
me topics to cover for my website and MSDN columns.

And its always good to help folks.

--
Zman (mailto:zm...@thezbuffer.com)
http://www.thezbuffer.com
News and Resources for Managed DirectX


"Oane Mizguel" <oanem...@gmail.com> wrote in message

news:1125339142.1...@g14g2000cwa.googlegroups.com...

Oane Mizguel

unread,
Aug 31, 2005, 11:39:02 AM8/31/05
to
I dunno what you need to ur website exactly, but here is my, I think,
final version what I made by myself.
My solution was to move all wireframe model by a small value in camera
direction.
Code looks like this:
Matrix lineMatrix = device.Transform.World * device.Transform.View *
device.Transform.Projection * Matrix.Translation(0,0,-0.0002f); //
-0.0002 is our z-trick
device.RenderState.ZBufferEnable = true;
foreach(Vector3[][] y in wireframe)
foreach(Vector3[] x in y)
line.DrawTransform(x, lineMatrix, Color.Black);

And working looks like this: http://thinker.virtual.pl/rys/good_wf.png
I know this isn't ideal, but it looks much more better than previous
one (http://thinker.virtual.pl/rys/bad_wf2.png)
Tell me if you will use it somewhere :)

0 new messages