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

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>
            亚洲人被黑人高潮完整版| 久久精品视频在线免费观看| 欧美大片专区| 欧美国产丝袜视频| 日韩亚洲国产欧美| 宅男噜噜噜66一区二区| 国产九九精品| 你懂的国产精品永久在线| 麻豆国产va免费精品高清在线| 亚洲第一黄网| 亚洲美女中文字幕| 国产精品视频你懂的| 久久午夜电影网| 欧美片第一页| 久久精品夜色噜噜亚洲a∨| 老司机午夜精品视频| 99视频有精品| 久久国产精品久久w女人spa| 亚洲精品乱码久久久久久蜜桃91| 亚洲视频在线免费观看| 激情久久综合| 亚洲午夜激情网站| 91久久精品视频| 亚洲一区自拍| 亚洲伦理在线观看| 欧美综合国产精品久久丁香| 日韩写真在线| 久久香蕉精品| 欧美一区二区高清在线观看| 男人天堂欧美日韩| 欧美一区二区三区在线观看| 你懂的视频欧美| 久久成人综合视频| 欧美色大人视频| 亚洲国产精品成人久久综合一区 | 亚洲在线视频网站| 亚洲欧洲日本mm| 久久精品一区四区| 午夜精品在线| 欧美性猛交xxxx乱大交蜜桃| 欧美成人小视频| 国产日韩欧美a| 亚洲网站在线播放| 在线亚洲免费视频| 欧美成人免费网| 欧美a级在线| 红桃视频欧美| 欧美一激情一区二区三区| 中文av一区特黄| 欧美片在线观看| 亚洲黄色精品| 亚洲精品一区二区三区99| 久久九九久久九九| 久久久久久久久综合| 国产精品亚洲第一区在线暖暖韩国| 亚洲国产精品小视频| 亚洲国产精品嫩草影院| 久久久久成人精品免费播放动漫| 欧美在线观看一二区| 国产精品天天摸av网| 亚洲天堂av在线免费观看| 亚洲一品av免费观看| 欧美午夜精品久久久| 一本不卡影院| 亚洲字幕一区二区| 国产精品永久| 欧美在线亚洲在线| 蜜桃av一区二区在线观看| 激情综合中文娱乐网| 久久男女视频| 91久久极品少妇xxxxⅹ软件| 亚洲日本中文字幕| 欧美日韩一区二区在线观看| 99www免费人成精品| 亚洲欧美综合国产精品一区| 国产精品午夜视频| 欧美在线视频二区| 欧美高清视频一区| 99在线精品免费视频九九视| 欧美视频在线视频| 午夜影院日韩| 欧美成人免费视频| 亚洲午夜电影在线观看| 国产精品亚洲综合一区在线观看 | 久久久精品免费视频| 欧美a一区二区| 一区二区三区偷拍| 国产精品午夜在线| 美女久久一区| 在线一区日本视频| 免费欧美高清视频| 中文一区二区| 精品999网站| 欧美三级特黄| 久久久www成人免费毛片麻豆| 欧美国产日本| 欧美一区二区高清| 亚洲乱码国产乱码精品精可以看 | 亚洲欧美日韩人成在线播放| 国内成+人亚洲+欧美+综合在线| 一本色道88久久加勒比精品 | 欧美日韩 国产精品| 亚洲主播在线观看| 亚洲国产美女| 久久精品人人做人人爽| 一本色道久久88精品综合| 国产亚洲视频在线| 欧美色图首页| 美女脱光内衣内裤视频久久网站| 国产亚洲人成网站在线观看| 欧美激情麻豆| 久久爱91午夜羞羞| 一区二区免费在线视频| 欧美丰满高潮xxxx喷水动漫| 亚洲欧美另类久久久精品2019| 亚洲激情第一区| 激情久久久久久久| 国产欧美午夜| 国产精品毛片a∨一区二区三区| 免费成人av在线看| 久久精品国产亚洲高清剧情介绍| 日韩一级大片在线| 91久久夜色精品国产网站| 老牛影视一区二区三区| 久久久久久久久久久久久女国产乱| 亚洲深夜激情| 99热在这里有精品免费| 一区二区三区在线免费观看| 国产欧美69| 国产精品免费小视频| 国产精品盗摄久久久| 欧美四级电影网站| 欧美日韩免费高清| 欧美日本不卡高清| 欧美日韩精品三区| 欧美日韩在线播放三区| 欧美日本一道本| 欧美日本网站| 国产精品国产自产拍高清av| 欧美日韩在线播放三区| 欧美性猛交xxxx乱大交蜜桃| 欧美午夜激情视频| 国产精品视频| 国产日韩欧美高清| 好看不卡的中文字幕| 狠狠噜噜久久| 亚洲国产欧美一区二区三区同亚洲| 在线播放国产一区中文字幕剧情欧美| 国产婷婷一区二区| 一区视频在线播放| 亚洲国产婷婷香蕉久久久久久| 亚洲国产综合在线| 99成人在线| 亚洲欧美激情精品一区二区| 亚洲欧美www| 久久久久久999| 欧美大片91| 一区二区三区日韩| 欧美主播一区二区三区美女 久久精品人| 午夜免费电影一区在线观看| 久久精品国产999大香线蕉| 久久免费偷拍视频| 欧美日韩免费看| 国产日韩精品一区二区| 亚洲第一中文字幕| 一区二区三区四区五区精品视频| 亚洲尤物在线| 裸体丰满少妇做受久久99精品 | 欧美伊人久久久久久久久影院| 久久久夜夜夜| 亚洲日本乱码在线观看| 亚洲嫩草精品久久| 欧美91大片| 国产精品一区毛片| 亚洲人成毛片在线播放| 亚洲欧美激情诱惑| 欧美mv日韩mv亚洲| 亚洲午夜久久久久久尤物| 久久久久久尹人网香蕉| 欧美日韩国产限制| 黄色小说综合网站| 在线视频免费在线观看一区二区| 小黄鸭精品aⅴ导航网站入口| 欧美成人小视频| 午夜精品国产更新| 欧美日本一区| 亚洲大片一区二区三区| 小黄鸭精品密入口导航| 亚洲全黄一级网站| 久久精品一区中文字幕| 国产精品美女一区二区在线观看| **网站欧美大片在线观看| 亚洲主播在线观看| 亚洲国产精品高清久久久| 欧美一区激情| 国产精品一区二区三区四区| 亚洲国产日韩欧美在线99 | 久久久九九九九| 日韩一级大片| 欧美精品三区|