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

Shadow Techniques for Relief Texture Mapped Objects

http://www.gamasutra.com/view/feature/2420/book_excerpt_shadow_techniques_.php

The following is an excerpt from Advanced Game Development with Programmable Graphics Hardware (ISBN 1-56881-240-X) published by A K Peters, Ltd.

--

Integrating shadows to the relief map objects is an important feature in fully integrating the effect into a game scenario. The corrected depth option (see Chapter 5), which ensures that the depth values stored in Z-buffer include the displaced depth from the relief map, makes it possible to implement correct shadow effects for such objects. We consider the use of stencil shadows and shadow maps in this context. We can implement three types of shadows: shadows from relief object to the world, from the world to relief object and from relief object to itself (self-shadows).

Let us first consider what can be achieved using stencil volume shadows. When generating the shadow volumes, we can only use the polygons from the original mesh to generate the volume. This means that the shadows from relief objects to the world will not show the displaced geometry of the relief texture, but will reflect the shape of the original triangle mesh without the displaced pixels (Figure 1).


Figure 1. A relief mapped object cannot produce correct object to world shadows using shadow volumes.

However, as we have the corrected depth stored in Z-buffer when rendering the lighting pass we can have shadows volumes from the world projected onto the relief objects correctly, and they will follow the displaced geometry properly. Self-shadows (relief object to itself) are not possible with stencil shadows.

Thus, using relief maps in conjunction with shadow volumes, we have the following:

  • Relief object to world: correct silhouette or displacement visible in shadows is not possible.
  • World to relief object: shadows can project on displaced pixels correctly.
  • Relief object to relief object: not possible.

Relief mapped objects integrate much better into shadow map algorithms. Using a shadow map, we can resolve all three cases; as for any other object, we render the relief mapped object into the shadow map. As the shadow map only needs depth values, the shader, used when rendering the object to the shadow map, does not need to calculate lighting. Also if no self-shadows are desired, we could simplify the ray intersect function to invoke only the linear search (as in this case we only need to know if a pixel has an intersection and we do not need the exact intersection point). The shader used when rendering relief objects to a shadow map is given in Listing 4.4, and an example is shown in Figure 2.


Figure 2. Using relief mapped objects in conjunction with shadow maps. Shadows from relief object to world.

To project shadows from the world to the relief map objects, we need to pass the shadow map texture and light matrix (light frustum view/projection/bias multiplied by inverse camera view matrix). Then, just before calculating the final colour in the shader we project the displaced pixel position into the light space and compare the depth map at that position to the pixel depth in light space.

#ifdef RM_SHADOWS
  // transform pixel position to shadow map space
  sm= mul (viewinverse_lightviewprojbias,position);   
  sm/=sm.w;
  if (sm.z> f1tex2D (shadowmap,sm.xy))
    att=0; // set attenuation to 0
#endif


Figure 3. Shadows from world to relief objects. Left image shows normal mapping, and right image, relief mapping (notice how the shadow boundary follows the displaced relief correctly).

An example of this approach is shown in Figure 3. This is compared with a conventional render using a normal map in conjunction with a shadow map. Thus, using relief maps in conjunction with shadow maps, we can implement the following:

  • Relief object to world: good silhouette and displacement visible in
    shadows.
  • World to relief object: Shadows can project on displaced pixels correctly.
  • Relief object to relief object: possible if full linear/binary search and
    depth correct used when rendering to shadow map.

Listing 4.4
Using relief mapped objects in conjunction with shadow maps.

float ray_intersect_rm_shadow(
    
in sampler2D reliefmap,
    in float2 tx,
    in float3 v,
    in float f,
    in float tmax)
{
  const int linear_search_steps=10;

  float t=0.0;
  float best_t=tmax+0.001;
  float size=best_t/linear_search_steps;

  // search for first point inside object
  for ( int i=0;i<linear_search_steps-1;i++ )
  {
    t+=size;
    float3 p=ray_position(t,tx,v,f);
    float4 tex= tex2D (reliefmap,p.xy);
    if (best_t>tmax)
    if (p.z>tex.w)
         best_t=t;
  }

  return best_t;
}

f2s main_frag_relief_shadow(
    v2f IN,
    uniform sampler2D rmtex: TEXUNIT0 , // rm texture map
    uniform float4 planes,     // near and far plane info
    uniform float tile,                  // tile factor
    uniform float depth)       // depth factor
{
    f2s OUT;

    // view vector in eye space
    
float3 view= normalize (IN.vpos);

    // view vector in tangent space
    
float3 v= normalize ( float3 ( dot (view,IN.tangent.xyz),
        dot (view,IN.binormal.xyz), dot (-view,IN.normal)));

    // mapping scale from object to texture space
    
float2 mapping= float2 (IN.tangent.w,IN.binormal.w)/tile;

    // quadric coefficients transformed to texture space
    
float2 quadric=IN.curvature.xy*mapping.xy*mapping.xy/depth;

    // view vector in texture space
    
v.xy/=mapping;
    v.z/=depth;

    // quadric applied to view vector coodinates
    
float f=quadric.x*v.x*v.x+quadric.y*v.y*v.y;

    // compute max distance for search min(t(z=0),t(z=1))
    
float d=v.z*v.z-4*f;
    float tmax=100;
    if (d>0)     // t when z=1
        
tmax=(-v.z+ sqrt (d))/(-2*f);
    d=v.z/f;     // t when z=0
    if (d>0)
        
tmax= min (tmax,d);

#ifndef RM_DEPTHCORRECT
  // no depth correct, use simple ray_intersect
  float t=ray_intersect_rm_shadow(rmtex,IN. texcoord*tile,v,f,tmax);
  if (t>tmax)
      discard ; // no intesection, discard fragment
#else
    // with depth correct, use full ray_intersect
    float t=ray_intersect_rm(rmtex,IN.texcoord*tile,v,f,tmax);
    if (t>tmax)
        discard ; // no intesection, discard fragment

    // compute displaced pixel position in view space
    
float3 p=IN.vpos.xyz+view*t;

    // a=-far/(far-near)
    // b=-far*near/(far-near)
    // Z=(a*z+b)/-z
    
OUT.depth=((planes.x*p.z+planes.y)/-p.z);
#endif

    return OUT;
}

posted on 2008-12-22 16:26 zmj 閱讀(1276) 評論(1)  編輯 收藏 引用

評論

# re: Shadow Techniques for Relief Texture Mapped Objects 2009-02-02 20:10 zxx

year. use the modified shader to generate the tex used for shadow mapping  回復  更多評論   

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            一区二区三区欧美亚洲| 亚洲欧美日本日韩| 欧美在线播放视频| 激情综合在线| 午夜激情久久久| 亚洲国内在线| 亚洲视频欧美视频| 国产精品午夜电影| 亚洲女同性videos| 午夜精品美女自拍福到在线| 久久亚洲图片| 欧美日韩情趣电影| 国产欧美一区二区三区另类精品| 欧美在线短视频| 亚洲国产综合91精品麻豆| 欧美一区二区三区在线看| 欧美高清在线一区二区| 欧美成人免费观看| 欧美日韩中文在线| av不卡在线观看| 久久久久久久久蜜桃| 久久aⅴ乱码一区二区三区| 欧美有码视频| 欧美视频日韩视频在线观看| 免费短视频成人日韩| 久久久91精品国产一区二区精品| 久久精品国产一区二区电影| 加勒比av一区二区| 欧美99久久| 国产精品国产三级国产aⅴ入口| 亚洲精品久久久久久下一站 | 雨宫琴音一区二区在线| 亚洲精品影院| 一区二区动漫| 久久久91精品国产| 在线视频成人| 欧美性jizz18性欧美| 欧美与欧洲交xxxx免费观看| 国产亚洲精品美女| 久久久久久香蕉网| 美女精品国产| 欧美影视一区| 一区二区三区在线观看视频| 亚洲欧美日韩一区二区三区在线| 久久精品国产在热久久| 美女精品在线| 久久久精品五月天| 亚洲第一精品电影| 欧美—级a级欧美特级ar全黄| 一区二区久久| 久久福利精品| 国产精品五月天| 欧美日本久久| 性欧美8khd高清极品| 亚洲伦理在线| 欧美搞黄网站| 久久综合亚州| 亚洲精品孕妇| 国产免费一区二区三区香蕉精| 久久漫画官网| 亚洲免费不卡| 欧美大片一区| 亚洲免费黄色| 久久婷婷影院| 久久一二三区| 亚洲精品一区二区三区福利| 亚洲第一精品影视| 国产欧美婷婷中文| 久久在线免费观看视频| 亚洲精品在线免费观看视频| 玖玖精品视频| 久久大香伊蕉在人线观看热2| 91久久精品国产91久久| 久久久久.com| 午夜精品成人在线| 日韩一本二本av| 国产欧美精品日韩区二区麻豆天美| 欧美~级网站不卡| 91久久国产综合久久91精品网站| 伊人一区二区三区久久精品| 欧美一区二区久久久| 麻豆精品视频| 亚洲一二三四区| 免费日韩av片| 浪潮色综合久久天堂| 久久综合五月天婷婷伊人| 亚洲欧美视频在线观看| 亚洲深夜福利| 欧美激情第8页| 亚洲国产欧美日韩精品| 欧美日韩国产成人在线91| 久久精品亚洲乱码伦伦中文| 欧美成人黑人xx视频免费观看| 亚洲综合电影一区二区三区| 老司机午夜精品视频| 亚洲综合色自拍一区| 欧美大片在线看免费观看| 欧美专区在线观看一区| 久久久久在线| 欧美激情自拍| 欧美成va人片在线观看| 国产一区二区三区丝袜| 亚洲午夜激情| 亚洲女同同性videoxma| 国产视频在线观看一区二区| 亚洲视频视频在线| 欧美一区三区三区高中清蜜桃| 欧美国产高清| 亚久久调教视频| 久久五月天婷婷| 亚洲人成网站精品片在线观看| 久久久久久9999| 欧美黄在线观看| 亚洲另类黄色| 久久久国产视频91| 亚洲精品少妇| 一区二区三区四区五区精品视频| 国产色综合网| 欧美精品在线极品| 欧美激情一区二区三区在线视频| 亚洲美女视频在线观看| 欧美精品久久一区| 欧美1区2区3区| 亚洲美女网站| 国产精品中文字幕欧美| 欧美日韩国产精品| 久久av在线| 一区二区三区精品视频在线观看| 亚洲激情视频在线观看| 国产模特精品视频久久久久 | 欧美一级电影久久| 亚洲理论在线| 精品成人乱色一区二区| 国产精品久久久久久久久久直播| 午夜一级在线看亚洲| 欧美激情视频在线免费观看 欧美视频免费一 | 欧美精品激情在线| 香蕉精品999视频一区二区| 欧美黑人多人双交| 蜜臀a∨国产成人精品| 91久久国产综合久久| 亚洲国产精品va| 亚洲少妇诱惑| 国产亚洲在线观看| 欧美四级电影网站| 国产日本欧洲亚洲| 国产精品久久久久aaaa樱花| 欧美高清在线观看| 国产精品揄拍一区二区| 永久域名在线精品| 国产日韩欧美高清| 亚洲看片免费| 蜜乳av另类精品一区二区| 久久噜噜噜精品国产亚洲综合 | 亚洲欧美另类国产| 久久精品国产久精国产思思| 免费欧美在线视频| 黄色精品一区二区| 亚洲经典一区| 亚洲自拍电影| 欧美福利影院| 亚洲欧美日产图| 久久精品一区| 国产精品久久国产三级国电话系列 | 亚洲欧美视频一区二区三区| 欧美一区二区在线观看| 亚洲乱码国产乱码精品精可以看| 久久久久久9999| 在线观看中文字幕不卡| 麻豆成人综合网| 亚洲人精品午夜| 欧美成人精品h版在线观看| 国产一区二区三区视频在线观看 | 亚洲精品一二区| 亚洲午夜女主播在线直播| 久久精品一区二区三区不卡牛牛| 美女网站在线免费欧美精品| 亚洲第一级黄色片| 久久嫩草精品久久久精品| 亚洲欧美自拍偷拍| 亚洲国产女人aaa毛片在线| 欧美在线视频观看| 久久av一区二区三区漫画| 在线视频观看日韩| 亚洲人成高清| 欧美激情中文字幕乱码免费| 亚洲精品久久嫩草网站秘色| 国产精品自拍网站| 久久美女性网| 亚洲欧美在线另类| 国产一级精品aaaaa看| 麻豆精品在线观看| 久久国内精品自在自线400部| 一区二区三区鲁丝不卡| 亚洲国产精品一区二区久| 国产精品高潮久久| 欧美一级午夜免费电影| 欧美视频中文字幕在线| 久久久久国产精品一区| 另类av一区二区|