Question

I've created a simple DirectX app that renders a field of vertices. Vertices are rendered like this (if viewed from top):

|\|\|\|\|
|\|\|\|\|

Each triangle is rendered like this:

1
|\
2 3

Which should mean that the polygon is counterclockwise and not be rendered, but it is. Anyway when viewed from top the plane is perfect.

However, when viewed from another level some polygons are sort of transparent and you can see geometry behind them. I've highlighted some of the place where this is happening.

I am thinking this is some of the basic, beginner problems. What am I missing? My rasterizer description is such:

new RasterizerStateDescription
                                {
                                    CullMode = CullMode.Front,
                                    IsAntialiasedLineEnabled = true,
                                    IsMultisampleEnabled = true,
                                    IsDepthClipEnabled = true,
                                    IsFrontCounterclockwise = false,
                                    IsScissorEnabled = true,
                                    DepthBias = 1,
                                    DepthBiasClamp = 1000.0f,
                                    FillMode = FillMode.Wireframe,
                                    SlopeScaledDepthBias = 1.0f
                                };

alt text

Was it helpful?

Solution 2

Turned out I just had no depth-stencil buffer set up. Oh well.

OTHER TIPS

This is by design. FillMode.Wireframe only draws edges of each triangle as lines. That's all.

Do a first pass with a solid fill mode and depth writes on and a color mask (RenderTargetWriteMask in D3D11 terminology), and a second one with depth test on (but depth writes off) and wireframe mode on. You will probably need depth bias too since lines and triangles are not rasterized the same way (and their z can differ at equal fragment position).

BTW, this technique is known as hidden line removal. You can check this presentation for more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top