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

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>
            欧美日本簧片| 国产精品美腿一区在线看| 狠狠色综合日日| 欧美在线观看视频| 小处雏高清一区二区三区| 国产精品嫩草99av在线| 欧美诱惑福利视频| 久久久久亚洲综合| 亚洲人成欧美中文字幕| 亚洲精品一区在线观看| 国产精品国产自产拍高清av| 亚洲欧美中文另类| 久久精品亚洲国产奇米99| 亚洲精品一二三| 一区二区电影免费观看| 国产一区二区三区久久精品| 美女网站久久| 欧美三级乱码| 久久全球大尺度高清视频| 美日韩精品免费| 亚洲夜间福利| 久久视频精品在线| 亚洲桃色在线一区| 久久美女性网| 亚洲一区二区少妇| 久久在线观看视频| 亚洲一区视频在线观看视频| 久久精品国产99精品国产亚洲性色 | 欧美亚洲一区二区三区| 久久精品国产在热久久 | 欧美激情第五页| 欧美一级二区| 欧美精品免费在线观看| 久久国产成人| 欧美日韩调教| 亚洲第一级黄色片| 国产伦精品一区二区三区视频黑人| 美女福利精品视频| 国产欧美日本在线| 亚洲精品小视频在线观看| 狠狠色伊人亚洲综合网站色| 一本久道久久综合狠狠爱| 激情综合色综合久久综合| 亚洲视频电影图片偷拍一区| 亚洲国产三级在线| 欧美资源在线| 香港成人在线视频| 欧美午夜一区| 亚洲毛片网站| 亚洲精品综合精品自拍| 久久久久久久一区二区三区| 欧美专区福利在线| 欧美性视频网站| 亚洲精品综合精品自拍| 最近看过的日韩成人| 久久久www成人免费无遮挡大片| 亚洲欧美三级在线| 国产精品男gay被猛男狂揉视频| 亚洲精品美女久久久久| 亚洲精品社区| 欧美成人tv| 亚洲欧洲精品成人久久奇米网 | 欧美搞黄网站| 亚洲大黄网站| a91a精品视频在线观看| 欧美激情一区二区三区| 亚洲国产精品成人一区二区| 亚洲国产精品成人久久综合一区| 久久精品国产亚洲精品| 久久最新视频| 亚洲第一精品福利| 免费久久精品视频| 亚洲国产欧美一区二区三区丁香婷| 亚洲国产精品热久久| 免费观看在线综合色| 亚洲国产精品一区| 在线中文字幕一区| 国产精品久久久久天堂| 午夜精品区一区二区三| 久久久综合激的五月天| 一区二区视频在线观看| 六月天综合网| 亚洲美女免费精品视频在线观看| 一本大道久久a久久精品综合| 欧美日韩国产成人在线| 亚洲一区二区三区三| 欧美中文在线观看| 在线播放豆国产99亚洲| 欧美久久久久久久| 午夜国产精品影院在线观看| 久久综合伊人| 一区二区三区**美女毛片| 国产精品嫩草影院av蜜臀| 久久久www成人免费精品| 亚洲福利一区| 欧美一区二区女人| 亚洲黄色有码视频| 国产精品乱人伦一区二区| 久久久久99| 一本久久知道综合久久| 久久综合久久综合这里只有精品| 亚洲啪啪91| 国产网站欧美日韩免费精品在线观看| 久久成人精品一区二区三区| 最新成人av网站| 久久久国产一区二区| 一区二区欧美精品| 激情文学一区| 国产精品高潮在线| 欧美成人精品三级在线观看| 9色porny自拍视频一区二区| 老司机午夜精品视频| 亚洲午夜羞羞片| 亚洲欧洲精品一区二区三区不卡 | 国产精品成人一区二区网站软件| 欧美在线亚洲综合一区| 日韩亚洲不卡在线| 蜜臀av国产精品久久久久| 亚洲综合第一| 亚洲精品字幕| 亚洲福利小视频| 国产性猛交xxxx免费看久久| 欧美日韩一区国产| 欧美a级一区| 久久色中文字幕| 欧美一区二区三区在线观看视频| 99精品欧美一区二区三区| 欧美成人高清视频| 久久亚洲视频| 久久精品国产一区二区电影| 亚洲性夜色噜噜噜7777| 亚洲美洲欧洲综合国产一区| 影音先锋欧美精品| 激情av一区| 国产一区二区三区免费观看| 国产精品久久久久久久午夜| 欧美激情二区三区| 免费在线观看精品| 美女黄色成人网| 裸体一区二区三区| 久久尤物视频| 麻豆av一区二区三区久久| 久久人人爽人人爽| 久久久人成影片一区二区三区| 欧美一区二区在线观看| 午夜亚洲性色福利视频| 欧美在线观看视频在线| 欧美在线视频一区| 久久久久久9| 久久综合久色欧美综合狠狠 | 亚洲欧美日韩国产成人精品影院| 中文亚洲免费| 亚洲欧美日韩国产中文在线| 香蕉久久久久久久av网站| 久久国产精品99国产| 久久久国产91| 欧美成人亚洲成人日韩成人| 欧美激情视频在线播放 | 欧美日韩一二三区| 国产精品毛片高清在线完整版| 欧美亚州在线观看| 国产午夜精品久久久久久免费视 | 欧美性生交xxxxx久久久| 国产精品久久久久久福利一牛影视| 国产精品久久久久久久久久尿| 国产伦精品一区二区三区照片91| 国产亚洲亚洲| 亚洲精品国产精品国自产在线 | 欧美在线你懂的| 久久综合狠狠综合久久综合88| 欧美成人免费全部| 一区二区日韩免费看| 性色av一区二区三区红粉影视| 久久蜜桃精品| 欧美日韩在线观看一区二区| 国产女主播一区二区| 亚洲国产精品综合| 亚洲在线电影| 欧美11—12娇小xxxx| 一区二区三区欧美亚洲| 欧美在线观看www| 欧美日韩www| 精品51国产黑色丝袜高跟鞋| 99成人精品| 久久久久网站| 99天天综合性| 蜜桃精品久久久久久久免费影院| 欧美三区在线视频| 在线成人av| 久久国产福利国产秒拍| 亚洲日本va午夜在线影院| 欧美综合国产精品久久丁香| 欧美巨乳波霸| 亚洲国产99精品国自产| 欧美一区二区三区免费视| 亚洲国产精品一区二区三区| 欧美一区永久视频免费观看| 欧美日韩亚洲一区二区三区在线观看 | 亚洲免费黄色| 女女同性精品视频|