views:

1164

answers:

3

When using wireframe fill mode in Direct3D, all rectangular faces display a diagonal running across due to the face being split in to two triangles. How do I eliminate this line? I also want to remove hidden surfaces. Wireframe mode doesn't do this.

I need to display a Direct3D model in isometric wireframe view. The rendered scene must display the boundaries of the model's faces but must exclude the diagonals.

+1  A: 

Getting rid of the diagonals is tricky as the hardware is likely to only draw triangles and it would be difficult to determine which edge is the diagonal. Alternatively, you could apply a wireframe texture (or a shader that generates a suitable texture). That would solve the hidden line issues, but would look odd as the thickness of the lines would be dependant on z distance.

Using line primitives is not trivial, although surfaces facing away from the camera can be easily removed, partially obscured surfaces would require manual clipping. As a final thought, do a two pass approach - the first pass draws the filled polygons but only drawing to the z buffer, then draw the lines over the top with suitable z bias. That would handle the partially obscured surface problem.

Skizz

Skizz
Using the two pass approach, I have another problem. I am not using textures. So, I think the wireframe will be the same color as the fill and won't be visible!
Vulcan Eager
The first pass only draws to the z-buffer, the image buffer is left unchanged (so you can see through the wire frame). The image buffer is only updated on the second pass. It's been a while since I did any D3D stuff so I'm not sure about the practicality of the first pass.
Skizz
A: 

The built-in wireframe mode renders edges of the primitives. As in D3D the primitives are triangles (or lines, or points - but not arbitrary polygons), that means the built-in way won't cut it.

I guess you have to look up some sort of "edge detection" algorithms. These could operate in image space, where you render the model into a texture, assigning unique color for each logical polygon, and then do a postprocessing pass using pixel shader and detect any changes in color (color changes = output black, otherwise output something else).

Alternatively, you could construct a line list that only has the edges you need and just render them.

Yet another alternative could be using geometry shaders in Direct3D 10. Somehow, lots of different options here.

NeARAZ
A: 

I think you'll need to draw those line manually, as wireframe mode is a built in mode, so I don't think you can modify that. You can get the list of vertex in your mesh, and process them into a list of lines that you need to draw.

faulty