• <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++博客 :: 首頁 :: 新隨筆 :: 聯(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) 閱讀(1359) 評(píng)論(0)  編輯 收藏 引用 所屬分類: GraphicsCoding
            久久SE精品一区二区| 久久精品无码一区二区WWW| 国内精品伊人久久久久| 国产91色综合久久免费分享| 亚洲综合精品香蕉久久网97| 色偷偷88欧美精品久久久 | 久久九九青青国产精品| 久久国产成人午夜aⅴ影院| 久久精品国产清自在天天线| 国产精品久久久久久| 国产精品久久久久久五月尺| 国产欧美一区二区久久| 久久综合九色综合网站| 欧美一区二区精品久久| 欧美va久久久噜噜噜久久| 久久国产精品一区| 久久精品国产亚洲AV无码偷窥| 久久久久久久久久久免费精品| 久久久精品2019免费观看| 亚洲欧美成人久久综合中文网 | 久久精品国产精品亚洲精品| 精品人妻伦九区久久AAA片69| 久久无码专区国产精品发布 | 国产成人精品久久一区二区三区 | 欧美日韩成人精品久久久免费看| 秋霞久久国产精品电影院| 色综合久久久久综合体桃花网| 国产女人aaa级久久久级| 国内精品久久九九国产精品| 久久精品国产亚洲AV嫖农村妇女 | 国产精品久久网| 国产精品无码久久久久久| 久久婷婷五月综合色高清| 无码国内精品久久人妻蜜桃| 7777精品伊人久久久大香线蕉| 人人狠狠综合久久亚洲| 久久久久亚洲AV无码专区网站| 久久涩综合| 久久精品国产亚洲αv忘忧草| 久久精品国产亚洲AV香蕉| 久久综合狠狠综合久久|