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

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>
            国产日韩欧美综合| 午夜在线播放视频欧美| 欧美一区中文字幕| 亚洲精品视频在线观看网站| 性色av一区二区三区| 日韩午夜激情电影| 亚洲激情社区| 亚洲精品免费电影| 亚洲第一视频| 99视频超级精品| 亚洲天堂视频在线观看| 亚洲一区二区在线看| 国产一区二区日韩精品| 国产亚洲电影| 亚洲电影在线观看| 99精品国产一区二区青青牛奶| 亚洲黄色一区| 亚洲综合视频网| 老司机aⅴ在线精品导航| 免费不卡在线视频| 亚洲三级视频| 亚洲精品一区二| 亚洲私人影吧| 欧美福利在线| 韩国一区二区在线观看| 亚洲精品欧美一区二区三区| 久久久久久亚洲精品中文字幕| 香蕉久久久久久久av网站| 免费在线视频一区| 国产精品一区在线观看| 亚洲麻豆一区| 亚洲韩国日本中文字幕| 欧美一区二区三区四区在线| 欧美精品一区在线播放| 亚洲高清久久| 久久综合影视| 蜜桃伊人久久| 91久久精品一区二区别| 久久婷婷久久| 久久国产直播| 狠狠干成人综合网| 久久综合九色欧美综合狠狠| 亚洲一区二区免费看| 欧美三区视频| 亚洲欧美日韩国产成人| 亚洲毛片一区| 国产精品扒开腿做爽爽爽视频| 免费久久久一本精品久久区| 亚洲黄色高清| 欧美日韩成人综合在线一区二区| 韩国欧美一区| 亚洲国产一区二区三区a毛片| 久久中文字幕导航| 亚洲精品久久久久久久久久久久| 亚洲国产精品成人| 欧美伦理a级免费电影| 亚洲尤物在线| 久久免费视频一区| 亚洲欧美日韩在线播放| 亚洲午夜伦理| 久久精品视频在线看| 久久亚洲影音av资源网| 久久久一区二区三区| 在线一区二区日韩| 久久久久**毛片大全| 亚洲精品孕妇| 久久天天狠狠| 久久精品二区亚洲w码| 欧美精品在线观看一区二区| 欧美自拍偷拍午夜视频| 欧美精品v国产精品v日韩精品| 欧美一区1区三区3区公司| 欧美激情第三页| 亚洲第一久久影院| 极品日韩av| 久久精品最新地址| 久久国产精品久久久久久| 国产精品户外野外| 日韩视频免费在线| 99国产精品国产精品久久| 欧美 亚欧 日韩视频在线| 媚黑女一区二区| 精品不卡一区二区三区| 久久精品一二三| 欧美一区二区三区四区在线观看地址| 国产一区二区三区在线播放免费观看| 欧美黄色aaaa| 午夜精品999| 亚洲人成人一区二区在线观看| 欧美日本不卡| 亚洲欧美电影在线观看| 亚洲国产精品专区久久| 亚洲精品乱码久久久久久| 欧美三级视频在线播放| 亚洲欧美中文字幕| 欧美国产精品va在线观看| 99精品视频免费观看视频| 国产精品麻豆成人av电影艾秋| 亚洲欧美日韩国产中文| 久久国产日韩| 久久综合九色九九| 在线日韩av永久免费观看| 亚洲国产精品视频一区| 亚洲视屏在线播放| 91久久精品日日躁夜夜躁欧美| 欧美日韩免费高清一区色橹橹| 午夜精品99久久免费| 欧美大胆成人| 久久久美女艺术照精彩视频福利播放| 亚洲国产精品成人一区二区| 国产精品激情| 欧美性大战久久久久久久| 麻豆精品在线观看| 久久精品国产综合精品| 亚洲欧美日韩一区在线观看| 亚洲日本免费| 亚洲国产日韩在线一区模特| 欧美成人性生活| 欧美国产日韩精品免费观看| 久久综合福利| 欧美国产精品v| 亚洲青涩在线| 一区二区三区欧美亚洲| 亚洲精品乱码久久久久久黑人| 欧美va亚洲va国产综合| 亚洲国产成人精品久久久国产成人一区| 久久riav二区三区| 久久久亚洲成人| 亚洲国产高清一区| 日韩一区二区精品视频| 亚洲香蕉成视频在线观看| 中文国产成人精品久久一| 欧美一区二区三区啪啪| 久久久国产精品一区二区三区| 久久久久国产精品www| 欧美连裤袜在线视频| 国产欧美精品一区二区三区介绍| 国产性猛交xxxx免费看久久| 亚洲高清在线精品| 欧美经典一区二区三区| 欧美日韩一区二区高清| 国产日韩欧美成人| 一区二区av在线| 久久精品夜色噜噜亚洲aⅴ| 欧美成人免费全部观看天天性色| 99精品福利视频| 欧美**人妖| 亚洲国产成人av| 久久久久久久久久久久久女国产乱 | 久久久久久久999精品视频| 亚洲激情欧美激情| 久久久99久久精品女同性| 国产精品美女xx| 亚洲在线观看视频网站| 亚洲免费精彩视频| 欧美国产在线电影| 日韩一级精品| 在线亚洲免费| 国产精品麻豆va在线播放| 一区二区三区国产| 99热免费精品在线观看| 欧美日韩精品免费观看视频完整| 最新国产成人av网站网址麻豆 | 国产精品久久久久久久久久三级| 最新精品在线| 一区二区三欧美| 国产女人精品视频| 久久久久看片| 欧美精品综合| 久久精品99国产精品| 久久精品男女| 中国亚洲黄色| 久久久久天天天天| 亚洲视频一起| 免费亚洲电影在线| 欧美亚洲日本一区| 欧美福利精品| 国产欧美视频一区二区三区| 久久国产日韩| 国产精品久久久久久久久久三级 | 久久久久女教师免费一区| 久久福利视频导航| 亚洲激情精品| 欧美一区二区黄色| 亚洲第一级黄色片| 亚洲男女自偷自拍图片另类| 国产婷婷97碰碰久久人人蜜臀| 亚洲精品激情| 亚洲九九爱视频| 久久野战av| 美女日韩欧美| 亚洲电影免费在线观看| 久久久久久久综合| 免费成人高清在线视频| 国产日韩一级二级三级| 午夜亚洲激情| 麻豆成人综合网| aa级大片欧美| 欧美性做爰猛烈叫床潮| 亚洲一区二区精品在线|