|
|
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的算法联系起来的?
苦思不得其解,请教各位,谢谢! |
|