Jump to content
  • Advertisement
Sign in to follow this  
jkristia

How to fix z - fighting when drawing an edge ?

This topic is 2136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

See attached image. I'm trying to draw edges (not wireframe) onto my boxes, and I hoped I could use DepthBias to prevent z-fighting, but the setting doesn't really seem to make any difference.

 

This is how I draw the edge. The edge is added to the vertex and index buffer while building the geometry.

Before drawing, I set the DepthBias state, tried +- values, but with no difference in output.

 

Is there a way to make prevent this z-fighting between the face and the edge?

			if (obj.EdgeIndexCount > 0)
			{
				rsd = new RasterizerStateDescription()
				{
					CullMode = CullMode.None,
					FillMode = FillMode.Solid,
					DepthBias = -10,
				};
				rc.Context.Rasterizer.State = new RasterizerState(rc.Device, rsd);
				rc.Context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineList;
				m_cbObj.ObjColor = new Vector4(0f, 0f, 0f, 0);
				rc.Context.UpdateSubresource<cbObjStruct>(ref m_cbObj, m_perObjcBuf);
				rc.Context.DrawIndexed(obj.EdgeIndexCount, obj.EdgeIndexStart, 0);
			}

[attachment=17917:zfighting.png]

Share this post


Link to post
Share on other sites
Advertisement

If I'm right this is SharpDx, though I don't have much experience with it, I may have some useful information.

 

In directx there is this structure: D3D11_RASTERIZER_DESC, which should exist in sDx in some manner (like the one above), and in that there is a bool called AntialiasedLineEnable, maybe that can help you.

 

Hope it's useful. wink.png

-MIGI0027

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!