• <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>
            隨筆 - 505  文章 - 1034  trackbacks - 0
            <2006年11月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789


            子曾經(jīng)曰過:編程無他,唯手熟爾!

            常用鏈接

            留言簿(94)

            隨筆分類(649)

            隨筆檔案(505)

            相冊

            BCB

            Crytek

            • crymod
            • Crytek's Offical Modding Portal

            Game Industry

            OGRE

            other

            Programmers

            Qt

            WOW Stuff

            搜索

            •  

            積分與排名

            • 積分 - 914456
            • 排名 - 14

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜


            截圖:





            LPDIRECT3DVERTEXSHADER9         g_pVertexShader = NULL;
            LPD3DXCONSTANTTABLE             g_pConstantTable 
            = NULL;
            LPDIRECT3DVERTEXDECLARATION9    g_pVertexDeclaration 
            = NULL;


            OnCreateDevice


                D3DVERTEXELEMENT9 decl[] =
                {
                    { 
            00, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
                    D3DDECL_END()
                };

                V_RETURN( pd3dDevice
            ->CreateVertexDeclaration( decl, &g_pVertexDeclaration ) );

            創(chuàng)建vertex shader

                // Assemble the vertex shader from the file
                V_RETURN( D3DXCompileShaderFromFile( strPath, NULL, NULL, "Ripple",
                                                     
            "vs_2_0", dwShaderFlags, &pCode,
                                                     NULL, 
            &g_pConstantTable ) );

                
            // Create the vertex shader
                hr = pd3dDevice->CreateVertexShader( ( DWORD* )pCode->GetBufferPointer(),
                                                     
            &g_pVertexShader );



            每幀設置shader里面的常量
            void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext )
            {
                
            // Update the camera's position based on user input 
                g_Camera.FrameMove( fElapsedTime );

                
            // Set up the vertex shader constants
                D3DXMATRIXA16 mWorldViewProj;
                D3DXMATRIXA16 mWorld;
                D3DXMATRIXA16 mView;
                D3DXMATRIXA16 mProj;

                mWorld 
            = *g_Camera.GetWorldMatrix();
                mView 
            = *g_Camera.GetViewMatrix();
                mProj 
            = *g_Camera.GetProjMatrix();

                mWorldViewProj 
            = mWorld * mView * mProj;

                g_pConstantTable
            ->SetMatrix( DXUTGetD3D9Device(), "mWorldViewProj"&mWorldViewProj );
                g_pConstantTable
            ->SetFloat( DXUTGetD3D9Device(), "fTime", ( float
             )fTime );
            }


            Vertex Shader代碼

            HLSLwithoutEffects.vsh
            float4x4 mWorldViewProj;  // World * View * Projection transformation
            float fTime;              // Time parameter. This keeps increasing


            //-----------------------------------------------------------------------------
            // Vertex shader output structure
            //-----------------------------------------------------------------------------
            struct VS_OUTPUT
            {
                float4 Position   : POSITION;   
            // vertex position 
                float4 Diffuse    : COLOR0;     // vertex diffuse color
            };


            //-----------------------------------------------------------------------------
            // Name: Ripple
            // Type: Vertex shader                                      
            // Desc: This shader ripples the vertices
            //-----------------------------------------------------------------------------
            VS_OUTPUT Ripple( in float2 vPosition : POSITION )
            {
                VS_OUTPUT Output;
                
                
            float fSin, fCos;   
                
            float x = length( vPosition ) * sin( fTime ) * 15.0f;
                
                
            // This HLSL intrinsic computes returns both the sine and cosine of x
                sincos( x, fSin, fCos );

                
            // Change the y of the vertex position based on a function of time 
                
            // and transform the vertex into projection space. 
                Output.Position = mul( float4( vPosition.x, fSin * 0.1f, vPosition.y, 1.0f ), mWorldViewProj );
                
                
            // Output the diffuse color as function of time and 
                
            // the vertex's object space position
                Output.Diffuse = 0.5f - 0.5f * fCos;
                
                
            return Output;
            }



            posted on 2008-11-18 14:33 七星重劍 閱讀(950) 評論(0)  編輯 收藏 引用 所屬分類: Game GraphicsHLSL&ShaderMonkey
            久久91精品国产91| 国产一区二区三区久久| 久久久久亚洲AV成人网人人软件| 久久亚洲综合色一区二区三区| 国产欧美久久一区二区| 久久国产福利免费| 热99RE久久精品这里都是精品免费 | 国产99久久九九精品无码| 青青青青久久精品国产h| 精品久久久久中文字| 久久国产色av免费看| 国产精品毛片久久久久久久| 久久国产免费直播| 久久综合精品国产二区无码| 久久精品国产亚洲麻豆| 国产精品中文久久久久久久| 国产精品久久国产精麻豆99网站| 日韩AV毛片精品久久久| 国产亚洲精品自在久久| 久久热这里只有精品在线观看| 国产精品99久久久久久人| 色狠狠久久综合网| 一本大道久久a久久精品综合| 欧美久久天天综合香蕉伊| 久久久久久午夜成人影院| 欧美国产成人久久精品| 99久久婷婷国产综合亚洲| 综合久久精品色| 国产精品美女久久久免费| 丰满少妇人妻久久久久久| 久久人妻AV中文字幕| 久久人妻少妇嫩草AV无码蜜桃| 精品久久久久久久国产潘金莲| 精品久久久久久无码中文野结衣| 99久久人妻无码精品系列蜜桃| 亚洲精品乱码久久久久久按摩| 亚洲国产视频久久| 久久久久久精品久久久久| 久久乐国产综合亚洲精品| 热99RE久久精品这里都是精品免费 | 亚洲人成伊人成综合网久久久 |