Jump to content

  • Log In with Google      Sign In   
  • Create Account

ddengster

Member Since 19 May 2008
Offline Last Active Today, 04:01 AM

Posts I've Made

In Topic: triangle culling in close proximity to other triangles?

29 April 2016 - 10:54 PM

ah ok. fixed the problem. turned out to be a frontface winding issue


In Topic: triangle culling in close proximity to other triangles?

29 April 2016 - 09:33 AM

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.


In Topic: triangle culling in close proximity to other triangles?

29 April 2016 - 12:02 AM

the model is meant to a rock. the one in the middle is the rock floating in the air, the rest are touching the ground


In Topic: triangle culling in close proximity to other triangles?

28 April 2016 - 05:49 AM

 

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


In Topic: Is there a named algorithm for this method of splitting a large triangle into...

22 April 2016 - 10:26 AM

 

 

I don't know of a name, but here's a version I like better:
- For each side of the triangle, check if it's longer than some threshold.
- If all 3 sides are too long, divide the triangle into 4 triangles.
- If 2 sides are too long, divide the triangle into 3 triangles (there are 2 ways to do this).
- If 1 side is too long, divide the triangle into 2 triangles.

This has the huge advantage that the subdivision can be done independently in triangles of the same triangulation without introducing cracks.

Here's an even simpler version with the same feature:
- Pick the longest side.
- If it's longer than some threshold, divide the triangle into 2 triangles.

 
Regarding the first method, how is it that you can ensure no cracks? For the 2 sides too long case, when you subdivide into 3 triangles (with a 'z' pattern), the edge that is split in half has an alternative face which may not comprise of the same vertex. If you animate the vertices, you would see cracks.

 


I don't understand the problem. Both methods ensure no cracks by making the criterion for splitting an edge depend only on features of the edge. Cracks only happen when two triangles share an edge and you decide to split the edge on one triangle but not in the other.

 

Yea, I was thinking of that shared edge case you mentioned. thanks for the heads up


PARTNERS