glPolygonOffset解决两个面共面

 
摘自http://www.gamergroup.cn/html/78/n-3078.html
当两个面共面时,会出现十分难看的z - fighting 问题,
要解决此问题可以使用, Polygon Offset, 方法如下:
drawSomething();
//同一位置绘制另一个东西
glEnable( GL_POLYGON_OFFSET_FILL ); // This is the one we need...
glPolygonOffset( g_OffsetFactor, g_OffsetUnit );
drawOtherthing();
glPolygonOffset( 0.0f, 0.0f );
glDisable( GL_POLYGON_OFFSET_FILL );
其中
g_OffsetFactor代表 factor,
g_OffsetUnit 代表 units,
关于factor, units 的解释如下:
When GL_POLYGON_OFFSET is enabled, each fragment's depth
value will be offset after it is interpolated from the depth
values of the appropriate vertices. The value of the offset
is factor * DZ + r * units, where DZ is a measurement of
the change in depth relative to the screen area of the
polygon, and r is the smallest value that is guaranteed to
produce a resolvable offset for a given implementation. The
offset is added before the depth test is performed and
before the value is written into the depth buffer.
glPolygonOffset is useful for rendering hidden-line images,
for applying decals to surfaces, and for rendering solids
with highlighted edges.


这个函数以后可能用得到,tutorial04里面画阴影的时候用到了,不过阴影还是很难看
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值