![]() |
|
Spaces home Yelz的江湖PhotosProfileFriendsMore ![]() | ![]() |
Yelz的江湖May 01 Implement Skinned animation (with vertex diffuse, specular and fog) by Vertex ShaderThe demands: 1. Implement skinned animation with vertex shader 2. Implement vertex diffuse, specular and fog in the vertex shader. During the period I am focusing on implementing the above features, I refered different materials, D3DX SDK help, Google, Gamedev.net...such like that. They are helpful, but none of them is really work! D3DX SDK sample doesn't show the way to do specular and fog. It also failed to emphasize the points new HLSL programmers (like me) need to pay attention. Pages searched by google are too cursory and full with mistake. It tooks me much time to get everything work. Here is the piece of shader code. I am trying to add enough comments so that you can not only know "how" but also know "why". ////// Shader file for skin animation///////////////////////////////////////////// // Matrx used to do camera space transformations. it is worldMatrix * viewMatrix // Lighting constant // Matrix Pallette float4x3 mWorldMatrixArray[MAX_MATRICES]:WORLDMATRIXARRAY1; float4x4 mGlobalWorldViewProjMatrix : COMBINEDMATRIX; /////////////////////////////////////////////////////////// struct VS_OUTPUT VS_OUTPUT VShade(VS_INPUT i, uniform int NumBones) // Compensate for lack of UBYTE4 on Geforce3 // case the vectors to arrays for use in the for loop below // caculate the pos/normal using the "normal" weights // For 3x3 part of mWorldMatrixArray[i], mWorldMatrixArray[i] = Transpose(Inverse(mWorldMatrixArray[i])), // Now that we have the calculated weight, add in the final influence // transform position from world space into view and then projection space // Compiler don't know Pos is a position, so, we need to add .w item by hand // For 3x3 part of matWorldView, matWorldView = Transpose(Inverse(matWorldView)), float NLDot = max(0, dot(NormalInpCameraSpace, lightDirection.xyz)); o.Diffuse = globalAmbient + combinedDiffuse * NLDot; if (fogParameter.x > 0.0f) // Copy the input texture coordinate through ////////////////////////////////////// ///// C++ Part //// D3DXMATRIXA16 combinedMat; // Set Lighting Parameters D3DLIGHT9 light; D3DXVECTOR4 lightDirection(light.Direction.x, light.Direction.y, light.Direction.z, 0.0f); // Set light and use the .w to set the power for specular m_pSkinEffect->SetVector("lightDirection", &lightDirection); D3DXCOLOR combinedDiffuse; D3DXCOLOR combinedSpecular; DWORD dwFlogFlag = 0; D3DXMatrixMultiply(&combinedMat, &combinedMat, &m_ProjMatrix); DWORD dwDrawnFaceCount = 0; if (m_MatrixPalette[uPalleteEntry] != m_boneMatrix[uMatrixIndex]) hr = m_pSkinEffect->SetMatrixArray("mWorldMatrixArray", m_MatrixPalette, pAnimationData->m_paletteSize); hr = m_pSkinEffect->SetMatrix("mGlobalWorldViewProjMatrix", &combinedMat); hr = m_pSkinEffect->SetInt("CurNumBones", pAnimationData->m_dwMaxVertInfl-1); UINT numPasses; for (UINT iPass = 0; iPass < numPasses; iPass++) pDevice->DrawIndexedPrimitive( ... ); m_pSkinEffect->EndPass(); m_pSkinEffect->End(); dwDrawnFaceCount += faceGroup.FaceCount; Becuase the matrix palette is usually too small for a whole model, we need to use ID3DXSkinInfo::ConvertToIndexedBlendedMesh to devide the whole model into sub-model to render seperatelly. I implemented the same function by myself, not very difficult. If you don't want to use .x format mesh, try to implement the function by yourself. April 30 谈论 What's the matter with Tibet? – by i.elephantWritten by my friend bill. 引用 What's the matter with Tibet? – by i.elephant March 03 梅花,新天下贰
灵峰、孤山和西溪自古以来就是杭州赏梅的三大胜地。说起来,最为所人知的便是孤山,那个“梅妻鹤子”的林逋和那句“疏影横斜水清浅,暗香浮动月黄昏”虽时隔千年,尤让人心向往之。中国文人向来对梅花青睐有加,说到底是孤芳自赏的心里在作怪,“零落成泥碾做尘,只有香如故”,大概就是文人仕途失意,处江湖之远后的自我安慰。所以文士们赏梅,讲究的是意境:或是在清冷的冬晨,朔风凛冽,天地肃杀;或是在幽冷的晴夜,月色朦朦,文士们踩着厚厚的积雪在小道上踽踽独行,忽一抬头,正看见一朵怒放的梅花在枝头怒放,那便是有意境了。我们老百姓看梅花就没那么多讲究,踏雪寻梅固然别有乐趣,但与其顶风冒雪,还不如等到明媚的春日,去梅园看一看满树盛开的各色梅花:在花丛中拍几张照片,拈过花来嗅一嗅阵阵幽香,即便是和他人摩肩接踵,也是件开心的事。上周末就是这样的天气,所以一大早便去了植物园,一路径直来到灵峰,在梅花的海洋里徜徉了一番。 公司的3D大型网游天下贰再次内测了,从老天下贰回炉到今天重新内测,只有10个月时间,游戏内容,美术风格,收费模式,全都改了,且不说改得是否成功,效率的确够高。老天下贰我玩得不多,只到10多级,印象最深的就是从新手村出来,一不小心掉到山下小河里,游了半天才找到上岸的地方,灰头土脸跑回去,结果没过多久,再次掉到河里......。新天下贰里选了魍魉,也玩到10多级了,渐入佳境。就画面来说,比以前精致了不少,个人还是很喜欢;任务系统做得也不错,新手的上手难度明显降低。从程序上来说,bigworld引擎经过一年多的优化,无论是效率还是表现力,应该都有提高。之前在悉尼的时候到bigworld总部去访问过,其间谈到了地表渲染部分的优化,差不多就是progressive mesh的概念,看起来也很好的运用到新的游戏场景中了。 February 05 今天出来的两则道歉申明
陈冠希就艳照门道歉: http://ent.163.com/special/00032I5C/ps_stars.html 这说明: 真的假不了 陕西林业厅就老虎门道歉: http://news.163.com/08/0205/00/43T82GN00001124J.html 这说明:假的也真不了 February 03 断桥,白堤,楼外楼,西泠印社,雪后Microsoft’s Letter to Yahoohttp://dealbook.blogs.nytimes.com/2008/02/01/microsofts-letter-to-yahoo/ really a big news. Microsoft leaks this letter purposely in order to give pressure to Yahoo. From the perspective of shareholders and employees of Yahoo, it's really hard to refuse the offer. If the acquisition transaction is successful, I just wonder how to combine to 2 bands: Yahoo and Live.
|
|||||||||||||
|
|