• <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>

            黎明的剔透里伸出了你沁清的曖昧

            Graphics|EngineDev|GameDev|2D&3D Art

              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              60 隨筆 :: 1 文章 :: 18 評(píng)論 :: 0 Trackbacks
            The pseudo code to implement parallax mapping is the following :

            float parallaxHeight = 0.035f
            float height = tex2D ( HeightMap ).r;
            float offset = parallaxHeight * ( 2.0f * height - 1.0f);
            float2 parallaxTexCoord = texCoord + offset * viewVec.xy;

            The height is a value between 0 and 1 but the offset is a value in the range [-parallaxHeight, +parallaxHeight]. The reason for this mapping is to distribute the distortion of the texture map equally in 2 directions.
             1attribute vec3 rm_Binormal;
             2attribute vec3 rm_Tangent;
             3
             4varying vec3 vCameraDir;
             5   
             6void main( void )
             7{
             8   gl_Position = ftransform();
             9   gl_TexCoord[0= gl_MultiTexCoord0;
            10
            11   vec4 view_position = gl_ModelViewMatrix * gl_Vertex;
            12   vec3 camera_dir = normalize(view_position.xyz);
            13   
            14   mat3x3  TangentSpace;
            15   TangentSpace[0= gl_NormalMatrix * rm_Tangent;
            16   TangentSpace[1= gl_NormalMatrix * rm_Binormal;
            17   TangentSpace[2= gl_NormalMatrix * gl_Normal;
            18
            19   vCameraDir = camera_dir * TangentSpace;
            20   // equal to .
            21   //vCameraDir.x = dot(camera_dir, TangentSpace[0]);
            22   //vCameraDir.y = dot(camera_dir, TangentSpace[1]);
            23   //vCameraDir.z = dot(camera_dir, TangentSpace[2]);
            24}




             1varying vec3 vCameraDir;
             2
             3uniform sampler2D DiffuseMap;
             4uniform sampler2D HeightMap;
             5
             6uniform float fHeight;
             7
             8void main( void )
             9
            10{
            11   vCameraDir = normalize(vCameraDir);
            12   
            13   vec3  texcoord = vec3(gl_TexCoord[0].xy, fHeight);
            14   
            15   float depth = (2.0*texture2D(HeightMap, texcoord).r-1.0*fHeight;
            16   vec3  texcoord_corrected = texcoord + vCameraDir.xyz * depth;
            17    
            18   gl_FragColor = texture2D(DiffuseMap, texcoord_corrected.xy); 
            19}




            http://knol.google.com/k/shader-fx-parallax-mapping#
            http://www.ownself.org/oswpblog/?p=59
            http://blog.csdn.net/soilwork/article/details/1452437
            posted on 2012-04-07 17:03 情絕格調(diào)(fresmaster) 閱讀(1356) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): GraphicsCoding
            久久久久亚洲av毛片大| 欧美黑人激情性久久| 久久久精品午夜免费不卡| 狠狠人妻久久久久久综合| 久久99热这里只频精品6| 人妻无码αv中文字幕久久 | 久久久噜噜噜久久中文字幕色伊伊 | 精品久久久久中文字幕一区| 狠狠久久综合| 久久国产免费观看精品3| 久久精品国产99久久久香蕉| 亚洲精品乱码久久久久久中文字幕 | 日韩久久无码免费毛片软件| 成人久久免费网站| 国产精品综合久久第一页| 亚洲人成网亚洲欧洲无码久久| 99久久精品免费观看国产| 久久A级毛片免费观看| 亚洲精品成人久久久| 国产福利电影一区二区三区久久久久成人精品综合 | 狠狠狠色丁香婷婷综合久久五月 | 国内精品伊人久久久久妇| 国产成人久久777777| 国产精品久久网| 久久久久成人精品无码中文字幕| 精品国产综合区久久久久久 | 久久综合九色综合97_久久久| 伊人久久大香线蕉亚洲五月天| 欧洲国产伦久久久久久久| 久久se这里只有精品| 国产精品成人99久久久久91gav | 久久久久亚洲AV无码专区首JN | 久久免费视频网站| 久久er热视频在这里精品| 国产三级久久久精品麻豆三级| 欧美牲交A欧牲交aⅴ久久| 色婷婷久久综合中文久久蜜桃av| 亚洲精品乱码久久久久久自慰| 综合网日日天干夜夜久久 | 久久精品国产欧美日韩| 青草影院天堂男人久久|