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

时间: 2024-07-30 13:38:11

dx11 入门 Tutorial 05: DepthBuffer的创建 DirectXSampleBrowser(June 2010)的相关文章

dx11 入门 Tutorial 03: 什么是shader DirectXSampleBrowser(June 2010)

对shader的认知: shader是什么? In Direct3D 11, shaders reside in different stages of the graphics pipeline. They are short programs that, executed by the GPU, take certain input data, process that data, and then output the result to the next stage of the pip

dx11 入门篇 Tutorial 01: 基本要素的创建 DirectXSampleBrowser(June 2010)

目标:这几天迅速入门dx11 第一讲主要是基本要素的创建:device .context.view.swap: 笔记: 1.In Direct3D 10, the device object was used to perform both rendering and resource creation. In Direct3D 11, the immediate context is used by the application to perform rendering onto a buf

dx11 入门 Tutorial 02: 数据传入GPU的设置 和绘制一个三角形 DirectXSampleBrowser(June 2010)

烦...一年前看过教程,但全忘掉了,这一年我都干什么了... 教程2遇到的两个error: error 1:ID3DBlob调用不成功 ,是重复调用版本冲突的原因?ID3DBlob在D3DCommon.h中, 因为window include里和SDK里各有一份,造成了冲突,修改头文件的调用,先调用SDK内的即可.参考:http://www.cnblogs.com/Wilson-Loo/archive/2013/01/20/2797902.html 那为什么先后顺序就解决问题呢> error 2

dx11 入门 Tutorial 04: DX、HLSL中矩阵的内存存储和数学计算方式 DirectXSampleBrowser(June 2010)

主要是两方面: 1.shader数据和dx的通信,使用constant Buffer 2.矩阵的数学计算方式和内存存储方式再DX和HLSL中的异同 先说第一个: dx中的常量数据matrix等传入shader中流程: The first thing that we need to do is declare three constant buffer variables. Constant buffers are used to store data that the application n

dx11 入门 Tutorial 06: 明白context->updateSubsource和setConstantBuffers DirectXSampleBrowser(June 2010)

需要明白constantBuffer传入数据到shader的正确使用:: cb1.vOutputColor = XMFLOAT4(0, 0, 0, 0); g_pImmediateContext->UpdateSubresource( g_pConstantBuffer, 0, NULL, &cb1, 0, 0 ); //更新cube的数据 // // Render the cube // g_pImmediateContext->VSSetShader( g_pVertexShade

Angular系列----AngularJS入门教程05:双向绑定(转载)

在这一步你会增加一个让用户控制手机列表显示顺序的特性.动态排序可以这样实现,添加一个新的模型属性,把它和迭代器集成起来,然后让数据绑定完成剩下的事情. 请重置工作目录: git checkout -f step-4 你应该发现除了搜索框之外,你的应用多了一个下来菜单,它可以允许控制电话排列的顺序. 步骤3和步骤4之间最重要的不同在下面列出.你可以在GitHub里看到完整的差别. 模板 app/index.html Search: <input ng-model="query"&g

【新手入门】基于Cocos2d-x-2.2x 创建新项目(一)

来自:http://cn.cocos2d-x.org/article/index?type=cocos2d-x&url=/doc/cocos2d-x-ch/manual/framework/native/v2/getting-started/setting-up-development-environments/windows-7-environment-setup/setup-win32-development-environment/zh.md 菜鸟阶段,为了便于自己创建cocos2d-x创

Android官方入门文档[15]重新创建一个Activity活动

Android官方入门文档[15]重新创建一个Activity活动 Recreating an Activity重新创建一个Activity活动 This lesson teaches you to1.Save Your Activity State2.Restore Your Activity State You should also read?Supporting Different Screens?Handling Runtime Changes?Activities 这节课教你1.保存

Web开发入门教程:Pycharm轻松创建Flask项目

Web开发入门教程:Pycharm轻松创建Flask项目 打开Pycharm的file,选择创建新的项目,然后弹出对话框,我们可以看到里面有很多的案例,Flask.Django等等,我们选择生成Flask的demo程序 选择创建之后一个简易的Flask项目就出现在我们眼前,第一个是入口程序,还有一个static的静态目录,templates是模板存放的位置 我们可以手动来启动这个Flask项目,但是这不是很理智的,在Pycharm上面有个run,我们可以选择run来启动Flask的服务,默认打开