DirectX rendering Transparency

14 views Asked by At

When i draw cubes over DirectX (SharpDX wrapper) i get the next behaviour: enter image description here From one side i see pipe laying inside cubes and i do not see back cubes. enter image description here From the other side i see back cubes and pipe. There is a code by which i initialize depth buffer:

    private void InitializeDepthBuffer() {

      var depthStencilDesc = new DepthStencilStateDescription {
        IsDepthEnabled = true,
        DepthWriteMask = DepthWriteMask.All,
        DepthComparison = Comparison.Always,
        IsStencilEnabled = false
      };

      var depthStencilState = new DepthStencilState(_device3D, depthStencilDesc);
      _context3D.OutputMerger.SetDepthStencilState(depthStencilState);

      var depthBufferDesc = new Texture2DDescription {
        Width = Width,
        Height = Height,
        ArraySize = 1,
        MipLevels = 1,
        Format = Format.D24_UNorm_S8_UInt,
        SampleDescription = new SampleDescription(1, 0),
        Usage = ResourceUsage.Default,
        BindFlags = BindFlags.DepthStencil,
        CpuAccessFlags = CpuAccessFlags.None,
        OptionFlags = ResourceOptionFlags.None
      };

      var depthBuffer = new Texture2D(_device3D, depthBufferDesc);

      var depthStencilViewDesc = new DepthStencilViewDescription {
        Format = depthBufferDesc.Format,
        Dimension = DepthStencilViewDimension.Texture2D
      };

      _depthStencilView = new DepthStencilView(_device3D, depthBuffer, depthStencilViewDesc);
      _context3D.OutputMerger.SetTargets(_depthStencilView, _renderTargetView);
    }

and inside RenderLoop I do:

_context3D.ClearDepthStencilView(_depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);

I want to delete transparency. But i do not know direction in which to move. Please, help

I want to avoid transparency

0

There are 0 answers