zoukankan      html  css  js  c++  java
  • dx11 入门 Tutorial 05: DepthBuffer的创建 DirectXSampleBrowser(June 2010)

    本课主要是矩阵变换和DepthBuffer的创建;

    笔记:关于depthBuffer

    问题:1.depthBuffer的作用?

            2.怎么创建?

            作用:我想到的:1.depthTest,保证遮挡,同一个pixel中z值小的渲染;  2.三维世界,需要z值来表示近大远小  3.dx中值在1到0之间

                    MSDN的解释:1.depthBuffer存储每个pixel的z值,也可以存储stencil值,常用32bit,24bit用于depth数据 8bit用于stencil数据

                                        2.当一个pixel渲染后,里面保存color值和depth值,如果一个pixel进行二次render(比如物体遮挡overlap),需要进行depthTest,最终决定绘制结果

             怎么创建:The following code in the sample creates a depth buffer (a DepthStencil texture). It also creates a DepthStencilView of the depth buffer so that Direct3D 11 knows to use it as a Depth Stencil texture.

                        首先先用device创建一块buffer,先申请一块ID3D11Texture2D,在填充相应的数据信息,绑定到texture2D上:    

    hr = g_pd3dDevice->CreateTexture2D( &descDepth, NULL,&g_pDepthStencil );//申请g_pDepthStencil一块buffer,绑定DESC相应信息 

                     但现在dx不知道这块buffer干嘛用的

                         所以device创建DepthStencilView并绑定g_pDepthStencil 告诉dx这用来作为depth和stencil存储

       

    下面context设置后台buffer里的 color和depth:

       g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, g_pDepthStencilView );
    

     记住每帧要先进行clear,以保证上帧的数据不影响现在的render

                       

               

  • 相关阅读:
    hdu 3072 Intelligence System(Tarjan 求连通块间最小值)
    HDU 4635 Strongly connected (Tarjan+一点数学分析)
    HDU 2767 Proving Equivalences (Tarjan)
    codeforce 853A Planning
    codeforces 851C Five Dimensional Points(鸽巢原理)
    Lucas模板
    LCA 模板
    hdu 2874 Connections between cities(st&rmq LCA)
    寒假练习赛总结
    ACM常用模板整理
  • 原文地址:https://www.cnblogs.com/dust-fly/p/4231366.html
Copyright © 2011-2022 走看看