酱坛子

专注C++技术 在这里写下自己的学习心得 感悟 和大家讨论 共同进步(欢迎批评!!!)

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  66 Posts :: 16 Stories :: 236 Comments :: 0 Trackbacks

公告

王一伟 湖南商学院毕业 电子信息工程专业

常用链接

留言簿(19)

我参与的团队

搜索

  •  

积分与排名

  • 积分 - 382429
  • 排名 - 63

最新随笔

最新评论

阅读排行榜

评论排行榜

另外一篇 英文资料(转自 http://www.intel.com/cd/ids/developer/apac/zho/dc/games/optimization/170939.htm?page=4
使用Z-Bias解决Z-Fighting问题的替代方案
|
目录
Introduction
Alternative Method 1: Projection Matrix
Alternative Method 2: Viewport
Alternative Method 3: Depth Bias
Conclusion
Additional Resources

Alternative Method 3: Depth Bias

The last method addressed in this article uses the DirectX 9 Depth Bias method to solve z-fighting. A check to verify that the graphics card is capable of performing depth bias is needed. Intel Integrated Graphics will support depth bias in the next graphics core code named Grantsdale. After checking the cap bits to verify that depth bias is supported, this technique merely requires setting D3DRS_SLOPESCALEDEPTHBIAS and D3DRS_DEPTHBIAS to the proper values to get the desired effect.

The following code snippet shows the depth-bias alternative to using a DirectX z-bias call:

BOOL m_bDepthBiasCap; // TRUE, if device has DepthBias Caps

// Globals used for Depth Bias
float g_fSlopeScaleDepthBias = 1.0f;
float g_fDepthBias = -0.0005f;
float g_fDefaultDepthBias = 0.0f;

// Check for devices which support the new depth bias caps
if ((pCaps->RasterCaps & D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS) &&
(pCaps->RasterCaps & D3DPRASTERCAPS_DEPTHBIAS))
{
m_bDepthBiasCap = true; // TRUE, if DepthBias Caps
}

// Billboards are rendered...

// DepthBias work around
if ( m_bDepthBiasCap ) // TRUE, if DepthBias supported
{
// Used to determine how much bias can be applied
// to co-planar primitives to reduce z fighting
// bias = (max * D3DRS_SLOPESCALEDEPTHBIAS) + D3DRS_DEPTHBIAS,
// where max is the maximum depth slope of the triangle being rendered.
m_pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, F2DW(g_fSlopeScaleDepthBias));
m_pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS, F2DW(g_fDepthBias));
}

// Posters are rendered...

if ( m_bDepthBiasCap ) // TRUE, if DepthBias supported
{
// DepthBias work around
// set it back to zero (default)
m_pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, F2DW(g_fDefaultDepthBias));
m_pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS, F2DW(g_fDefaultDepthBias));
}

. . .

Like the other methods (and like the original z-bias), some tweaking may be necessary, but using D3DRS_SLOPESCALEDEPTHBIAS and D3DRS_DEPTHBIAS is a relatively consistent technique for resolving z-fighting issues across a wide selection of graphics devices. The figure below shows the result of this alternate solution:


Figure 4. Z-fighting solved with depth bias solution.
As Figure 4 shows, care should be taken for adjusting the D3DRS_SLOPESCALEDEPTHBIAS and D3DRS_DEPTHBIAS. They can be very sensitive and lead to other issues like the problem below for distant objects:


Figure 5. Depth-bias solution possible issue: unwanted overlapping polygons.
找到一些英文资料
Depth Bias收藏

An application can help ensure that coplanar polygons are rendered properly by adding a bias to the z-values that the system uses when rendering the sets of coplanar polygons. To add a z-bias to a set of polygons, call the SetRenderState method just before rendering them, setting the State parameter to D3DRS_DEPTHBIAS, and the value parameter to a value between 0-16 inclusive. A higher z-bias value increases the likelihood that the polygons you render will be visible when displayed with other coplanar polygons.


Offset = m * D3DRS_SLOPESCALEDEPTHBIAS + D3DRS_DEPTHBIAS

where m is the maximum depth slope of the triangle being rendered.

m = max(abs(delta z / delta x), abs(delta z / delta y))

The units for the D3DRS_DEPTHBIAS and D3DRS_SLOPESCALEDEPTHBIAS render states depend on whether z-buffering or w-buffering is enabled. The application must provide suitable values.

The bias is not applied to any line and point primitive. However, this bias needs to be applied to triangles drawn in wireframe mode.

// RenderStates
D3DRS_SLOPESCALEDEPTHBIAS, // Defaults to zero
D3DRS_DEPTHBIAS, // Defaults to zero

// Caps
D3DPRASTERCAPS_DEPTHBIAS
D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS

是的 无外乎就是这样的
请问用winnet怎么实现远程的seek操作

而不是像MFC的HTTPFile那样down到本地了才Seek

呵呵 sunraiing@126.com
re: inline函数 @王一伟 2007-12-30 08:12
inline化算是编译时的一种优化,比如里面有for循环的时候,还有递归调用什么的,编译器就会自动优化成非inline函数,inline的会导致代码体积上升过快 呵呵。

这个是编译到代码段的行为。
re: UNICODE 介绍 @王一伟 2007-12-30 08:06
没有涉及过unix/linux编程哦 可以探讨下 过阵我会研究一下linux下的,d等我有两台电脑的时候 呵呵
re: amd的Memcpy函数 @王一伟 2007-12-30 08:04
呵呵 粘帖过来的 还没来得及研究呢
有时间研究下可以探讨探讨

指令一般般多拉 哈哈
re: inline函数 @王一伟 2007-12-30 08:03
呵呵 是的 寄存器变量的分配在编译时获得,编译时会确定变量数据段的地址,包括寄存器变量。

inline也是编译器负责 原生C++都是在编译时进行inline化,而C++/CLI可以支持运行时的inline化

不知道是不是可以理解C++/CLI为一种动态语言了 呵呵,我对这不是太清楚 Solomon Jon可以解释下
re: 两类程序员 @王一伟 2007-11-26 15:29
来这里的都会选前者的

每种程序员的竞争力核心不一样,不能只狭隘的吧所有的东西归结到程序语言本身上。

很少有人的工作是完全纯净的某一个狭小的领域的,混合型工作是工作的主流,各个层面工作的比例不同造就了我们在这里讨论的几种程序员的工作重心不一样,核心竞争力也就不一样 呵呵
re: D语言与C++ @王一伟 2007-09-14 15:57
荒谬 拖出去喂鸟


3.4秒钟你遍历这几百个文件名还不一定够

你还编译个鸟
re: 引领Boost(一)(开篇) @王一伟 2007-08-16 12:34
好东西 学习学习
re: 函数用const修饰算不算重载 @王一伟 2007-08-13 14:13
或许泡泡牛大哥的解释方法能解释吧
re: 函数用const修饰算不算重载 @王一伟 2007-08-13 14:12
但是是重载的话 如果单写某一个函数 用同一种调用方法都能调用 呵呵

说不清

结贴吧
re: 函数用const修饰算不算重载 @王一伟 2007-08-13 09:51
似乎 重载又不似重载 呵呵

不管了 知道怎么用就可以了

这玩意专研多了 无意,浪费青春
re: GetProcAddress @王一伟 2007-08-09 09:50
已经解决 嘿嘿
re: GetProcAddress @王一伟 2007-08-09 08:58
我重新写了上面的代码 发觉还是有问题dll能导入成功,函数地址能获取

但是一旦用typedef的函数指针的时候就连编译都编译不过了

请求帮助

工程文件如下http://www.cppblog.com/Files/sunraiing9/hahahah.rar

11k大小
re: 无题 @王一伟 2007-07-30 17:54
你是最好的服装设计师?拜托 不能这么说人家啊 呵呵
这可不是做美术
re: 图片测试贴 @王一伟 2007-04-12 11:47
用netease 的相册,比较好用
re: 类模板(原创) @王一伟 2007-04-11 10:50
好文,哈哈,下班了慢慢看看你写的
re: 白居易《长恨歌》的主题 @王一伟 2007-04-11 10:05
有没搞错,这个也发到主页上来,LZ没睡好吧
re: 请达人提示一下 @王一伟 2007-04-11 09:50
转过来支持下array,pointer,map等
re: 请达人提示一下 @王一伟 2007-04-11 09:49
HOHO 已经完成带基本数据类型 和string的类序列化