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

                       

               

  • 相关阅读:
    后端开发-Mybatis开发之一
    Zeppelin推荐
    构建Maven项目
    linux使用curl进行WebService接口测试
    html和jsp的区别及优缺点
    Ajax实现Web长连接
    java生成二维码
    Android调用传感器和震动
    【Head First设计模式-读书笔记】装饰者模式
    【Head First设计模式-读书笔记】观察者模式
  • 原文地址:https://www.cnblogs.com/dust-fly/p/4231366.html
Copyright © 2011-2022 走看看