Sign in to follow this  
ddengster

triangle culling in close proximity to other triangles?

Recommended Posts

As you can see in the image, when my object partially intersects the ground, the triangles get culled (backface culling is on), which shouldnt happen. My best guess as to why this happens is that directx culls entire triangles when it detects a portion of the triangle behind another. Is this true, and how can i render these triangles even such that backface culling is still turned on?

Share this post


Link to post
Share on other sites

Hello,

 

haha, it would probably help if I knew what I was looking at ;)

 

But have you ruled out the possibility of inverted normals on the mesh, with BF culling that would certainly create the issue of triangles not appearing...

 

Marcus Hansen

Edited by markypooch

Share this post


Link to post
Share on other sites

My best guess as to why this happens is that directx culls entire triangles when it detects a portion of the triangle behind another. Is this true, and how can i render these triangles even such that backface culling is still turned on?

It's not true. Depth testing happens on a per-pixel basis and is unrelated to backface culling.

It could be "z-fighting", which is where there's not enough precision in the depth buffer to properly tell which pixel is in front of each other. What is the format of your depth buffer resource, and what's the 'near' and 'far' values used in your projection matrix?

Share this post


Link to post
Share on other sites

 

My best guess as to why this happens is that directx culls entire triangles when it detects a portion of the triangle behind another. Is this true, and how can i render these triangles even such that backface culling is still turned on?

It's not true. Depth testing happens on a per-pixel basis and is unrelated to backface culling.

It could be "z-fighting", which is where there's not enough precision in the depth buffer to properly tell which pixel is in front of each other. What is the format of your depth buffer resource, and what's the 'near' and 'far' values used in your projection matrix?

 

 

I'm using DXGI_FORMAT_D24_UNORM_S8_UINT.

Near - far distance is: 0.1 to 250, i tweaked it and still got the bugged results

Share this post


Link to post
Share on other sites

Im going to guess it is a depth buffer issue. I would also run it through PIX or Nsight.to get more information.

 

Also, is that the Fruity Loops logo?

Edited by ExErvus

Share this post


Link to post
Share on other sites

At first I ruled out Depth Buffer issue, because as Hodge mentioned, Depth testing occurs at a per pixel level, not a per primitive level, so back face culling shouldn't be involved. 

However, in the picture you just posted I do see what seems to be Z Fighting on your last rock.

 

A few questions,

 

1. Can we see your depth buffer creation code, preferably all the way up to you bind it to the Output Merger. 

 

2. Are the Rock Models completely perpendicular to the ground model, or is the camera pitched at a 45d (0.78 in radians), or is the camera looking straight down the Y-Axis?

 

Marcus Hansen

Edited by markypooch

Share this post


Link to post
Share on other sites

At first I ruled out Depth Buffer issue, because as Hodge mentioned, Depth testing occurs at a per pixel level, not a per primitive level, so back face culling shouldn't be involved. 

However, in the picture you just posted I do see what seems to be Z Fighting on your last rock.

 

A few questions,

 

1. Can we see your depth buffer creation code, preferably all the way up to you bind it to the Output Merger. 

 

2. Are the Rock Models completely perpendicular to the ground model, or is the camera pitched at a 45d (0.78 in radians), or is the camera looking straight down the Y-Axis?

 

Marcus Hansen

 

1)

/************** Setup ************/
// Create depth stencils
  D3D11_TEXTURE2D_DESC descDepth;
  ZeroMemory(&descDepth, sizeof(D3D11_TEXTURE2D_DESC));
  descDepth.Width = texture2ddesc.Width;
  descDepth.Height = texture2ddesc.Height;
  descDepth.MipLevels = 1;
  descDepth.ArraySize = 1;
  descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; //24 bits for depth, 8 bits for stencil
  descDepth.SampleDesc.Count = 1;
  descDepth.SampleDesc.Quality = 0;
  descDepth.Usage = D3D11_USAGE_DEFAULT;
  descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL;
  descDepth.CPUAccessFlags = 0;
  descDepth.MiscFlags = 0;

  //maincontext->mDepthStencilTexture is of type ID3D11Texture2D*
  hr = GetDevice()->CreateTexture2D(&descDepth, NULL, &maincontext->mDepthStencilTexture);
  if (hr != S_OK)
  {
    ASSERTLOGC(0, "Failed to create DepthStencil for swap chain");
    return false;
  }

  // Create the depth stencil view
  D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
  ZeroMemory(&descDSV, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC));
  descDSV.Format = descDepth.Format;
  descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
  descDSV.Texture2D.MipSlice = 0;
  
  //maincontext->mDepthStencilView ID3D11DepthStencilView
  hr = GetDevice()->CreateDepthStencilView(maincontext->mDepthStencilTexture, &descDSV, &maincontext->mDepthStencilView);
  if(hr != S_OK)
  {
    ASSERTLOGC(0, "Failed to create DepthStencilView for swap chain");
    return false;
  }

/************** Binding code ************/
mContext->OMSetRenderTargets(1, &mFrameBufferRT, mDepthStencilView);

2) My camera is not looking straight down, but slight downwards. the rock models are on a flat xz plane.

 

Also, the rocks flicker a little as I zoom the camera in and out, so it's probably z-fighting like you guys said.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this