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

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 閱讀(1281) 評論(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  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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>
            久久婷婷丁香| 海角社区69精品视频| 亚洲国产另类精品专区| 午夜一区二区三区在线观看| 久久久国产精彩视频美女艺术照福利 | 日韩一区二区电影网| 亚洲欧洲偷拍精品| 国产精品久久久久久模特| 欧美一区二区三区播放老司机| 久久综合色婷婷| 国产精品视频yy9299一区| 久久久精品国产免大香伊| 欧美成人在线免费观看| 亚洲一区二区三区视频| 国产亚洲一区二区在线观看| 欧美freesex8一10精品| 亚洲欧美日韩在线播放| 亚洲第一精品福利| 欧美日韩精品免费| 欧美中文字幕在线播放| 中文在线不卡| 欧美大片免费观看在线观看网站推荐| 国产中文一区| 欧美午夜精品久久久久久超碰| 久久天天躁狠狠躁夜夜av| 亚洲日本激情| 美女网站久久| 欧美诱惑福利视频| 欧美无乱码久久久免费午夜一区| 国产精品高潮呻吟久久| 欧美日韩1区2区3区| 99国产精品私拍| 免费亚洲电影在线| 国产精品久久久久久久久久直播| 欧美另类一区二区三区| 久久先锋资源| 欧美日韩三级电影在线| 你懂的亚洲视频| 国产精品久久久久久久久久尿| 红桃视频一区| 亚洲欧美日韩精品久久亚洲区 | 久久精品卡一| 欧美视频在线观看| 欧美日一区二区在线观看| 国产日韩欧美成人| 国产综合激情| 欧美在线观看网址综合| 欧美日韩精品国产| 亚洲激情网址| 麻豆国产精品777777在线| 亚洲一区二区三| 午夜一区二区三视频在线观看| 欧美精品一区二区在线观看| 在线观看欧美黄色| 亚洲国产精品免费| 亚洲精品美女在线观看播放| 亚洲精品在线看| 99视频超级精品| 日韩视频一区二区三区| 久久久久九九视频| 亚洲一级黄色片| 免费亚洲一区二区| 欧美一区二区成人6969| 欧美日韩国产综合视频在线| 国产亚洲精品成人av久久ww| 亚洲一区不卡| 亚洲电影免费在线| 亚洲人成人99网站| 欧美高清自拍一区| 久久久精品日韩欧美| 国产精品高清一区二区三区| 亚洲国产精品日韩| 久久久人成影片一区二区三区观看 | 一区二区三区精密机械公司| 亚洲精品乱码久久久久久蜜桃91 | 欧美aⅴ一区二区三区视频| 国产农村妇女毛片精品久久麻豆| 亚洲激情在线观看视频免费| 亚洲视频在线视频| 国产一区二区电影在线观看| 在线成人小视频| 午夜精品福利在线观看| 欧美在线免费看| 亚洲女人天堂av| 玖玖玖免费嫩草在线影院一区| 亚洲人精品午夜| 欧美绝品在线观看成人午夜影视| 亚洲国产一区在线观看| 欧美大片免费观看| 国产欧美短视频| 亚洲女爱视频在线| 日韩午夜三级在线| 国产精品啊啊啊| 亚洲欧美日韩国产中文| 亚洲二区在线视频| 欧美a级一区二区| 亚洲精品午夜| 日韩视频一区二区三区在线播放| 欧美日韩国产欧美日美国产精品| 日韩午夜av在线| 日韩视频―中文字幕| 国产精品成人免费| 午夜精品成人在线视频| 欧美1区2区3区| 亚洲在线观看视频网站| 亚洲欧美一区二区视频| 激情亚洲网站| 亚洲片在线资源| 国产精品大片wwwwww| 欧美怡红院视频| 99国内精品久久| 在线观看一区| 亚洲开发第一视频在线播放| 日韩亚洲视频| 国产亚洲欧美日韩一区二区| 久久夜色精品国产噜噜av| 欧美 日韩 国产精品免费观看| 亚洲精品激情| 亚洲欧美日韩综合国产aⅴ| 在线观看欧美视频| 亚洲精品视频在线观看网站| 国产深夜精品福利| 欧美在线综合| 久久野战av| 亚洲一区在线直播| 久久亚洲不卡| 亚洲色图自拍| 欧美一区激情视频在线观看| 亚洲精品视频在线看| 亚洲欧美精品suv| 亚洲精品一二三区| 欧美中文在线观看| 在线精品亚洲一区二区| 国产欧美日韩一级| 久久婷婷国产综合国色天香| 欧美在线视频免费观看| 欧美乱大交xxxxx| 亚洲一区二区三区免费视频 | 国产精品私房写真福利视频 | 亚洲高清不卡在线| 国产美女诱惑一区二区| 亚洲午夜高清视频| 久久久久天天天天| 六月丁香综合| 国产精品红桃| 亚洲一区精品在线| 亚洲伊人一本大道中文字幕| 久久国产婷婷国产香蕉| 欧美a级理论片| 最近中文字幕日韩精品| 国产综合自拍| 久久免费视频网| 久久久青草青青国产亚洲免观| 久久久精品日韩| 欧美国产视频日韩| 1024亚洲| 久久久91精品国产| 久久国产成人| 国产目拍亚洲精品99久久精品| 99国产一区| 亚洲伊人伊色伊影伊综合网| 国产欧美一区二区三区国产幕精品| 一二美女精品欧洲| 亚洲精品日韩久久| 久久精品国产亚洲高清剧情介绍| 亚洲视频网在线直播| 美女国内精品自产拍在线播放| 狠狠色狠狠色综合日日91app| 久久国产夜色精品鲁鲁99| 欧美偷拍另类| 亚洲精品国精品久久99热一| 亚洲精品国精品久久99热| 欧美激情一区二区三区在线视频观看| 亚洲青色在线| 91久久夜色精品国产九色| 久久久久久久久久久久久女国产乱 | 99国产麻豆精品| 亚洲欧美日韩在线高清直播| 欧美成人精品三级在线观看| 亚洲欧美国产毛片在线| 久久精品中文字幕免费mv| 狠狠色综合色综合网络| 美女脱光内衣内裤视频久久网站| 男人的天堂成人在线| 亚洲精品亚洲人成人网| 欧美午夜不卡在线观看免费| 亚洲国产婷婷综合在线精品 | 国产精品社区| 午夜一级久久| 免费高清在线一区| 一区二区三区久久| 亚洲视频一起| 亚洲视频在线观看视频| 欧美日韩精品一区二区在线播放| 亚洲欧美激情诱惑| 免费一级欧美片在线观看| 欧美精品18+| 亚洲精品永久免费| 国产精品久久久久一区| 久久久久一本一区二区青青蜜月|