Solid + Wireframe not working too good

Started by
7 comments, last by don 17 years, 10 months ago
I'm rendering a model in solid + wireframe mode (first solid then wireframe to better show the edges). However, as shown in the image, some lines appear partially visible (dotted). I'd guess this is a float-resolution problem but since I use the same mesh with the same matrix it should result in the same interpolated positions, right? What could be wrong? I have a lot of code, but my general procedure: ¤ Set world/view/projection matrices ¤ Set fillmode to SOLID ¤ Render mesh ¤ Set fillmode to WIREFRAME ¤ Render mesh The Z-func is LESSEQUAL so the wireframe it *should* render properly above the solid.
----------------------------------------MagosX.com
Advertisement
Perhaps you could scale it a small amount before rendering the wireframe?
---------------------My specs (because I always forget to post them)Intel P4 2.4 GHz640 MB system memoryRadeon 9700 PROWindows XPDirectX 9DirectX 8.1 SDK
Quote:Original post by TWild
Perhaps you could scale it a small amount before rendering the wireframe?
I second this suggestion. The other, slightly more complex, method is to extrude a small amount along each vertices normal - you'd need either a vertex shader or a secondary mesh though.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

You can do this with the stencil buffer. Draw the wireframe first, generating a mask in the stencil buffer. Then draw the solid polys, filling every pixel that wasn't set in the mask.
Also try the D3DRS_DEPTHBIAS render state. If you give the wire a small bias it will not Z-fight with the mesh.
don: What about "hidden" faces then? Lines that shine though the wireframe but not the solid one will screw things up!

M-knight: This did give a somewhat better look, however other artifacts appeared like parts of lines showing that should not show.

I'm more interested in an explanation WHY this occurs rather than hacking some workaround. The both renders should give the same z-value so why doesn't LESSEQUAL work as it should work, on the EQUAL part?
----------------------------------------MagosX.com
While the wireframe of the backfaces won't be drawn, occluded front-facing triangles would be a problem (i.e. if your mesh contains concave sections) using the method I mentioned.




Quote:I'm more interested in an explanation WHY this occurs rather than hacking some workaround


I would guess, as I'm kinda new to this, that it is similar to "z-fighting" - both the wireframe and the tri fills are on the same plane and are fighting to be shown.
---------------------My specs (because I always forget to post them)Intel P4 2.4 GHz640 MB system memoryRadeon 9700 PROWindows XPDirectX 9DirectX 8.1 SDK
Quote:I'm more interested in an explanation WHY this occurs rather than hacking some workaround. The both renders should give the same z-value so why doesn't LESSEQUAL work as it should work, on the EQUAL part?



Just a guess but I would imagine this is happening because the fill rules for lines are different than those used for filling triangles. The wireframe fill mode is usually drawn using line segments and lines follow GDI's GIQ diamond convention, rather than the top-left fill method used to rasterize triangles.

This topic is closed to new replies.

Advertisement