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

            4D星宇

            c++

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              57 隨筆 :: 0 文章 :: 39 評(píng)論 :: 0 Trackbacks

            剛開始學(xué)習(xí)DX10,發(fā)覺模型文件已經(jīng)從原來的X格式變?yōu)镾DKMESH格式,也就是說DX10不直接支持X文件了,
            那現(xiàn)在該怎么辦,我在NVSDK下找到了他的解決方案,先用DX9的接口打開X文件,再用DX10接口來渲染文件。
                     在DX10下,缺少了很多以前在DX9下的元素。比如,光照,材質(zhì)等。
                     要實(shí)現(xiàn)這些元素,就必須在SHADER下手動(dòng)去實(shí)現(xiàn),那就意味著你必須熟悉圖形學(xué)的內(nèi)容,特別是其中的光照模型等內(nèi)容。
            比如,方向光的實(shí)現(xiàn):
                //directional light-----------------------------------------------------------------
                float3 lightDir = g_lightPos - In.worldPos;
                float3 lightDirNorm = normalize(lightDir);
                float3 SDir = normalize( g_lightPos - g_eyePos);
                float cosGammaDir = dot(SDir, V);
                float dirLighting = g_Kd*dirLightIntensity*saturate( dot( N,lightDirNorm ) );
                //diffuse
                float3 diffuseDirLight = dirLighting*exDir;       
                //airlight
                float3 dirAirLight = phaseFunctionSchlick(cosGammaDir)* dirLightIntensity*float3(1-exDir.x,1-exDir.y,1-exDir.z);
                //specular
                float3 specularDirLight = saturate( pow(  dot(lightDirNorm,reflVect),g_specPower)) * dirLightIntensity * g_KsDir * exDir;
            點(diǎn)光源的實(shí)現(xiàn):
              //point light 1---------------------------------------------------------------------
                //diffuse surface radiance and airlight due to point light
                float3 pointLightDir = g_PointLightPos - In.worldPos;
                //diffuse
                float3 diffusePointLight1 = calculateDiffusePointLight(0.1,Dvp,g_DSVPointLight,pointLightDir,N,V);
                //airlight
                float3 airlight1 = calculateAirLightPointLight(Dvp,g_DSVPointLight,g_VecPointLightEye,V);
                //specular
                float3 specularPointLight = Specular(g_PointLightIntensity, g_KsPoint, length(pointLightDir), Dvp, g_specPower, normalize(pointLightDir), reflVect);
            計(jì)算點(diǎn)光源的漫射光:
            float3 calculateDiffusePointLight(float Kd,float Dvp,float Dsv,float3 pointLightDir,float3 N,float3 V)
            {

                float Dsp = length(pointLightDir);
                float3 L = pointLightDir/Dsp;
                float thetas = acos(dot(N, L));
                float lightIntensity = g_PointLightIntensity * 100;
               
                //spotlight
                float angleToSpotLight = dot(-L, g_SpotLightDir);
                if(g_useSpotLight)
                {    if(angleToSpotLight > g_cosSpotlightAngle)
                         lightIntensity *= abs((angleToSpotLight - g_cosSpotlightAngle)/(1-g_cosSpotlightAngle));
                     else
                         lightIntensity = 0;        
                }  
               
                //diffuse contribution
                float t1 = exp(-g_beta.x*Dsp)*max(cos(thetas),0)/Dsp;
                float4 t2 = g_beta.x*Gtable.SampleLevel(samLinearClamp, float2((g_beta.x*Dsp-g_diffXOffset)*g_diffXScale, (thetas-g_diffYOffset)*g_diffYScale),0)/(2*PI);
                float rCol = (t1+t2.x)*exp(-g_beta.x*Dvp)*Kd*lightIntensity/Dsp;
                float diffusePointLight = float3(rCol,rCol,rCol); 
                return diffusePointLight.xxx;
            }
            計(jì)算高光:
            float3 Specular(float lightIntensity, float Ks, float Dsp, float Dvp, float specPow, float3 L, float3 VReflect)
            {
                lightIntensity = lightIntensity * 100;
                float LDotVReflect = dot(L,VReflect);
                float thetas = acos(LDotVReflect);

                float t1 = exp(-g_beta*Dsp)*pow(max(LDotVReflect,0),specPow)/Dsp;
                float4 t2 = g_beta.x*G_20table.SampleLevel(samLinearClamp, float2((g_beta.x*Dsp-g_20XOffset)*g_20XScale, (thetas-g_20YOffset)*g_20YScale),0)/(2*PI);
                float specular = (t1+t2.x)*exp(-g_beta.x*Dvp)*Ks*lightIntensity/Dsp;
                return specular.xxx;
            }
            下一步,考慮如何不通過DX9接口,直接導(dǎo)入X文件。

            posted on 2008-07-17 10:26 bloodbao 閱讀(851) 評(píng)論(2)  編輯 收藏 引用 所屬分類: c++

            評(píng)論

            # re: 由X文件導(dǎo)入引發(fā)的。。 2008-08-04 16:02 無名劍
            X文件的讀取只需要使用DX9里面的那幾個(gè)頭文件把那GUID搞到就行了
            主要是識(shí)別里面元素的類型是什么 然后對(duì)相應(yīng)的元素做處理

            PS:DX的API老是在變,實(shí)在是件很郁悶人的事  回復(fù)  更多評(píng)論
              

            # re: 由X文件導(dǎo)入引發(fā)的。。[未登錄] 2008-08-06 15:10 BLOODBAO
            哦,謝了,有空,再瞧瞧!
            DX11不知會(huì)怎么變?  回復(fù)  更多評(píng)論
              

            噜噜噜色噜噜噜久久| 久久91精品国产91久久户| 久久影视综合亚洲| 亚洲欧美一区二区三区久久| 国产欧美久久久精品影院| 亚洲AV无码成人网站久久精品大| 国产一级持黄大片99久久| 久久精品国产一区二区电影| 久久久精品人妻一区二区三区蜜桃 | 色综合久久夜色精品国产| 久久综合久久自在自线精品自| 久久国产精品99精品国产987| 久久人人超碰精品CAOPOREN| 精品无码久久久久国产| 久久中文精品无码中文字幕| 久久无码人妻一区二区三区午夜 | 91亚洲国产成人久久精品网址 | 久久久噜噜噜久久中文福利| 国产午夜福利精品久久| 亚洲AV无码成人网站久久精品大| 久久国产三级无码一区二区| 久久超碰97人人做人人爱| 久久久亚洲裙底偷窥综合| 久久久久综合国产欧美一区二区| 久久99国内精品自在现线| 中文字幕无码精品亚洲资源网久久| 久久99精品久久久久久野外 | 一本一本久久a久久精品综合麻豆| 国产精品久久自在自线观看| 少妇久久久久久被弄高潮| 伊人久久无码精品中文字幕| 久久精品18| 日韩精品无码久久一区二区三| 久久午夜电影网| 大蕉久久伊人中文字幕| 99久久无色码中文字幕| 久久99国产精品久久99| 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 | 国内精品伊人久久久久| 青青国产成人久久91网| 国内精品久久久久久不卡影院|