青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

The Mechanics of Robust Stencil Shadows

http://www.gamasutra.com/features/20021011/lengyel_01.htm

The Mechanics of Robust Stencil Shadows

The idea of using the stencil buffer to generate shadows has been around for over a decade, but only recently has 3D graphics hardware advanced to the point where using the stencil algorithm on a large scale has become practical. Not long ago, there existed some unsolved problems pertaining to stencil shadows that prevented the algorithm from working correctly under various conditions. Advances have now been made, however, so that stencil shadows can be robustly implemented to handle arbitrarily positioned point lights and infinite directional lights having any desired spatial relationship with the camera. This article presents the intricacies of the entire stencil shadow algorithm and covers every mathematical detail of its efficient implementation.

Algorithm Overview

The basic concept of the stencil shadow algorithm is to use the stencil buffer as a masking mechanism to prevent pixels in shadow from being drawn during the rendering pass for a particular light source. This is accomplished by rendering an invisible shadow volume for each shadow-casting object in a scene using stencil operations that leave nonzero values in the stencil buffer wherever light is blocked. Once the stencil buffer has been filled with the appropriate mask, a lighting pass only illuminates pixels where the value in the stencil buffer is zero.

As shown in Figure 1, an object’s shadow volume encloses the region of space for which light is blocked by the object. This volume is constructed by finding the edges in the object’s triangle mesh representing the boundary between lit triangles and unlit triangles and extruding those edges away from the light source. Such a collection of edges is called the object’s silhouette with respect to the light source. The shadow volume is rendered into the stencil buffer using operations that modify the stencil value at each pixel depending on whether the depth test passes or fails. Of course, this requires that the depth buffer has already been initialized to the correct values by a previous rendering pass. Thus, the scene is first rendered using a shader that applies surface attributes that do not depend on any light source, such as ambient illumination, emission, and environment mapping.

 

Figure 1. An object’s shadow volume encloses the region of space for which light is blocked by the object.

The original stencil algorithm renders the shadow volume in two stages. In the first stage, the front faces of the shadow volume (with respect to the camera) are rendered using a stencil operation that increments the value in the stencil buffer whenever the depth test passes. In the second stage, the back faces of the shadow volume are rendered using a stencil operation that decrements the value in the stencil buffer whenever the depth test passes. As illustrated in Figure 2, this technique leaves nonzero values in the stencil buffer wherever the shadow volume intersects any surface in the scene, including the surface of the object casting the shadow.

 

Figure 2. Numbers at the ends of rays emanating from the camera position C represent the values left in the stencil buffer for a variety of cases. The stencil value is incremented when front faces of the shadow volume pass the depth test, and the stencil value is decremented when back faces of the shadow volume pass the depth test. The stencil value does not change when the depth test fails.

There are two major problems with the method just described. The first is that no matter what finite distance we extrude an object’s silhouette away from a light source, it is still possible that it is not far enough to cast a shadow on every object in the scene that should intersect the shadow volume. The example shown in Figure 3 demonstrates how this problem arises when a light source is very close to a shadow-casting object. Fortunately, this problem can be elegantly solved by using a special projection matrix and extruding shadow volumes all the way to infinity.

 

Figure 3. No matter what finite distance an object’s silhouette is extruded away from a light source, moving the light close enough to the object can result in a shadow volume that cannot reach other objects in the scene.

The second problem shows up when the camera lies inside the shadow volume or the shadow volume is clipped by the near plane. Either of these occurrences can leave incorrect values in the stencil buffer causing the wrong surfaces to be illuminated. The solution to this problem is to add caps to the shadow volume geometry, making it a closed surface, and using different stencil operations. The two caps added to the shadow volume are derived from the object’s triangle mesh as follows. A front cap is constructed using the unmodified vertices of triangles facing toward the light source. A back cap is constructed by projecting the vertices of triangles facing away from the light source to infinity. For the resulting closed shadow volume, we render back faces (with respect to the camera) using a stencil operation that increments the stencil value whenever the depth test fails, and we render front faces using a stencil operation that decrements the stencil value whenever the depth test fails. As shown in Figure 4, this technique leaves nonzero values in the stencil buffer for any surface intersecting the shadow volume for arbitrary camera positions. Rendering shadow volumes in this manner is more expensive than using the original technique, but we can determine when it’s safe to use the less-costly depth-pass method without having to worry about capping our shadow volumes.

 

Figure 4. Using a capped shadow volume and depth-fail stencil operations allows the camera to be inside the shadow volume. The stencil value is incremented when back faces of the shadow volume fail the depth test, and the stencil value is decremented when front faces of the shadow volume fail the depth test. The stencil value does not change when the depth test passes.

The details of everything just described are discussed throughout the remainder of this article. In summary, the rendering algorithm for a single frame runs through the following steps.

A Clear the frame buffer and perform an ambient rendering pass. Render the visible scene using any surface shading attribute that does not depend on any particular light source.
B Choose a light source and determine what objects may cast shadows into the visible region of the world. If this is not the first light to be rendered, clear the stencil buffer.
C For each object, calculate the silhouette representing the boundary between triangles facing toward the light source and triangles facing away from the light source. Construct a shadow volume by extruding the silhouette away from the light source.
D Render the shadow volume using specific stencil operations that leave nonzero values in the stencil buffer where surfaces are in shadow.
E Perform a lighting pass using the stencil test to mask areas that are not illuminated by the light source.
F Repeat steps B through E for every light source that may illuminate the visible region of the world.

For a scene illuminated by n lights, this algorithm requires at least n+1 rendering passes. More than n+1 passes may be necessary if surface shading calculations for a single light source cannot be accomplished in a single pass. To efficiently render a large scene containing many lights, one must be careful during each pass to render only objects that could potentially be illuminated by a particular light source. An additional optimization using the scissor rectangle can also save a significant amount of rasterization work -- this optimization is discussed in the last section of this article.

______________________________________________________

Infinite View Frustums

posted on 2008-12-04 14:23 zmj 閱讀(929) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国内精品99| 欧美/亚洲一区| 欧美日韩国产一区二区三区地区| 欧美一区二区精品在线| 欧美黑人国产人伦爽爽爽| 一区二区三区精品在线 | 另类激情亚洲| 宅男噜噜噜66一区二区 | 玖玖玖免费嫩草在线影院一区| 亚洲国产日韩在线| 亚洲精品1区| 欧美成人第一页| 久久精品视频免费观看| 久久综合九色综合网站| 欧美中文在线观看| 巨胸喷奶水www久久久免费动漫| 亚洲小视频在线观看| 国产精品嫩草影院av蜜臀| 欧美高清在线精品一区| 蜜桃久久av一区| 久久亚洲综合色| 久久免费高清| 久热综合在线亚洲精品| 午夜视频一区在线观看| 午夜精品一区二区三区在线播放| 亚洲乱码国产乱码精品精| 欧美色视频在线| 国产在线精品自拍| 欧美色图五月天| 在线观看成人av| 永久免费毛片在线播放不卡| 亚洲日本一区二区三区| 久久视频在线视频| 亚洲午夜精品久久| 久久久久久高潮国产精品视| 噜噜噜在线观看免费视频日韩| 日韩视频在线播放| 最新中文字幕亚洲| 亚洲第一精品夜夜躁人人爽 | 在线看片成人| 国产香蕉久久精品综合网| 国产日韩欧美高清| 一区二区三区高清不卡| 在线亚洲欧美| 亚洲国产精品免费| 亚洲精品日产精品乱码不卡| 欧美中文字幕不卡| 欧美ed2k| 国产精品v亚洲精品v日韩精品| 国产精品ⅴa在线观看h| 国产乱码精品一区二区三| 韩国女主播一区| 亚洲精品一区二区三区四区高清| 妖精视频成人观看www| 国产精品日韩一区| 欧美日韩1区2区| 99riav久久精品riav| 亚洲制服av| 亚洲最新在线视频| 久久久久久高潮国产精品视| 国产一区二区按摩在线观看| 影音欧美亚洲| 男女激情视频一区| 亚洲一级高清| 99精品视频免费观看| 欧美激情亚洲激情| 国产免费亚洲高清| 久久疯狂做爰流白浆xx| 亚洲第一中文字幕在线观看| 裸体素人女欧美日韩| 国产精品素人视频| 久久不射中文字幕| 日韩午夜在线播放| 亚洲精选视频免费看| 国产精品久久久久久久久久三级 | 一二三区精品| 久久精品中文字幕免费mv| 午夜电影亚洲| 欧美日韩精品综合在线| 亚洲制服丝袜在线| 欧美激情在线有限公司| 欧美人与性动交cc0o| 在线观看视频一区二区欧美日韩| 亚洲欧美日韩另类| 亚洲第一级黄色片| 亚洲国产综合视频在线观看| 国产精品一区久久| 蜜桃精品一区二区三区| 亚洲免费网址| 在线免费不卡视频| 久久精品国产在热久久| 蜜桃久久av| 在线成人av网站| 亚洲精品国产精品国自产在线 | 亚洲一区二区三区免费观看 | 亚洲国产精品久久久| 欧美日韩亚洲综合| 91久久在线视频| 亚洲视频免费观看| 欧美裸体一区二区三区| 国产色婷婷国产综合在线理论片a| 亚洲一区二区三区四区中文| 最新69国产成人精品视频免费| 国产女精品视频网站免费| 亚洲欧美一区二区激情| 女人色偷偷aa久久天堂| 亚洲高清久久网| 亚洲一区二区三区四区五区黄 | 伊人狠狠色j香婷婷综合| 亚洲国产一区二区三区在线播| 可以看av的网站久久看| 亚洲视频在线一区| 亚洲在线成人精品| 久久琪琪电影院| 性欧美激情精品| 亚洲欧美一区二区三区久久| 一区二区欧美日韩视频| 一本高清dvd不卡在线观看| 亚洲乱码视频| 亚洲精品自在在线观看| 亚洲国产精品999| 最新精品在线| 欧美成人精品一区二区| 久久色在线播放| 欧美sm视频| 欧美成人影音| 欧美日韩日本网| 亚洲区免费影片| 欧美精品三级日韩久久| 久久久亚洲国产天美传媒修理工| 久久精品国产免费观看| 国产精品嫩草影院av蜜臀| 99国内精品久久| 国产综合色产在线精品| 亚洲女优在线| 激情五月***国产精品| 亚洲欧美日韩国产一区二区| 久久久久久有精品国产| 久久久久国产精品一区二区| 西瓜成人精品人成网站| 久久精品午夜| 欧美成人r级一区二区三区| 欧美777四色影视在线| 久久综合九色九九| 国产精品久久久久久久久免费桃花| 亚洲精品资源美女情侣酒店| 久热国产精品| 亚洲一区二区三区乱码aⅴ| 狼人社综合社区| 亚洲伊人观看| 国产日韩欧美亚洲一区| 亚洲精品久久久久中文字幕欢迎你| 日韩视频免费观看高清完整版| 午夜精品在线看| 韩国一区二区在线观看| 免费国产一区二区| 久久激五月天综合精品| 在线欧美小视频| 一区二区三区视频在线看| 99国产精品国产精品久久| 久久狠狠亚洲综合| 欧美成人精品一区二区| 激情欧美一区二区| 免费影视亚洲| 久久夜色精品国产| 久久国产精品99国产| 欧美日韩成人在线视频| 欧美成人精品三级在线观看| 国产一区二区三区四区五区美女| 亚洲国内自拍| 亚洲精品网址在线观看| 久久免费精品视频| 亚洲精品中文字幕女同| 亚洲国产裸拍裸体视频在线观看乱了中文 | 国产一区二区三区观看| 亚洲成在人线av| 日韩一级欧洲| 免费观看久久久4p| 亚洲一区二区三区免费在线观看 | 欧美中日韩免费视频| 亚洲欧美日韩天堂一区二区| 国产真实久久| 久久理论片午夜琪琪电影网| 亚洲成色999久久网站| 嫩草国产精品入口| 嫩草成人www欧美| 亚洲欧美制服另类日韩| 欧美日韩久久| 久久最新视频| 欧美激情亚洲自拍| 久久久国产一区二区| 狠狠色综合色区| 国产精品一二三视频| 亚洲欧美日韩精品久久久| 亚洲毛片一区二区| 欧美极品aⅴ影院| 亚洲国产精品免费| 亚洲欧美乱综合| 国产精品美女主播| 欧美日韩蜜桃|