Solid + Wireframe not working too good
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.
Quote:Original post by TWildI 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.
Perhaps you could scale it a small amount before rendering the wireframe?
hth
Jack
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?
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?
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.
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
Popular Topics
Advertisement