• <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++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              60 隨筆 :: 1 文章 :: 18 評論 :: 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 情絕格調(fresmaster) 閱讀(1369) 評論(0)  編輯 收藏 引用 所屬分類: GraphicsCoding
            久久99精品九九九久久婷婷| 色噜噜狠狠先锋影音久久| 亚洲?V乱码久久精品蜜桃 | 伊人久久免费视频| 久久黄视频| 亚洲国产精品无码久久一区二区| 久久er热视频在这里精品| 亚洲国产精品综合久久网络 | 久久天天躁狠狠躁夜夜av浪潮| 亚洲愉拍99热成人精品热久久| 国产叼嘿久久精品久久| 99久久国产精品免费一区二区| 国产AⅤ精品一区二区三区久久| 无码人妻久久一区二区三区免费 | 无码人妻精品一区二区三区久久久 | 99久久99这里只有免费的精品| 人人狠狠综合久久亚洲| 国产成人精品综合久久久久| 久久精品亚洲福利| 2021国产成人精品久久| 97久久精品人妻人人搡人人玩| 国内高清久久久久久| 伊人久久大香线蕉成人| 欧美久久综合九色综合| 久久九色综合九色99伊人| 久久香蕉一级毛片| 狠狠狠色丁香婷婷综合久久五月| 久久精品国产亚洲AV香蕉| 久久人人添人人爽添人人片牛牛| 色狠狠久久综合网| 久久福利资源国产精品999| 青春久久| 久久精品极品盛宴观看| 婷婷久久综合九色综合绿巨人| 精品国产婷婷久久久| 久久久久亚洲av毛片大| 久久综合伊人77777| 色偷偷88欧美精品久久久| 一日本道伊人久久综合影| 久久久久亚洲AV片无码下载蜜桃| 亚洲AV日韩精品久久久久久|