Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sylverstorm

Member Since 29 Oct 2008
Offline Last Active Aug 19 2012 10:22 AM
-----

Posts I've Made

In Topic: Render problem (depth?)

16 August 2012 - 03:03 PM

I made a depth buffer (see code below) and checked if it is the same size as the render target. Unless I'm making a huge mistake somewhere it is. The result of adding in the depth buffer like this is that I do not see any model at all.

The code for creating the buffer is straight below the part where I create the render target. It's probably something simple, but I cannot see what it is. When I have some more time and still cannot fix the problem I might try remaking the project from step 1.
[source lang="csharp"] Texture2DDescription depthBufferDes = new Texture2DDescription() { ArraySize = 1, BindFlags = BindFlags.DepthStencil, Format = Format.D32_Float, Height = form.ClientSize.Height, Width = form.ClientSize.Width, CpuAccessFlags = CpuAccessFlags.None, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default }; var depthBuffer = new Texture2D(dx11Device, depthBufferDes); DepthStencilViewDescription dsViewDes = new DepthStencilViewDescription() { ArraySize = 0, FirstArraySlice = 0, Dimension = DepthStencilViewDimension.Texture2D, Flags = DepthStencilViewFlags.None, Format = Format.D32_Float, MipSlice = 0 }; var depthView = new DepthStencilView(dx11Device, depthBuffer, dsViewDes); DepthStencilStateDescription dsStateDes = new DepthStencilStateDescription() { IsDepthEnabled = true, DepthWriteMask = DepthWriteMask.All, DepthComparison = Comparison.LessEqual, //IsStencilEnabled = false, /*FrontFace = new DepthStencilOperationDescription(){FailOperation = StencilOperation.Keep, Comparison = Comparison.Always, DepthFailOperation = StencilOperation.Increment, PassOperation = StencilOperation.Keep}, BackFace = new DepthStencilOperationDescription(){FailOperation = StencilOperation.Keep, Comparison = Comparison.Always, DepthFailOperation = StencilOperation.Decrement, PassOperation = StencilOperation.Keep}*/ //FrontFace = StencilOperation StencilFailOp/DepthFailOp/PassOp/Func }; var depthState = DepthStencilState.FromDescription(dx11Device, dsStateDes); context.OutputMerger.DepthStencilState = depthState; context.OutputMerger.SetTargets(depthView, renderTarget);[/source]

PARTNERS