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

Shadow mapping

http://en.wikipedia.org/wiki/Shadow_map

From Wikipedia, the free encyclopedia

  (Redirected from Shadow map)
Jump to: navigation, search
Scene with shadow mapping
Scene with no shadows

Shadow mapping or projective shadowing is a process by which shadows are added to 3D computer graphics. This concept was introduced by Lance Williams in 1978, in a paper entitled "Casting curved shadows on curved surfaces". Since then, it has been used both in pre-rendered scenes, in realtime, and even in many console and high-end PC games. Shadow mapping is used by Pixar's RenderMan, and likewise, shadow mapping has been used in such films as Toy Story.

Shadows are created by testing whether a pixel is visible from the light source, by comparing it to a z-buffer or depth image of the light's view, stored in the form of a texture.

Contents

[hide]

[edit] Principle of a shadow and a shadow map

If you looked out from a source of light, all of the objects you can see would appear in light. Anything behind those objects, however, would be in shadow. This is the basic principle used to create a shadow map. The light's view is rendered, storing the depth of every surface it sees (the shadow map). Next, the regular scene is rendered comparing the depth of every point drawn (as if it were being seen by the light, rather than the eye) to this depth map.

For real-time shadows, this technique is less accurate than shadow volumes, but the shadow map can sometimes be a faster alternative depending on how much fill time is required for either technique in a particular application. As well, shadow maps do not require the use of an additional stencil buffer, and can sometimes be modified to produce shadows with a soft edge. However, unlike shadow volumes, the accuracy of a shadow map is limited by its resolution.

[edit] Algorithm overview

Rendering a shadowed scene involves two major drawing steps. The first produces the shadow map itself, and the second applies it to the scene. Depending on the implementation (and number of lights), this may require two or more drawing passes.

[edit] Creating the shadow map

Scene rendered from the light view.
Scene from the light view, depth map.

The first step renders the scene from the light's point of view. For a point light source, the view should be a perspective projection as wide as its desired angle of effect (it will be a sort of square spotlight). For directional light (e.g. that from the Sun), an orthographic projection should be used.

From this rendering, the depth buffer is extracted and saved. Because only the depth information is relevant, it is usual to avoid updating the color buffers and disable all lighting and texture calculations for this rendering, in order to save drawing time. This depth map is often stored as a texture in graphics memory.

This depth map must be updated any time there are changes to either the light or the objects in the scene, but can be reused in other situations, such as those where only the viewing camera moves. (If there are multiple lights, a separate depth map must be used for each light.)

In many implementations it is practical to render only a subset of the objects in the scene to the shadow map in order to save some of the time it takes to redraw the map. Also, a depth offset which shifts the objects away from the light may be applied to the shadow map rendering in an attempt to resolve stitching problems where the depth map value is close to the depth of a surface being drawn (i.e. the shadow casting surface) in the next step. Alternatively, culling front faces and only rendering the back of objects to the shadow map is sometimes used for a similar result.

[edit] Shading the scene

The second step is to draw the scene from the usual camera viewpoint, applying the shadow map. This process has three major components, the first is to find the coordinates of the object as seen from the light, the second is the test which compares that coordinate against the depth map, and finally, once accomplished, the object must be drawn either in shadow or in light.

[edit] Light space coordinates

Visualization of the depth map projected onto the scene

In order to test a point against the depth map, its position in the scene coordinates must be transformed into the equivalent position as seen by the light. This is accomplished by a matrix multiplication. The location of the object on the screen is determined by the usual coordinate transformation, but a second set of coordinates must be generated to locate the object in light space.

The matrix used to transform the world coordinates into the light's viewing coordinates is the same as the one used to render the shadow map in the first step (under OpenGL this is the product of the modelview and projection matrices). This will produce a set of homogeneous coordinates that need a perspective division (see 3D projection) to become normalized device coordinates, in which each component (x, y, or z) falls between -1 and 1 (if it is visible from the light view). Many implementations (such as OpenGL and Direct3D) require an additional scale and bias matrix multiplication to map those -1 to 1 values to 0 to 1, which are more usual coordinates for depth map (texture map) lookup. This scaling can be done before the perspective division, and is easily folded into the previous transformation calculation by multiplying that matrix with the following:

If done with a shader, or other graphics hardware extension, this transformation is usually applied at the vertex level, and the generated value is interpolated between other vertices, and passed to the fragment level.

[edit] Depth map test

Depth map test failures.

Once the light-space coordinates are found, the x and y values usually correspond to a location in the depth map texture, and the z value corresponds to its associated depth, which can now be tested against the depth map.

If the z value is greater than the value stored in the depth map at the appropriate (x,y) location, the object is considered to be behind an occluding object, and should be marked as a failure, to be drawn in shadow by the drawing process. Otherwise it should be drawn lighted.

If the (x,y) location falls outside the depth map, the programmer must either decide that the surface should be lit or shadowed by default (usually lit).

In a shader implementation, this test would be done at the fragment level. Also, care needs to be taken when selecting the type of texture map storage to be used by the hardware: if interpolation cannot be done, the shadow will appear to have a sharp jagged edge (an effect that can be reduced with greater shadow map resolution).

It is possible to modify the depth map test to produce shadows with a soft edge by using a range of values (based on the proximity to the edge of the shadow) rather than simply pass or fail.

The shadow mapping technique can also be modified to draw a texture onto the lit regions, simulating the effect of a projector. The picture above, captioned "visualization of the depth map projected onto the scene" is an example of such a process.

[edit] Drawing the scene

Final scene, rendered with ambient shadows.

Drawing the scene with shadows can be done in several different ways. If programmable shaders are available, the depth map test may be performed by a fragment shader which simply draws the object in shadow or lighted depending on the result, drawing the scene in a single pass (after an initial earlier pass to generate the shadow map).

If shaders are not available, performing the depth map test must usually be implemented by some hardware extension (such as GL_ARB_shadow), which usually do not allow a choice between two lighting models (lighted and shadowed), and necessitate more rendering passes:

  1. Render the entire scene in shadow. For the most common lighting models (see Phong reflection model) this should technically be done using only the ambient component of the light, but this is usually adjusted to also include a dim diffuse light to keep curved surfaces from appearing flat in shadow.
  2. Enable the depth map test, and render the scene lit. Areas where the depth map test fails will not be overwritten, and remain shadowed.
  3. An additional pass may be used for each additional light, using additive blending to combine their effect with the lights already drawn. (Each of these passes requires an additional previous pass to generate the associated shadow map.)

The example pictures in this article used the OpenGL extension GL_ARB_shadow_ambient to accomplish the shadow map process in two passes.

[edit] See also

[edit] External links

[edit] Further reading

posted on 2008-12-22 14:49 zmj 閱讀(1517) 評論(0)  編輯 收藏 引用

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            aⅴ色国产欧美| 亚洲国产午夜| 性欧美办公室18xxxxhd| 亚洲欧美日韩精品| 亚洲午夜女主播在线直播| 在线亚洲+欧美+日本专区| 亚洲欧洲日韩在线| 久久久亚洲高清| 久久免费高清视频| 国产午夜精品一区二区三区视频 | 欧美亚男人的天堂| 亚洲免费观看高清完整版在线观看熊 | 国产一区二区三区网站| 一区二区欧美日韩视频| 美国成人直播| 久久综合狠狠综合久久综合88| 国产视频观看一区| 美女露胸一区二区三区| 另类av一区二区| 国产精品专区一| 亚洲欧美日韩一区在线| 亚洲精品乱码久久久久久黑人 | 日韩视频精品| 欧美福利电影网| 99国产精品视频免费观看| 夜夜嗨av一区二区三区网站四季av| 久久综合久久久久88| 免费在线成人av| 在线视频亚洲欧美| 国产日韩一级二级三级| 亚洲欧美成人精品| 欧美国产日本韩| 免费久久精品视频| 性做久久久久久久免费看| 影院欧美亚洲| 国产亚洲成av人片在线观看桃| 国产精品对白刺激久久久| 亚洲特黄一级片| 亚洲一区二区视频在线观看| 亚洲国产高清一区二区三区| 一本色道久久综合亚洲精品按摩 | 国产精品一区二区三区久久 | 免费观看成人www动漫视频| 亚洲另类自拍| 伊人精品成人久久综合软件| 国产欧美精品日韩| 欧美性淫爽ww久久久久无| 亚洲成人在线免费| 国产精品久久久久aaaa九色| 亚洲精品一区中文| 久久激情五月丁香伊人| 亚洲欧美日本日韩| 久久国产精品网站| 亚洲人成网站777色婷婷| 亚洲精品一区久久久久久| 亚洲欧美日韩在线高清直播| 欧美一区二区高清| 免费在线播放第一区高清av| 欧美精品在线免费观看| 国产精品亚洲综合| 亚洲另类春色国产| 久久精品论坛| 99热这里只有成人精品国产| 久久精品视频导航| 国产精品久久久久久一区二区三区| 国产亚洲综合在线| 亚洲在线视频免费观看| 亚洲国产精品成人一区二区| 欧美精品三级日韩久久| 欧美精品网站| 亚洲国产日韩欧美| 久久久久中文| 久久九九热re6这里有精品| 国产伦精品一区二区三区| 亚洲黄色影院| 蜜臀va亚洲va欧美va天堂| 99在线精品视频在线观看| 日韩午夜在线| 欧美va日韩va| 美女福利精品视频| 亚洲黄色av| 亚洲第一网站| 久久综合伊人77777尤物| 国产亚洲一区二区三区在线观看| 亚洲专区一区| 午夜精品偷拍| 亚洲国产精品欧美一二99| 欧美xx69| 欧美日韩一区免费| 亚洲激情成人| 夜夜嗨av色综合久久久综合网| 你懂的网址国产 欧美| 亚洲视频一区| 欧美一区二区视频在线观看2020 | 久久精品免费观看| 欧美国产日产韩国视频| 久久影视精品| 国产亚洲精品综合一区91| 一区二区三区视频观看| 99国产精品久久| 国产精品久久二区| 亚洲国产一区二区视频| 国产精品久久精品日日| 久久久国产成人精品| 欧美精品日韩| 久久午夜色播影院免费高清| 欧美高潮视频| 久久香蕉国产线看观看网| 欧美福利小视频| 亚洲高清二区| 久久亚洲视频| 欧美午夜宅男影院| 母乳一区在线观看| 国产精品一区免费观看| 亚洲精品日韩激情在线电影| 国产精品一级| 亚洲日本中文| 亚洲免费黄色| 你懂的国产精品永久在线| 久久乐国产精品| 狠狠色综合网| 午夜视频一区| 欧美一区二区| 国产一区二区黄| 欧美一级视频| 欧美一区日韩一区| 国产精品亚洲激情| 一区二区免费在线播放| 亚洲性夜色噜噜噜7777| 欧美日韩视频在线| 午夜宅男欧美| 亚洲国产高潮在线观看| 一本色道精品久久一区二区三区| 欧美插天视频在线播放| 亚洲欧洲日本mm| 亚洲在线视频| 亚洲国产一区二区在线| 欧美理论电影网| 欧美影视一区| 亚洲美女电影在线| 久久久精品国产免费观看同学 | 欧美ab在线视频| 正在播放日韩| 欧美大片免费观看| 欧美一站二站| 亚洲七七久久综合桃花剧情介绍| 裸体一区二区三区| 日韩视频一区| 国产一区二区三区久久精品| 欧美日韩三级视频| 欧美国产另类| 久久久久久亚洲精品杨幂换脸| 日韩亚洲不卡在线| 男女视频一区二区| 久久久精品国产一区二区三区| 一本一本久久a久久精品综合麻豆| 欧美性色aⅴ视频一区日韩精品| 一区二区三区成人| 亚洲一级黄色av| 在线亚洲伦理| 亚洲欧美三级伦理| 午夜亚洲伦理| 久久久999| 麻豆久久精品| 亚洲片区在线| 在线综合亚洲| 久久精品免费电影| 久久亚洲春色中文字幕| 男人的天堂成人在线| 欧美日韩免费在线视频| 国产精品久久国产精品99gif| 国产精品激情偷乱一区二区∴| 国产精品高潮呻吟久久av黑人| 国产精品激情偷乱一区二区∴| 国产视频一区二区在线观看| 影音先锋在线一区| 亚洲永久免费观看| 久久永久免费| 一本在线高清不卡dvd | 欧美一区二区三区免费视频| 久久久久国产精品www| 欧美 亚欧 日韩视频在线| 9久草视频在线视频精品| 欧美一区二区三区电影在线观看| 久久成人一区| 免费不卡在线观看av| 亚洲美女av黄| 欧美凹凸一区二区三区视频| 国产精品狼人久久影院观看方式| 永久免费视频成人| 一本色道久久综合狠狠躁篇怎么玩| 亚洲视频免费在线观看| 久久夜色精品| 亚洲一区免费观看| 欧美福利电影在线观看| 亚洲高清在线观看一区| 久久久水蜜桃| 久久av二区| 在线观看日韩av电影| 久久精品一区二区三区中文字幕|