关于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 ...
随机推荐
- 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem C: The Trip(水题)
Problem C: The Trip Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 19 Solved: 3[Submit][Status][Web ...
- Jquery鼠标滚动到页面底部自动加载更多内容,使用分页
index.php代码 [html] view plaincopy <!DOCTYPE html PUBLIC ;} .single_item{padding: ...
- laraver ajax分页
,设置分页容器参考laraver手册 我的设置代码如下: ,控制器调用的方法:代码如下 ); include($path); $content = ob_get_cle ...
- CC2540开发板学习笔记(五)——串口通信
(一)串口发送 一.实验现象: 开发板实现功能发送 二.实验过程 1.PL2303 USB转串口电路图 2.串口发送 (1)查看用户手册有: UART0 对应的外部设备 IO 引脚关系为: P0_2 ...
- Java的线程模型
并发不一定要依赖多线程(如PHP中很常见的多进程并发),但是在Java里面谈论并发,大多数都与线程脱不开关系. 线程是比进程更轻量级的调度执行单位,线程的引入,可以把一个进程的资源分配和执行调度分开, ...
- 状压DP SGU 223 Little Kings
题目传送门 /* 题意:n*n的矩阵,放置k个king,要求king互相不能攻击,即一个king的8个方向都没有另外的king,求方案个数 状态压缩DP:dp[i][num[j]][s] 代表在第i行 ...
- html表单应用
<!DOCTYPE html> <html> <head> <meta name="generator" content="HT ...
- HDU2824 The Euler function(欧拉函数)
题目求φ(a)+φ(a+1)+...+φ(b-1)+φ(b). 用欧拉筛选法O(n)计算出n以内的φ值,存个前缀和即可. φ(p)=p-1(p是质数),小于这个质数且与其互质的个数就是p-1: φ(p ...
- LightOJ1079 Just another Robbery(DP)
题目大概是抢劫银行,每家银行都有一个收益和一个被抓的概率,求在被抓概率小于P的条件下能获得的最大收益. dp[i][j]表示抢劫前i家银行收益为j被抓的最小概率 dp[0][0]=0 dp[i][j] ...
- POJ2288 Islands and Bridges(TSP:状压DP)
求一个图的哈密顿路径的最大权及其路径数.显然状态压缩+DP. dp[v][u][S] 表示从v走到当前顶点 u且走过的顶点集合是S的 最大权值和方案数 这题我用记忆化搜索,从终点开始递归进行,感觉这样 ...