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

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 閱讀(1284) 評(píng)論(1)  編輯 收藏 引用

評(píng)論

# 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  回復(fù)  更多評(píng)論   


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   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>
            久久成人这里只有精品| 欧美自拍偷拍| 精品99一区二区| 这里是久久伊人| 亚洲国产另类久久精品| 亚洲欧美日韩国产中文| 正在播放欧美一区| 久久综合九色综合欧美狠狠| 欧美亚洲在线观看| 欧美日韩一区综合| 亚洲欧洲综合| 亚洲国产成人一区| 欧美专区日韩专区| 午夜日本精品| 国产精品视频精品视频| 在线亚洲高清视频| 亚洲一区二区网站| 欧美日韩亚洲天堂| 99re8这里有精品热视频免费| 亚洲国产欧美日韩精品| 麻豆国产精品777777在线| 久久久最新网址| 一区在线观看视频| 久久午夜羞羞影院免费观看| 久久久青草青青国产亚洲免观| 国产精品一区二区久久久| 亚洲一区二区精品在线观看| 亚洲在线一区二区三区| 国产精品豆花视频| 亚洲已满18点击进入久久| 性欧美1819性猛交| 国产一区二区精品久久91| 欧美在线高清视频| 美国成人毛片| 91久久精品国产91性色tv| 欧美成人午夜激情| 亚洲久色影视| 欧美一区二区高清在线观看| 国产女人18毛片水18精品| 欧美中文在线免费| 欧美 日韩 国产 一区| 亚洲日韩中文字幕在线播放| 欧美日本免费| 午夜视频在线观看一区二区| 理论片一区二区在线| 亚洲日韩视频| 国产精品久久久久影院亚瑟 | 最新国产成人av网站网址麻豆| 亚洲精品视频在线播放| 欧美日韩一区二区在线观看| 亚洲午夜电影在线观看| 久久在线免费视频| 亚洲伦理精品| 国产伦精品一区二区三区视频黑人 | 亚洲视频在线一区| 国产精品久久亚洲7777| 久久精品亚洲| 亚洲美女在线视频| 欧美在线观看一二区| 亚洲第一中文字幕| 国产精品av一区二区| 久久av红桃一区二区小说| 91久久精品国产91性色tv| 欧美一区二区三区在线免费观看| 极品日韩av| 国产精品xnxxcom| 久久综合给合久久狠狠色| 99在线精品视频| 看欧美日韩国产| 亚洲在线不卡| 最近中文字幕mv在线一区二区三区四区| 欧美日韩在线不卡| 久久蜜桃香蕉精品一区二区三区| 亚洲精品乱码久久久久久日本蜜臀| 久久er精品视频| 一本久道久久久| 1769国产精品| 国产欧美精品日韩精品| 欧美激情影音先锋| 久久精品国产清高在天天线| 亚洲视频一二区| 亚洲国产午夜| 女人香蕉久久**毛片精品| 欧美亚洲午夜视频在线观看| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 激情一区二区三区| 国产精品视频精品视频| 欧美片网站免费| 免费观看亚洲视频大全| 久久精品国产清自在天天线| 亚洲一区二区免费在线| 99v久久综合狠狠综合久久| 麻豆精品视频在线观看视频| 欧美专区在线播放| 性色一区二区三区| 亚洲一区二区三区精品动漫| 99精品视频免费全部在线| 亚洲欧洲精品一区二区三区波多野1战4 | 久久天天躁狠狠躁夜夜av| 亚洲综合精品自拍| 亚洲网站在线看| 亚洲私人影院| 亚洲无玛一区| 亚洲午夜极品| 午夜电影亚洲| 欧美一区二区视频免费观看| 亚洲欧美中文另类| 亚洲欧美日韩网| 欧美一区二区三区在线观看视频| 亚洲欧美日韩一区二区在线| 亚洲一区二区在线免费观看| 亚洲一区在线免费| 亚洲男人的天堂在线aⅴ视频| 亚洲素人一区二区| 亚洲制服丝袜在线| 欧美一区二区三区四区视频| 欧美中文字幕视频| 久久久久久久网| 牛牛国产精品| 亚洲电影免费在线 | 99re6热在线精品视频播放速度| 最新国产成人av网站网址麻豆| 亚洲国产日韩在线| 在线视频日韩精品| 性欧美暴力猛交另类hd| 久久久久久久一区二区三区| 麻豆国产精品一区二区三区| 欧美激情一区二区三区在线视频观看| 欧美日韩精品二区| 国产精品一区二区a| 国产一区二区三区久久| 亚洲国产va精品久久久不卡综合| 亚洲日本黄色| 亚洲欧美国产va在线影院| 欧美一区亚洲二区| 欧美寡妇偷汉性猛交| 日韩网站在线| 久久精品免费观看| 欧美高清视频www夜色资源网| 欧美午夜免费电影| 国产自产v一区二区三区c| 最新中文字幕一区二区三区| 亚洲免费影院| 亚洲大胆美女视频| 亚洲一区二区成人在线观看| 久久久久久9| 欧美日韩在线三区| 激情综合色综合久久综合| 亚洲精品免费网站| 欧美有码在线视频| 91久久精品国产91性色tv| 亚洲欧美日韩成人| 欧美激情欧美激情在线五月| 国产欧美一区二区精品婷婷| 亚洲日本理论电影| 久久久久久久高潮| 日韩视频欧美视频| 久久一区二区三区国产精品| 欧美日韩日日骚| 亚洲第一综合天堂另类专| 午夜在线成人av| 亚洲精品欧美日韩专区| 久久精品一区二区三区中文字幕| 欧美日韩在线高清| 最新高清无码专区| 久久久久一区二区三区| 中文av字幕一区| 欧美黄色成人网| 伊人久久综合97精品| 欧美在线视频一区二区| 亚洲狼人精品一区二区三区| 久久夜色精品国产欧美乱| 国产亚洲人成网站在线观看| 中文在线一区| 亚洲区一区二区三区| 久久综合久色欧美综合狠狠| 国产欧美日韩三级| 亚洲欧美日韩精品一区二区 | 国产精品红桃| 中文日韩在线视频| 91久久久国产精品| 毛片一区二区三区| 悠悠资源网亚洲青| 久久亚洲精品一区二区| 欧美一区二区三区久久精品| 国产精品一区二区久久久| 亚洲一区二区黄| 亚洲最新视频在线播放| 欧美国产高清| 亚洲免费大片| 亚洲三级视频| 欧美午夜片欧美片在线观看| 亚洲视频免费观看| 在线亚洲一区| 国产精品麻豆va在线播放| 午夜欧美不卡精品aaaaa| 亚洲午夜免费福利视频| 国产欧美亚洲视频| 久久色在线观看| 久久综合中文色婷婷|