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

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>
            欧美日韩视频在线一区二区| 欧美成人精精品一区二区频| 国产精品第一页第二页第三页| 亚洲精品中文字幕有码专区| 亚洲国产另类久久精品| 久久久国产一区二区| 激情欧美日韩| 亚洲国产精品成人久久综合一区| 开心色5月久久精品| 亚洲人成艺术| 日韩视频不卡中文| 国产精品综合| 蜜桃久久av一区| 欧美日本韩国一区| 欧美一区二区视频在线观看2020 | 亚洲精品一区二区三区蜜桃久| 欧美黄色影院| 欧美手机在线| 久久亚洲综合色一区二区三区| 玖玖综合伊人| 亚洲一区二区三区精品动漫| 先锋影院在线亚洲| 亚洲区一区二区三区| 99视频一区二区| 国产午夜精品视频| 亚洲国产成人av在线| 欧美激情免费观看| 久久激情久久| 欧美激情1区2区3区| 欧美一级理论片| 欧美v日韩v国产v| 午夜亚洲福利| 欧美精品一区二区视频| 欧美一区二区在线观看| 欧美黄色小视频| 久久久久久亚洲精品中文字幕| 欧美精品日本| 免费在线观看精品| 国产精品自在欧美一区| 亚洲激情第一区| 韩国久久久久| 亚洲私人影院| 亚洲最新合集| 免费一区二区三区| 久久久久久久91| 国产精品美女久久久久久久| 欧美激情第二页| 国产一区清纯| 亚洲欧美在线磁力| 亚洲视频大全| 欧美日韩一二三区| 亚洲国产精品久久久久秋霞蜜臀| 国产日韩专区在线| 亚洲视频视频在线| 亚洲天堂成人| 欧美福利在线观看| 欧美国产视频在线观看| 国产原创一区二区| 亚洲欧美日韩国产中文| 亚洲一区二区三区在线观看视频| 欧美成年人在线观看| 女同性一区二区三区人了人一 | 久久精品五月婷婷| 欧美亚洲在线| 国产精品综合不卡av| 亚洲伊人伊色伊影伊综合网| 亚洲一区二区伦理| 国产精品久99| 亚洲性感美女99在线| 亚洲一区二区三区涩| 欧美新色视频| 亚洲欧美不卡| 久久福利资源站| 好吊色欧美一区二区三区四区| 欧美一二三区在线观看| 久久九九国产| 亚洲国产日日夜夜| 欧美韩日高清| 中日韩美女免费视频网站在线观看| 亚洲最新在线视频| 国产精品福利av| 亚洲欧美清纯在线制服| 久久精品一区二区三区四区 | 国产精品日本精品| 性刺激综合网| 欧美不卡三区| 夜夜嗨av一区二区三区免费区| 欧美日韩亚洲一区二区三区在线观看 | 小黄鸭精品aⅴ导航网站入口| 国产欧美激情| 久久色中文字幕| 最新国产の精品合集bt伙计| 中文在线一区| 国产一区999| 美女免费视频一区| 亚洲精品中文字| 久久久www免费人成黑人精品| 亚洲高清视频在线观看| 欧美色图麻豆| 久久福利影视| 亚洲开发第一视频在线播放| 午夜电影亚洲| 一区二区三区在线免费播放| 欧美精品精品一区| 性感少妇一区| 9色国产精品| 久久免费视频观看| 一本色道久久综合亚洲精品不| 国产三级欧美三级日产三级99| 美女视频网站黄色亚洲| 亚洲一级黄色片| 欧美激情一区三区| 欧美中文字幕视频在线观看| 亚洲大胆视频| 国产精品视频专区| 欧美国产免费| 欧美中文字幕在线视频| 日韩视频免费在线| 欧美va亚洲va国产综合| 欧美一区深夜视频| 一区二区三区四区国产精品| 国产主播一区二区三区四区| 欧美精品在线一区二区| 久久久.com| 亚洲欧美精品suv| 99re6这里只有精品| 欧美不卡视频| 久久综合色88| 久久久久国产精品一区三寸| 亚洲一区在线免费观看| 亚洲最黄网站| 一本久道综合久久精品| 尤物九九久久国产精品的分类| 国产九九精品| 国产精品亚洲激情| 欧美日韩在线不卡一区| 欧美高清视频在线观看| 久久在线播放| 麻豆免费精品视频| 久久综合网色—综合色88| 久久av一区二区三区漫画| 亚洲欧美精品一区| 亚洲一线二线三线久久久| 一区二区久久| 亚洲视频中文| 亚洲男人影院| 亚洲欧美日韩另类精品一区二区三区| 日韩一级黄色大片| 一区二区高清在线观看| 在线一区亚洲| 午夜精品免费| 欧美在线观看www| 久久久久国产精品麻豆ai换脸| 欧美在线视频网站| 久久精品视频免费播放| 久久午夜精品一区二区| 美女视频一区免费观看| 欧美激情黄色片| 欧美日韩国产精品一区二区亚洲| 欧美久久99| 国产精品三上| 国户精品久久久久久久久久久不卡| 激情婷婷久久| 亚洲精品久久久蜜桃| 一区二区三区国产在线| 亚洲欧美日韩精品在线| 久久久久久久久久久久久久一区| 久久人人97超碰国产公开结果| 玖玖综合伊人| 亚洲精品美女在线观看| 中文亚洲视频在线| 久久精品亚洲一区二区| 老鸭窝91久久精品色噜噜导演| 欧美电影在线免费观看网站| 欧美视频在线观看免费网址| 国产欧美韩国高清| 亚洲第一综合天堂另类专| 日韩一级精品| 久久久久免费| 日韩视频在线观看| 久久国产夜色精品鲁鲁99| 欧美极品在线播放| 国产日韩欧美另类| 亚洲精品国产拍免费91在线| 欧美一级久久久久久久大片| 欧美成人中文| 亚洲欧美日韩成人高清在线一区| 蜜臀久久久99精品久久久久久 | 亚洲天堂av电影| 美女脱光内衣内裤视频久久网站| 欧美性感一类影片在线播放| 在线观看欧美日韩国产| 亚洲一区二区三区在线视频| 欧美aa在线视频| 亚洲一区二区三区777| 欧美不卡视频一区| 狠狠网亚洲精品| 午夜精品免费视频| 91久久午夜| 久热综合在线亚洲精品|