Direct3D: wireframe without diagonals

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

I need to render a Direct3D model in an isometric wireframe view. The rendered scene should display the boundaries of the model boundaries, but should exclude diagonals.

+1


source to share


3 answers


Getting rid of the diagonals is tricky as the hardware will most likely only draw triangles and it would be difficult to determine which edge is the diagonal. Alternatively, you can apply a wireframe texture (or a shader that creates a suitable texture). This would solve the hidden line problems, but it would look strange since the line thickness would depend on the z distance.



Using line primitives is not trivial, although surfaces facing away from the camera can be easily removed, partially hidden surfaces require manual clipping. As a final thought, take a two-pass approach: the first pass draws filled polygons, but only draws to buffer z, and then draws lines on top with a suitable z offset. This will be due to a partially hidden surface problem.

+2


source


Built-in wireframe mode displays the edges of primitives. As in D3D, primitives are triangles (or lines, or points, but not arbitrary polygons), which means that the built-in way will not clip it.

I think you need to look for some kind of boundary detection algorithms. They can work in image space where you render the model in a texture, assign a unique color to each logical polygon, and then do post-processing using a pixel shader and detect any color changes (color changes = output black, otherwise output something yet).



Alternatively, you can create a list of strings that only have the faces you want and just render them.

Another alternative might be to use geometry shaders in Direct3D 10. Somehow, there might be a lot of different options here.

+1


source


I guess you will need to draw this line by hand, since wireframe mode is inline mode, so I don't think you can change that. You can get a list of vertices in your mesh and process them into a list of lines to draw.

0


source







All Articles