• <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
            婷婷久久综合九色综合绿巨人| 久久精品无码一区二区三区免费| 亚洲伊人久久精品影院| 精品一二三区久久aaa片| 国产精品久久久久久久久| 国产99久久九九精品无码| 久久这里只精品99re66| 国内精品久久久久影院优| 久久福利片| 97久久超碰国产精品旧版| 久久伊人五月天论坛| 久久精品国产亚洲av日韩| 午夜精品久久久内射近拍高清| 国产精品一区二区久久国产| 久久久久亚洲AV无码专区桃色| 久久综合久久自在自线精品自| 久久综合久久鬼色| 成人国内精品久久久久影院| 无码任你躁久久久久久老妇App| 色综合久久中文综合网| 人妻精品久久久久中文字幕69 | 欧美亚洲国产精品久久高清| 久久精品国产亚洲欧美| 久久免费的精品国产V∧ | 国产精品成人久久久久久久| 久久综合久久自在自线精品自| 久久久黄色大片| 亚洲国产一成久久精品国产成人综合| 久久91精品国产91久久小草| 奇米影视7777久久精品| 久久夜色精品国产欧美乱| 亚洲AV日韩AV天堂久久| 久久精品国产99久久久古代| 一本综合久久国产二区| 亚洲国产精品成人久久蜜臀| 久久一区二区三区99| 色播久久人人爽人人爽人人片aV| 国产综合免费精品久久久| 精品久久久久久无码中文字幕 | 国产午夜久久影院| 亚洲国产精品热久久|