游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1970|回复: 6

stencil buffer的不解

[复制链接]

8

主题

16

帖子

16

积分

新手上路

Rank: 1

积分
16
发表于 2006-3-2 09:28:00 | 显示全部楼层 |阅读模式
Shadow Volumes are used for drawing shadows with the stencil buffer. The application computes the shadow volumes cast by occluding geometry, by computing the silhouette edges and extruding them away from the light into a set of 3-D volumes. These volumes are then rendered twice into the stencil buffer.

The first render draws forward-facing polygons, and increments the stencil-buffer values. The second render draws the back-facing polygons of the shadow volume, and decrements the stencil buffer values. Normally, all incremented and decremented values cancel each other out. However, the scene was already rendered with normal geometry causing some pixels to fail the z-buffer test as the shadow volume is rendered. Values left in the stencil buffer correspond to pixels that are in the shadow. These remaining stencil-buffer contents are used as a mask, to alpha-blend a large, all-encompassing black quad into the scene. With the stencil buffer acting as a mask, the result is to darken pixels that are in the shadows.

上述为DX文档中的一段文字; 其中不明白的地方有:

1. volumns 被render到stencil buffer需要两次,  这个是根据什么原理来的?

2. 在两次被render的过程中提及的forward-facing和back-facing polygon分别指的是什么呢?   因为在我的理解上back-facing  polygon为不可见面,为什么还要render呢?

3. 如何把这段话跟shadow的算法结合起来呢? shadow的算法关于stencil buffer的增加及减少是根据多边形与shadow的关系来进行的,这里面 increments stencil-buffer value和decrement stencil-buffer value怎么和检测shadow的算法联系起来的?

苦思不得其解,请教各位,谢谢!

36

主题

1047

帖子

1147

积分

金牌会员

Rank: 6Rank: 6

积分
1147
发表于 2006-3-2 09:31:00 | 显示全部楼层

Re:stencil buffer的不解

找一找OPENGL的文档看看,能好理解一些。

8

主题

16

帖子

16

积分

新手上路

Rank: 1

积分
16
 楼主| 发表于 2006-3-2 09:34:00 | 显示全部楼层

Re:stencil buffer的不解

我也在拼命地查资料,只是在关键问题上总是不能把它们串起来,可能在看问题的角度上一直钻在牛角尖上了,能否麻烦您解释一下呢?

36

主题

1047

帖子

1147

积分

金牌会员

Rank: 6Rank: 6

积分
1147
发表于 2006-3-2 09:41:00 | 显示全部楼层

Re:stencil buffer的不解

这是 Nvidia 的文档,希望对你有些帮助 http://developer.nvidia.com/object/cedec_stencil.html

8

主题

16

帖子

16

积分

新手上路

Rank: 1

积分
16
 楼主| 发表于 2006-3-2 16:31:00 | 显示全部楼层

Re: stencil buffer的不解

非常感谢您的资料,己经全部理解,谢谢!

36

主题

1047

帖子

1147

积分

金牌会员

Rank: 6Rank: 6

积分
1147
发表于 2006-3-2 21:15:00 | 显示全部楼层

Re:stencil buffer的不解

呵呵,不客气,不过建议你理解之后能写出来,这样更能加深理解,而且别人也都知道是为什么了。希望我们国内的游戏开发论坛能像国外一样。

4

主题

28

帖子

28

积分

注册会员

Rank: 2

积分
28
发表于 2006-3-3 00:02:00 | 显示全部楼层

Re:stencil buffer的不解

好像是模板缓冲做轮廓线生成软阴影,只是现在的硬件有许多都不支持双面模板,所以如果使用模板技术的话,可能会影响效率但是模板技术所产生的视觉效果很强大的.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-23 19:55

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表