关于Depth Bounds Test (DBT)和在CE3的运用
- DBT的逻辑是在 scissor test 后面, alpha testing前面
- min/max值被clamp在[0, 1]之间,非法值会被转为0
- DBT会被打开,当下面条件都为真时
- min < max
- min > 1 并且 max<1
- depth值在Shader里被使用
void CD3D9Renderer::SetDepthBoundTest(float fMin,float fMax,bool bEnable)
{
if(bEnable)
{
m_pd3dDevice->SetRenderState(D3DRS_ADAPTIVETESS_X,MAKEFOURCC('N','V','D','B'));
m_pd3dDevice->SetRenderState(D3DRS_ADAPTIVETESS_Z,*(DWORD*)&fMin);
m_pd3dDevice->SetRenderState(D3DRS_ADAPTIVETESS_W,*(DWORD*)&fMax);
}
else// disable depth bound test
{
m_pd3dDevice->SetRenderState(D3DRS_ADAPTIVETESS_X,);
}
}
DBT的主要用处有两个,一个例子是在OpenGL extension文档里的例子 可以用来优化stenciled shadow volume 的渲染

SetDepthBoundTest(.f,0.9999f,true);
下雨效果
CD3D9Renderer::FX_DeferredRainLayer()
constVec4 vDepthBounds =CDeferredShading::Instance().GetLightDepthBounds(rainVolParams.m_vWorldPos, rainVolParams.m_fRadius);
SetDepthBoundTest(max(vDepthBounds.x, fMinZ), min(vDepthBounds.z, fMaxZ),true);
下雪效果
CD3D9Renderer::FX_DeferredSnowLayer()
constVec4 vDepthBounds =CDeferredShading::Instance().GetLightDepthBounds(snowVolParams.m_vWorldPos, snowVolParams.m_fRadius);
SetDepthBoundTest(max(vDepthBounds.x, fMinZ), min(vDepthBounds.z, fMaxZ),true);
延迟光照着色
CDeferredShading::LightPass
Vec4 pDepthBounds =GetLightDepthBounds( pDL );
rd->SetDepthBoundTest( pDepthBounds.x, pDepthBounds.z,true);IBL的延迟着色
CDeferredShading::DeferredCubemapPass
Vec4 pDepthBounds =GetLightDepthBounds( pDL );
rd->SetDepthBoundTest( pDepthBounds.x, pDepthBounds.z,true);屏幕空间反射
CDeferredShading::ScreenSpaceReflectionPass
rd->SetDepthBoundTest(0.0f,0.9999f,true);
CDeferredShading::DirectionalOcclusionPass()
CDeferredShading::DirectionalOcclusionPass()
阴影处理
CDeferredShading::ShadowLightPasses()
Vec4 pDepthBounds =GetLightDepthBounds(&light );
rd->SetDepthBoundTest( pDepthBounds.x, pDepthBounds.z,true);为了在绘制里可以忽略天空部分
void CDeferredShading::Render()
if(CRenderer::CV_r_DeferredShadingDepthBoundsTest )
{
constVec4 pDepthBounds =CDeferredShading::Instance().GetLightDepthBounds( rRendSettings.m_pos, m_fDistance );
rd->SetDepthBoundTest(pDepthBounds.x, pDepthBounds.z,true);// skip sky only for GI
}
修改方法也比较简单,关闭CV_r_DeferredShadingDepthBoundsTest,或在shader里添加clip来discard掉像素,或用alpha test替代,但这两种方法在移动平台上忌讳的,所以需要进一步测试才有结果了
关于Depth Bounds Test (DBT)和在CE3的运用的更多相关文章
- (转)Shadow Map & Shadow Volume
转自:http://blog.csdn.net/hippig/article/details/7858574 shadow volume 这个术语几乎是随着 DOOM3 的发布而成为FPS 玩家和图形 ...
- D3D9 GPU Hacks (转载)
D3D9 GPU Hacks I’ve been trying to catch up what hacks GPU vendors have exposed in Direct3D9, and tu ...
- 引擎设计跟踪(九.14.3.2) Deferred shading的后续实现和优化
最近完成了deferred shading和spot light的支持, 并作了一部分优化. 之前forward shading也只支持方向光, 现在也支持了点光源和探照光. 对于forward sh ...
- 阴影锥(shadow volume)原理与展望
转记:找了不少关于shadow volume原理的资料,还是这个帖子讲解的一目了然,转帖在这里,方便查阅.引用链接:http://blog.donews.com/yyh/archive/2005/05 ...
- [LeetCode] Minimum Depth of Binary Tree 二叉树的最小深度
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...
- [LeetCode] Maximum Depth of Binary Tree 二叉树的最大深度
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- leetcode 111 minimum depth of binary tree
problem description: Given a binary tree, find its minimum depth. The minimum depth is the number of ...
- frame和bounds
- frame 是一个以**父视图**为坐标系的位置- bounds 是一个以**自身**为坐标系的位置- 如果改变了bounds 那么会影响子控件的显示位置
- 【leetcode】Minimum Depth of Binary Tree
题目简述: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along th ...
随机推荐
- cocos2dx创建sprite的多种方法
方法一 最常用,也是最简单的一种方法 CCSprite *bg=CCSprite::create(,,,)); bg->setAnchorPoint(ccp(,)); bg->setPos ...
- linux tricks 之 BUILD_BUG_ON_ZERO.
------------------------------------------- 本文系作者原创, 欢迎大家转载! 转载请注明出处:netwalker.blog.chinaunix.net -- ...
- 利用JS提交表单的几种方法和验证
第一种方式:表单提交,在form标签中增加onsubmit事件来判断表单提交是否成功 <script type="text/javascript"> function ...
- jquery php ajax 表单验证
本实例用到 JQuery 类库本身的函数和功能,所有表单信息利用 PHPMailer 类库邮件的形式发送. .创建一个表单 html 页面 表单部分 html 代码 以下为引用内容: &l ...
- POJ 3461 Oulipo KMP
题意:统计其中一个子串的出现次数 题解:即KMP算法中j==m的次数 //作者:1085422276 #include <cstdio> #include <cmath> #i ...
- cocos2dx游戏开发——捕鱼达人mini版学习笔记(一)——FishAchor的搭建
一.创建文件· FishAchor.h还有FishAchor.cpp. 主要就是创建每种鱼的类,方便以后的取用~,很多是重复性的操作,然后我们是mini版,暂时也就加入大概6钟鱼就好= =,然后我们现 ...
- sql经典习题及其答案(纠正错误版)
--网上有好多这套题的答案,但是经过我的验证,有很多都是错的,误人子弟--这是我自己纠正以后的版本 然后呢如果我写的还有不对的欢迎批评指正!--(1)查询2006年以后(包括2006年)的投稿情况,列 ...
- eclipse常用快捷键,这个只要新学会的常用的会陆续更新的。
1.Ctrl+Shift+O 引用包 2.Ctrl+Shift+F 格式化代码 3.Ctrl + / 注释和解除注释代码 4.Ctrl+M 代码最大最小化 5.ctrl+shif ...
- 状压DP POJ 2411 Mondriaan'sDream
题目传送门 /* 题意:一个h*w的矩阵(1<=h,w<=11),只能放1*2的模块,问完全覆盖的不同放发有多少种? 状态压缩DP第一道:dp[i][j] 代表第i行的j状态下的种数(状态 ...
- SGU185 Two shortest(最小费用最大流/最大流)
题目求一张图两条边不重复的最短路. 一开始我用费用流做. 源点到1连容量2费用0的边:所有边,连u到v和v到u容量1费用cost的边. 总共最多会增广两次,比较两次求得的费用,然后输出路径. 然而死M ...