??xml version="1.0" encoding="utf-8" standalone="yes"?>久久AⅤ人妻少妇嫩草影院,久久亚洲精品视频,国产精品久久久久久久久久免费http://www.shnenglu.com/sunicdavy/category/13082.html游戏Q架构,客户端,渲染Q服务器Q界面,开发技巧及l验 email: sunicdavy@sina.comzh-cnThu, 27 May 2010 04:41:06 GMTThu, 27 May 2010 04:41:06 GMT60由Direct3D ZBuffer引v的血?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116404.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Wed, 26 May 2010 09:01:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116404.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/116404.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116404.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/116404.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/116404.html</trackback:ping><description><![CDATA[ <p>今天利昄静态模? 加上U理?发现ZBuffer好像有点不对?/p> <p><a href="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Direct3DZBuffer_EF41/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Direct3DZBuffer_EF41/image_thumb.png" width="601" height="484"></a> </p> <p>于是查D3DRS_ZENABLE,D3DRS_ZWRITEENABLE, l果都是TRUE</p> <p>无奈,只有与我以前正确的DemoҎ210个渲染状? 有部分渲染不同的,使用代码强行纠?l果: 无效</p> <p>怀疑顶Ҏ式破? 重新使用以前的模型格?排除q个可能? l果:p|</p> <p>无奈?查设备选项, H然注意到D3DPRESENT_PARAMETERS l构体中的EnableAutoDepthStencil 讄是FALSE</p> <p>因ؓq次讑֤cL重写?Ҏ以前正确代码, 有差?其改ؓ</p> <p>PresentParameters.EnableAutoDepthStencil    = TRUE;<br>    PresentParameters.AutoDepthStencilFormat    = D3DFMT_D16; </p><p>以前阅SDK?注意q这个选项, q是由D3D帮你理ZBuffer. </p> <p>试, 问题解决.</p> <p> </p> <p>分析: 如果EnableAutoDepthStencil  = FALSE, 意味着qZBuffer都没?那更不要说渲染状? </p> <p><a href="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Direct3DZBuffer_EF41/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Direct3DZBuffer_EF41/image_thumb_1.png" width="290" height="339"></a> 正确l果</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/116404.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-05-26 17:01 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116404.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DirectX 9.0 Direct3D 囑Ş线大图http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116371.html战魂筑战魂筑Wed, 26 May 2010 03:35:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/05/26/116371.htmlhttp://www.shnenglu.com/sunicdavy/comments/116371.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/05/26/116371.html#Feedback1http://www.shnenglu.com/sunicdavy/comments/commentRss/116371.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/116371.htmlDXpipeline-9.0



战魂筑 2010-05-26 11:35 发表评论
]]>
优化Direct3D中多?Multistreaming)的资源分?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116368.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Wed, 26 May 2010 03:19:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116368.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/116368.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116368.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/116368.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/116368.html</trackback:ping><description><![CDATA[<p>转蝲h? <a href="http://www.shnenglu.com/sunicdavy">战魂筑</a></p> <p>本文译整理ȝ?a >http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter05.html</a></p> <p>如果喜欢,误买正?/p> <p>多流技术在渲染时能Ҏ能和结构有一定好?但是怎样模型数据分配到各顶Ҏ据流q行渲染是一个学? </p> <p> </p> <p></p> <p></p><a href="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Direct3DMultistreaming_9F24/05_multistreaming_1_2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="05_multistreaming_1" border="0" alt="05_multistreaming_1" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Direct3DMultistreaming_9F24/05_multistreaming_1_thumb.jpg" width="454" height="678"></a> <p>对于点数据可以分ؓq么几个大类:</p> <p>G: 多边形数? 包含vertex position, normal, and vertex color(s).</p> <p>T: U理映射, 包含多层U理坐标及tangent vectors{?/p> <p>A: 动画数据, 骨骼动画中的骨骼权重及骨骼烦?/p> <p>I: 用于Instancel制的用h?/p> <p> </p> <p>以下是对一些常用渲染的搭?</p> <p>静态模?/p> <p>   可以? <strong>G</strong> <em>or</em> <strong>G</strong> + <strong>T</strong></p> <p>骨骼动画模型</p> <p>   可以?<strong>G</strong> + <strong>A</strong> <em>or</em> <strong>G</strong> + <strong>T</strong> + <strong>A</strong></p> <p>Instancel制的骨骼动L?/p> <p>   可以?<strong>G</strong> + <strong>I</strong> <em>or</em> <strong>G</strong> + <strong>T</strong> + <strong>I</strong> 或者动ȝ型的<strong>G</strong> + <strong>A</strong> + <strong>I</strong> <em>or</em> <strong>G</strong> + <strong>T</strong> + <strong>A</strong> + <strong>I</strong></p> <p>渲染Z-Pass物g</p> <p>  可以?strong>G</strong>, 或者动ȝ型的<strong>G</strong> + <strong>A</strong> <em>or</em> <strong>G</strong> + <strong>I</strong> <em>or</em> <strong>G</strong> + <strong>A</strong> + <strong>I</strong></p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/116368.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-05-26 11:19 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/05/26/116368.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在VC调试器中昄CEGUI 字符?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/05/14/115356.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Fri, 14 May 2010 04:01:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/05/14/115356.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/115356.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/05/14/115356.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/115356.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/115356.html</trackback:ping><description><![CDATA[<p>CEGUI的字W串c设计的初衷是以32个字Wؓ分界? 低于32个字W用固定buffer, 高于才用栈分配内存存储字符? 不过因ؓCEGUI使用utf32,兼容性虽然很?但是在VC调试器里无法昄是个很大的问?</p> <p>q里参考了mybios博客中的<a href="http://www.shnenglu.com/mybios/archive/2009/11/10/28914.html">文章</a>,lCEGUI字符串做一个patch</p> <p>然后需要找到vs2008的autoexp.dat文g</p> <p>XP下位?C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\autoexp.dat</p> <p>用记事本{工h开, 在AutoExpandD中像这h?</p> <p>[AutoExpand]<br>; CEGUI String<br>CEGUI::String = str =<d_quickbuff,su> length =<d_cplength> <p>卛_在VC调试器中看到CEGUI字符串内? 不过中文q是暂时无法支持</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/115356.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-05-14 12:01 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/05/14/115356.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>增强骨骼动画pȝ的几个要?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/05/11/115080.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Tue, 11 May 2010 02:21:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/05/11/115080.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/115080.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/05/11/115080.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/115080.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/115080.html</trackback:ping><description><![CDATA[<p>要在游戏中用到强大而有扩展性的骨骼动画,有很多注意点.</p> <p>首先,我们得弃用CPU蒙皮, 虽然兼容性好,但是面对C多核但ƈ不提高单栔R率的情况下,GPUq是王道.而且GPU蒙皮代码可能更简?不过也有一点小~点, 对于引擎来?Shader必须l静态模型和骨骼动画模型写两?</p> <p>其次我们需要加Z个SubSkin的骨骼支持数? 骨骼动画上的每个SubSkin都是一ơDraw, 但是按照传统骨骼动画pȝ,每个骨头对应一个矩阵传?那么SM2.0保守计算只能支持50栚w? 不过在我前段旉?a href="http://www.shnenglu.com/sunicdavy/archive/2010/04/26/113578.html">文章</a>中有提到q个技?q且已经在我的骨骼动ȝl及OGRE中实?效果很好.</p> <p>术也许很反感一个h物做1个SubSkin, 他们更新好多个SubSkin,也就是说w体每个部分都是一个SubSkin, q样方便修改, 同时pȝ支持的骨骼数量还可以有一定量的上?不过我们q需要做一个烦引工? 传统的GPU骨骼动画中L在渲染SubSkin前传入所有这些SubSkin需要用到的骨骼矩阵. 但是每个SubSkinq不一定能用到所有的q些矩阵,q明显是一U浪? 因此在OGRE中做q一ơ烦引预处理,也就是将每个SubSkin用到的骨骼统计出? 在渲染这ơSubSkin时才重新传到GPU. 很明?q是用速度q空间和兼容? 如果在DX10以上,有ConstantBufferq好. DX9实在太慢?/p> <p>使用Marker点的换装pȝ很难处理例如贴n衣物q类物g换装. OGRE中有一U共享骨骼的技? 可以支持, 不过从代码分析看?q种技术对CPU端骨D量实在是大的惊? 因此我们军_整个SubSkin(也就是SubEntity)换掉,q样q术根据不同换装类型来衣服在MAX中直接绑定好后直接替换原始模型中的SubSkin卛_辑ֈ换装效果.可以说这是从动态计到静态预处理的{?效率提升很多.</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/115080.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-05-11 10:21 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/05/11/115080.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IDirect3DDevice9::DrawIndexedPrimitiveUP 的烦引个数推?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/05/05/114502.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Wed, 05 May 2010 09:07:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/05/05/114502.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/114502.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/05/05/114502.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/114502.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/114502.html</trackback:ping><description><![CDATA[<p>首先参考SDK里这个函数的定义:</p> <p><b>HRESULT </b><b>DrawIndexedPrimitiveUP(</b> </p> <p><b>D3DPRIMITIVETYPE</b> <i>PrimitiveType</i><b>,</b> </p> <p><b>UINT</b> <i>MinVertexIndex</i><b>,</b> </p> <p><b>UINT</b> <i>NumVertices</i><b>,</b> </p> <p><b>UINT</b> <i>PrimitiveCount</i><b>,</b> </p> <p><b>CONST void *</b> <i>pIndexData</i><b>,</b> </p> <p><b>D3DFORMAT</b> <i>IndexDataFormat</i><b>,</b> </p> <p><b>CONST void*</b> <i>pVertexStreamZeroData</i><b>,</b> </p> <p><b>UINT</b> <i>VertexStreamZeroStride</i> </p> <p><b>)</b>;</p> <p> </p> <p>q里假设我们要绘制一个由2个三角Şl成的面,那么参数q样讄</p> <p><i>MinVertexIndex</i> = 0;</p> <p><i>NumVertices</i> = 4;</p> <p><i>PrimitiveCount</i> = 2;</p> <p><i>pIndexData</i> = { 0,1, 2, 0, 2, 3}</p> <p><i>IndexDataFormat</i> = D3DFMT_INDEX16</p> <p><i>pVertexStreamZeroData</i><strong> =</strong> { 4个角的位|?}</p> <p><i>VertexStreamZeroStride</i>  = { l构体的跨度 }</p> <p> </p> <p>我们注意? 没有M一个参数用于描q?b>CONST void *</b> <em>pIndexData</em>的size 大小.</p> <p>但其实你的图元是可以正确l制? 但是你ƈ没有在indexdata后面加上例如字符?的结։,那么D3D是怎么知道IndexCount?</p> <p>我们先看下怎么ҎVertexCount?PrimitveType定 PrimitiveCount </p> <table border="1" cellspacing="0" cellpadding="2" width="448"> <tbody> <tr> <td valign="top" width="200">PrimitveType</td> <td valign="top" width="246">公式</td></tr> <tr> <td valign="top" width="200">D3DPT_POINTLIST</td> <td valign="top" width="246">PrimitiveCount = VertexCount</td></tr> <tr> <td valign="top" width="200">D3DPT_LINELIST</td> <td valign="top" width="246">PrimitiveCount = VertexCount/2</td></tr> <tr> <td valign="top" width="200">D3DPT_LINESTRIP</td> <td valign="top" width="246">PrimitiveCount = VertexCount-1</td></tr> <tr> <td valign="top" width="200">D3DPT_TRIANGLELIST</td> <td valign="top" width="246">PrimitiveCount = VertexCount/3</td></tr> <tr> <td valign="top" width="200">D3DPT_TRIANGLESTRIP</td> <td valign="top" width="246">PrimitiveCount = VertexCount-2</td></tr></tbody></table> <p>? D3DPT_TRIANGLEFAN在以后的驱动中已l不再?因此不再采用</p> <p>当用烦引缓冲时, VertexCount = IndexCount</p> <p>因此在上例中 PrimitiveCount = IndexCount/3</p> <p>也就是说 IndexCount = PrimitiveCount * 3</p> <p>代入PrimitiveCount = 2,因此 IndexCount = 6 </p> <p> </p> <p>因此E_的API的函数参数设计是l不会浪费Q何一个参数的</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/114502.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-05-05 17:07 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/05/05/114502.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[原创]提高Shader Model 2.0 蒙皮骨骼动画的骨骼限?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/04/26/113578.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Mon, 26 Apr 2010 05:31:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/04/26/113578.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/113578.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/04/26/113578.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/113578.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/113578.html</trackback:ping><description><![CDATA[<p>传统的蒙皮骨骼动L؜合方法易于理?但是在SM 2.0?56帔R限制?骨骼C守计最?0栚w?因此对美术的工作程以及模型渲染Ҏ造成了很大的障碍</p> <div id="yqeukws" class="csharpcode"><pre class="alt">float4x4 matBoneArray[40]; <span id="awmqwqi" class="rem">// q是传输的瓶?/span></pre><pre> </pre><pre class="alt">VS_OUTPUT vs_main( SkinnedVS_INPUT In )</pre><pre>{</pre><pre class="alt"> </pre><pre> VS_OUTPUT Out = (VS_OUTPUT)0;</pre><pre class="alt"> </pre><pre> float4x4 skinTransform = 0;</pre><pre class="alt"> </pre><pre> skinTransform += matBoneArray[In.BoneIndices.x] * In.BoneWeights.x;</pre><pre class="alt"> skinTransform += matBoneArray[In.BoneIndices.y] * In.BoneWeights.y;</pre><pre> skinTransform += matBoneArray[In.BoneIndices.z] * In.BoneWeights.z;</pre><pre class="alt"> skinTransform += matBoneArray[In.BoneIndices.w] * In.BoneWeights.w;</pre><pre> float4 localpos = mul(In.Position, skinTransform);</pre><pre class="alt"> </pre><pre> Out.Position = mul( localpos, matViewProj ); </pre><pre class="alt"> Out.TexCoord = In.TexCoord;</pre><pre> </pre><pre class="alt"> <span id="ugmaomc" class="kwrd">return</span> Out;</pre><pre>}</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>matBoneArrayq个数组是骨骼的LocalRot和LocalTranslation 通过以下函数build出来</p> <div id="eaqguka" class="csharpcode"><pre class="alt"> Matrix4& Matrix4::FromTranslationRotation( <span id="eqcoaig" class="kwrd">const</span> Vector3& translation, <span id="yaeoaiq" class="kwrd">const</span> Quaternion& rotation )</pre><pre> {</pre><pre class="alt"> <span id="eosoyyg" class="kwrd">float</span> xx = rotation.x * rotation.x * 2.0f, yy = rotation.y * rotation.y * 2.0f, zz = rotation.z * rotation.z * 2.0f;</pre><pre> <span id="qaeykcc" class="kwrd">float</span> xy = rotation.x * rotation.y * 2.0f, zw = rotation.z * rotation.w * 2.0f, xz = rotation.x * rotation.z * 2.0f;</pre><pre class="alt"> <span id="yceamca" class="kwrd">float</span> yw = rotation.y * rotation.w * 2.0f, yz = rotation.y * rotation.z * 2.0f, xw = rotation.x * rotation.w * 2.0f;</pre><pre> </pre><pre class="alt"> m[0][0] = 1.0f - yy - zz; m[0][1] = xy + zw; m[0][2] = xz - yw; m[0][3] = 0.0f;</pre><pre> m[1][0] = xy - zw; m[1][1] = 1.0f - xx - zz; m[1][2] = yz + xw; m[1][3] = 0.0f;</pre><pre class="alt"> m[2][0] = xz + yw; m[2][1] = yz - xw; m[2][2] = 1.0f - xx - yy; m[2][3] = 0.0f;</pre><pre> m[3][0] = translation.x; m[3][1] = translation.y; m[3][2] = translation.z; m[3][3] = 1.0f;</pre><pre class="alt"> </pre><pre> <span id="gamqkss" class="kwrd">return</span> *<span id="cwquwow" class="kwrd">this</span>;</pre><pre class="alt"> }</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p></p> <p>从这里你可以发现, 本来每根骨头只需?个float4 传递变换信息的,现在却需?个float4,也就是一个矩阉|传?矩阵中还有很多不使用的变量也被传输到GPU?q里是优化的点.</p> <p>重新调整后的Shader代码:</p> <div id="uwacogm" class="csharpcode"><pre class="alt">float4x4 BuildFromTransRot( float4 translation, float4 rot )</pre><pre>{</pre><pre class="alt"> float4 rotation = rot;</pre><pre> </pre><pre class="alt"> <span id="qakyasy" class="kwrd">float</span> xx = rotation.x * rotation.x * 2.0f, yy = rotation.y * rotation.y * 2.0f, zz = rotation.z * rotation.z * 2.0f;</pre><pre> <span id="ugaoyyo" class="kwrd">float</span> xy = rotation.x * rotation.y * 2.0f, zw = rotation.z * rotation.w * 2.0f, xz = rotation.x * rotation.z * 2.0f;</pre><pre class="alt"> <span id="ewammsk" class="kwrd">float</span> yw = rotation.y * rotation.w * 2.0f, yz = rotation.y * rotation.z * 2.0f, xw = rotation.x * rotation.w * 2.0f;</pre><pre> float4x4 m = { </pre><pre class="alt"> {1.0f - yy - zz, xy + zw, xz - yw, 0},</pre><pre> {xy - zw, 1.0f - xx - zz, yz + xw, 0},</pre><pre class="alt"> {xz + yw, yz - xw, 1.0f - xx - yy, 0},</pre><pre> {translation.x, translation.y, translation.z, 1}</pre><pre class="alt"> </pre><pre> };</pre><pre class="alt"> </pre><pre> <span id="mgkoaka" class="kwrd">return</span> m;</pre><pre class="alt">}</pre><pre> </pre><pre class="alt">float4x4 GetBoneElement( <span id="wgseqyi" class="kwrd">float</span> index )</pre><pre>{</pre><pre class="alt"> <span id="ysoqumu" class="kwrd">return</span> BuildFromTransRot( vecBoneLocalTrans[index], vecBoneLocalRot[index] );</pre><pre>}</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p></p> <div id="ikykumk" class="csharpcode"><pre class="alt">VS_OUTPUT vs_main( SkinnedVS_INPUT In )</pre><pre>{</pre><pre class="alt"> </pre><pre> VS_OUTPUT Out = (VS_OUTPUT)0;</pre><pre class="alt"> </pre><pre> float4x4 skinTransform = 0;</pre><pre class="alt"> </pre><pre> skinTransform += GetBoneElement(In.BoneIndices.x) * In.BoneWeights.x;</pre><pre class="alt"> skinTransform += GetBoneElement(In.BoneIndices.y) * In.BoneWeights.y;</pre><pre> skinTransform += GetBoneElement(In.BoneIndices.z) * In.BoneWeights.z;</pre><pre class="alt"> skinTransform += GetBoneElement(In.BoneIndices.w) * In.BoneWeights.w;</pre><pre> float4 localpos = mul(In.Position, skinTransform);</pre><pre class="alt"> </pre><pre> Out.Position = mul( localpos, matViewProj ); </pre><pre class="alt"> Out.TexCoord = In.TexCoord;</pre><pre> </pre><pre class="alt"> <span id="wguwiaq" class="kwrd">return</span> Out;</pre><pre>}</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>我们骨头的local旋{及偏UM递至GPU,然后在GPU内重l?虽然对GPU性能计算有部分损?但是骨骼数量p保守提高?00?</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/113578.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-04-26 13:31 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/04/26/113578.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>多线E渲染的一些资?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/04/15/112676.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Thu, 15 Apr 2010 08:06:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/04/15/112676.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/112676.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/04/15/112676.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/112676.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/112676.html</trackback:ping><description><![CDATA[<p>OGRE 中的3U层ơ实现多U程渲染的文?</p> <p><a >http://isdlibrary.intel-dispatch.com/vc/1632/Threading_OGRE3D.pdf</a></p> <p> </p> <p>ATI有关多线E效率提升的游戏比较及一些tips</p> <p><a >http://developer.amd.com/assets/ATIMThread.pdf</a></p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/112676.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-04-15 16:06 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/04/15/112676.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>游戏工程里的使用C++静态库与动态库http://www.shnenglu.com/sunicdavy/archive/2010/04/07/111859.html战魂筑战魂筑Wed, 07 Apr 2010 08:08:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/04/07/111859.htmlhttp://www.shnenglu.com/sunicdavy/comments/111859.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/04/07/111859.html#Feedback2http://www.shnenglu.com/sunicdavy/comments/commentRss/111859.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/111859.html假设我们?个工E及其工E类型:

CORE              DLL

ENGINE           DLL

GAME             EXE

D3DRENDER      DLL

其中D3DRENDER是GAME动态蝲入的Q其需要链接CORE,ENGINE

q是一个很常见的模式,但是不好的是Q因为CORE和ENGINE均是DLLQ代码中的Symbol都被导出才可使用。Q何h使用DEPENDENCE工具可以将DLL中引用的东西查看的清楚,虽然q不至于造成技术泄漏,但从速度和DLL大小来说都是不划的?/p>

现在很多游戏主exe一般都?0M+甚至20M+的大exeQ这都是使用静态链接而成。但是对代码l构也必dZ定的调整。所有工E必都是静态库Q这h能保证像COREq样的静态库中的全局/静态变量不至于被链?份而造成内存D逻辑错误?/p>

当然Q用全静态库q需要注意一点:所有的lib都是在最后的game工程里来做链接?/p>

战魂筑 2010-04-07 16:08 发表评论
]]>
[转]虚引擎UDK开发官方视频教E?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/04/07/111833.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Wed, 07 Apr 2010 02:36:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/04/07/111833.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/111833.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/04/07/111833.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/111833.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/111833.html</trackback:ping><description><![CDATA[<p>转蝲?<a >独立游戏中文论坛</a> <p>UDK是unrealengine develpoment kit 的羃写,单来说就是大名鼎鼎的虚Q引擎的免费商业版本Q不q虚q3毕竟q是Q年前的dx9的入门引擎Q在商业上取?br>巨大成功Q技术上也显得落后.目前Epicxq虚q3的最后一Ҏ力,于是q脆发布了这个免费版本.M人都可以用UQO开发游戏,但是如果游戏牟利的话每年q是要向<br>Epic交纳一定数量的技术授权费用的Q先不管q个Q还是来看看它的官方视频教程吧.<br>  [attach]44[/attach]<br>链接如下Q  <br><a >http://udn.epicgames.com/Three/VideoTutorials.html</a><br>一共5个教E 从引擎配|介l开始,到关卡和人物~辑器,以及最后一个完整的游戏的制作Q对于入门来说完全够了Q?br>视频说的q比较详l,听力不好的同学可以对照下开发文 <a >http://www.udk.com/documentation</a> 里面基本说的很详l.<br>最后附上UQO的下载地址Q <a >March 2010 UDK Beta</a> (548 MB .exe) <br>好了QUQO对于初学者来说还是比较适合的.对于游戏的开发h员来说引擎的整体架构q是很值得学习的.希望你学的愉快.</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/111833.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-04-07 10:36 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/04/07/111833.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>模拟OGRE的Compositorhttp://www.shnenglu.com/sunicdavy/archive/2010/04/01/111312.html战魂筑战魂筑Thu, 01 Apr 2010 10:56:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/04/01/111312.htmlhttp://www.shnenglu.com/sunicdavy/comments/111312.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/04/01/111312.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/111312.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/111312.htmlRenderTarget完成后,开始模拟OGRE的Compositor?/p>

OGRE的Compositor其实是用于解决l制PostEffect的,单的_是一URenderTarget的流E控制脚?/p>

q是OGRE compositor文g的片D?/p>

compositor Bloom
{
    technique
    {
        // Temporary textures
        texture rt_output target_width target_height PF_R8G8B8
        texture rt0 target_width_scaled 0.25 target_height_scaled 0.25 PF_R8G8B8
        texture rt1 target_width_scaled 0.25 target_height_scaled 0.25 PF_R8G8B8
 
        target rt_output
        {
            // Render output from previous compositor (or original scene)
            input previous
        }
 
        target rt0
        {
            // Start with clear texture
            input none
            // Horizontal blur pass
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BrightPass2
                input 0 rt_output
            }
        }
 
        target rt1
        {
            // Start with clear texture
            input none
            // Horizontal blur pass
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BlurV
                input 0 rt0
            }
        }
 
        target rt0
        {
            // Start with clear texture
            input none
            // Horizontal blur pass
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BlurH
                input 0 rt1
            }
        }
 
        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositor/BloomBlend2
                input 0 rt_output
                input 1 rt0
            }
        }
    }
}

 

大概我们知道Q一个Compositor分ؓ资源定义与绘制步骤(target xxxQ?/p>

而一个绘制步骤又分别定义Q?/p>

1. Q输入)l制的是什么东西?

2. Q效果)l制成什么样子?

3. Q输出)往哪里l制Q?/p>

输出方式在这个例子有2U:U理QRTQ和屏幕

输入方式?中:U理及场?/p>

我们可以使用一个回调来对一个绘制步骤提供绘制输?/p>

l制效果是一大堆的ShaderQ这些shader都是Z一个quad来做的,也就是一个矩形,使用变换后的点和一个纹理坐标作为顶点定?/p>

不过q里是不需要做vertexshader的,仅仅ps矣?/p>

l制的最后,是将前面l制的RTQ纹理)混合h

当然Q如果步骤比较多和复杂时QRT之间跟寄存器一P可以反复使用

YR7HEX8VAB[67GPOWLNPIBA

昄茶壶法线的场景加?Blur 的PostEffect

<?xml version="1.0" encoding="gb2312" ?>
<Compositor name = "bloom" >
  <Resource>
    <RenderTarget name ="rt_source" size="screenquad" />
    <RenderTarget name ="rt0" size="screenquad" />
    <RenderTarget name ="rt1" size="screenquad" />
  </Resource>
  <Step target="rt_source">
    <Geometry type ="callback" callback = "rt_input"/>
  </Step>
  <Step target="rt0">
    <Geometry type = "screenquad"/>
    <Effect name ="material\blurH.xml">
      <Texture name ="mTexture" value ="rt_source" />
    </Effect>
  </Step>
  <Step target="rt1">
    <Geometry type = "screenquad"/>
    <Effect name ="material\blurV.xml">
      <Texture name ="mTexture" value ="rt_source" />
    </Effect>
  </Step>
  <Step>
    <Geometry type = "screenquad"/>
    <Effect name ="material\combine.xml">
      <Texture name ="mTexture1" value ="rt0" />
      <Texture name ="mTexture2" value ="rt1" />
    </Effect>
  </Step>
</Compositor>
q是我的引擎里的Compositor脚本Q还在慢慢加强功能,希望能有一天达到OGRE的Compositor功能

战魂筑 2010-04-01 18:56 发表评论
]]>
3D引擎设计Q支持多RenderTarget及多Viewporthttp://www.shnenglu.com/sunicdavy/archive/2010/03/29/110895.html战魂筑战魂筑Mon, 29 Mar 2010 10:16:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/03/29/110895.htmlhttp://www.shnenglu.com/sunicdavy/comments/110895.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/03/29/110895.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/110895.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/110895.html如果让你的引擎结构支持多个RenderTargetl制及多个ViewportQ这里是我的单设计:

同样适用我的文本设计图标?+为包?  <为派?

 

RenderTexture

      RenderTarget

          <ScreenTarget(引擎启动Ӟ初始化屏q大的Viewport)

          +RenderView (对于一个RTQ可以是屏幕Q可以是U理RTQ所以可以拥?1~n个切分视?)

               +Camera

               +Viewport

 

以下是多Viewl制的类XNA伪代?/p>

 

Engine.Run()
{
    Device.Clear()
 
    // 保存当前全屏Viewport
    ScreenViewport = Device.CurrentViewport
 
    Device.BeginScene()    
 
    // 遍历当前屏幕RT下的所有View
    foreach RenderView in ScreenRT
    {
        // 未激zȝView不用l制
        if RenderView not active then continue
 
        // View对应的Viewport提交到设?       
        RenderView.CommitViewport()
 
        // 渲染回调
        foreach RenderEventListener in RenderEventListenerList
        {
            RenderEventListener.OnRenderFrame()
        }
    }
 
    Device.EndScene()
 
     Device.Present()
 
    Device.CurrentViewport = ScreenViewport // 恢复全屏viewport
}

 

 

以下是RT间嵌套绘制的伪代码:

RenderView.SwitchRenderTarget(stage, RenderTarget)
{
    // 保存l制前的RT
    PreTarget = Device.GetRenderTarget()
    // 讄为当前的RT
    Device.SetRenderTarget( RenderTarget )
 
    // 更新RT摄像?/span>
    RenderTarget.UpdateCamera()    
    
    // 清空RT
    Device.Clear()
 
    // l制回调
    RenderTarget.OnRender( )
 
    // 恢复之前的RT
    Device.SetRenderTarget( PreTarget  );
}


战魂筑 2010-03-29 18:16 发表评论
]]>
讨论Qshader与矩阵{|?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/03/17/109879.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Wed, 17 Mar 2010 03:08:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/03/17/109879.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/109879.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/03/17/109879.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/109879.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/109879.html</trackback:ping><description><![CDATA[<p>完成自己的shaderpȝ后,d之前写过的代码中发现有一个地方很奇?/p> <p>我的矩阵定义跟OGRE的没什么区?/p> <div id="aqcoigg" class="csharpcode"><pre class="alt"> union </pre><pre> {</pre><pre class="alt"> <span id="yimqaay" class="kwrd">struct</span></pre><pre> {</pre><pre class="alt"> <span id="yquiukk" class="kwrd">float</span> m11, m12, m13, m14;</pre><pre> <span id="qugcoum" class="kwrd">float</span> m21, m22, m23, m24;</pre><pre class="alt"> <span id="gauwkqg" class="kwrd">float</span> m31, m32, m33, m34;</pre><pre> <span id="qauqkka" class="kwrd">float</span> m41, m42, m43, m44;</pre><pre class="alt"> };</pre><pre> <span id="sciswem" class="kwrd">float</span> m[4][4];</pre><pre class="alt"> };</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>   乘法也跟OGRE的一模一P但在view及project乘好的矩阵送给HLSLӞ却必{|下Q才能得到正的l果</p> <div id="qikwayg" class="csharpcode"><pre class="alt">mSkinnedEffect.mMatrix.mValue = (camera.mViewMatrix * camera.mProjectMatrix).Transpose();</pre></div> <p>shader:</p> <div id="uwquggo" class="csharpcode"><pre class="alt">float4 localpos = mul(In.Position, skinTransform);</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p> </p> <p>    OGRE中有q么一D代码及注释:</p> <div id="eqmwiqq" class="csharpcode"><pre class="alt"> <span id="wiwiuus" class="kwrd">const</span> Matrix4& AutoParamDataSource::getProjectionMatrix(<span id="seicoew" class="kwrd">void</span>) <span id="keyuooe" class="kwrd">const</span></pre><pre> {</pre><pre class="alt"> <span id="swgceow" class="kwrd">if</span> (mProjMatrixDirty)</pre><pre> {</pre><pre class="alt"> <span id="uuycomm" class="rem">// NB use API-independent projection matrix since GPU programs</span></pre><pre> <span id="amyiems" class="rem">// bypass the API-specific handedness and use right-handed coords</span></pre><pre class="alt"> <span id="gkeakus" class="kwrd">if</span> (mCurrentRenderable && mCurrentRenderable->getUseIdentityProjection())</pre><pre> {</pre><pre class="alt"> <span id="yosoaqg" class="rem">// Use identity projection matrix, still need to take RS depth into account.</span></pre><pre> RenderSystem* rs = Root::getSingleton().getRenderSystem();</pre><pre class="alt"> rs->_convertProjectionMatrix(Matrix4::IDENTITY, mProjectionMatrix, <span id="kuqkgme" class="kwrd">true</span>);</pre><pre> }</pre><pre class="alt"> <span id="augkeek" class="kwrd">else</span></pre><pre> {</pre><pre class="alt"> mProjectionMatrix = mCurrentCamera->getProjectionMatrixWithRSDepth();</pre><pre> }</pre><pre class="alt"> <span id="mguyssa" class="kwrd">if</span> (mCurrentRenderTarget && mCurrentRenderTarget->requiresTextureFlipping())</pre><pre> {</pre><pre class="alt"> <span id="ismymua" class="rem">// Because we're not using setProjectionMatrix, this needs to be done here</span></pre><pre> <span id="egseqoe" class="rem">// Invert transformed y</span></pre><pre class="alt"> mProjectionMatrix[1][0] = -mProjectionMatrix[1][0];</pre><pre> mProjectionMatrix[1][1] = -mProjectionMatrix[1][1];</pre><pre class="alt"> mProjectionMatrix[1][2] = -mProjectionMatrix[1][2];</pre><pre> mProjectionMatrix[1][3] = -mProjectionMatrix[1][3];</pre><pre class="alt"> }</pre><pre> mProjMatrixDirty = <span id="ewkeigw" class="kwrd">false</span>;</pre><pre class="alt"> }</pre><pre> <span id="ykwycsi" class="kwrd">return</span> mProjectionMatrix;</pre><pre class="alt"> }</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>貌似是跟左右手这个恶心的东西有关p?/p> <p>回看DirectXSDK中提供的BasicHLSL例子</p> <div id="ieguewm" class="csharpcode"><pre class="alt"> mWorld = g_mCenterWorld * *g_Camera.GetWorldMatrix();</pre><pre> mProj = *g_Camera.GetProjMatrix();</pre><pre class="alt"> mView = *g_Camera.GetViewMatrix();</pre><pre> </pre><pre class="alt"> mWorldViewProjection = mWorld * mView * mProj;</pre><pre> </pre><pre class="alt"> V( g_pEffect->SetMatrix( <span id="iaoqcca" class="str">"g_mWorldViewProjection"</span>, &mWorldViewProjection ) );</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p></p> <p>shaderQ?/p><pre class="csharpcode">Output.Position = mul(vAnimatedPos, g_mWorldViewProjection);</pre> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>丝毫无需转置矩阵,Effect接口中也提供有SetMatrixTransposeq类Ҏ。所以排除内部有自动转置的嫌疑?/p> <p>询问q野猪这个问题,野猪{曰:"转置后传输至需要传3个vector, 最后一个是[0 0 0 1]?</p> <p>有达人知道的Q可以指点下qh| :)</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/109879.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-03-17 11:08 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/03/17/109879.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一套可扩充的游戏模型系l?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/03/12/109538.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Fri, 12 Mar 2010 08:13:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/03/12/109538.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/109538.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/03/12/109538.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/109538.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/109538.html</trackback:ping><description><![CDATA[<p>本h的设计图可以方便在文本编辑器里查?>为派?+为包? <p>MAX插g导出的模型资源分QMesh/Skin, Skeleton, Animation <p>不同动作按照不同的动L件保?<p>  <p>ResourceHandle 包含基本id<br>        >NamedResourceHandle 带有名称资源Q包含hashA, hashBQ?使用暴雪hash函数生成<br>        >ModelHandle        <br>        >MeshHandle            <br>        >SkeletonHandle        <br>        >AnimationHandle <p>获取资源Q如果资源不存在Ӟ自动加蝲<br>ModelMaster.ManualCache( &ModelHandle ) <p>直接资源讉KQ?br>RawSkeleton = ModelMaster.ManualCache( &SkeletonHandle("a.skl") )<br>RawSkeleton->GetMarker(...) <p>异步资源加蝲Q异步id保存于ModelHandle中,在callback中根据id认<br>ModelMaster.AsyncCache( &ModelHandle ) <p>获取资源指针Q未加蝲Ӟq回I?br>ModelResource = ModelMaster.Fetch( &ModelHandle ) <p>模型资源加蝲?br>    在模型句柄中l定对应加蝲?br>    可以自行~写带换装的ModelLoaderQ通过d自己的配|文Ӟ自行加蝲资源后生成RawModel<br>ModelLoader<br>    ModelHandle         ---mapping--->    ModelLoader         ---generate--> RawModel<br>    MeshHandle          ---mapping--->    MeshLoader             ---generate--> RawMesh<br>    SkeletonHandle     ---mapping--->    SkeletonLoader      ---generate--> RawSkeleton<br>    AnimationHandle    ---mapping--->    AnimationLoader   ---generate--> RawAnimation <p>引用计数c?nbsp;   <br>ModelResource<br>    >RawModel<br>    >RawMesh<br>    >RawSkeleton<br>    >RawAnimation <p>RawModel中不保留HandleQ只保留指针<br>RawModel<br>    +MeshVB    从模型文件中直接d点格式Q包?静?GPU,CPUcd点<br>        +RawMesh<br>        +MeshIB        一ơ性填充IB<br>        >GPUMeshVB    一ơ性填充VB<br>        >CPUMeshVB    每计算<br>    +Animation            q行期数据(旉/帧)<br>        +RawAnimation    原始动画内容<br>    +Skeleton<br>        +RawSkeleton</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/109538.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-03-12 16:13 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/03/12/109538.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Direct3D9 Fx/HLSL的若q条有用的笔?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/03/05/108962.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Fri, 05 Mar 2010 06:26:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/03/05/108962.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/108962.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/03/05/108962.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/108962.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/108962.html</trackback:ping><description><![CDATA[<p>Direct3D中的Shader是这LQ?/p> <p>1. ASM Shader是最元老的也是DX8主要使用Shader</p> <p>2. fxc~译器可以同时编译ASM,HLSL和fx脚本,其中HLSL和fx可以查看~译后的GPU汇编代码</p> <p>3. D3D9中,fx是HLSL的一U渲染脚本,化了HLSL讄及常量绑定,q且附带RenderStateBlock及设|?/p> <p>但只能用于制作简单的Shader</p> <p>4. DirectXSDK中有一个概忉|؜淆:C++例子中的BasicHLSL使用的其实还是fxQHLSLwithoutEffects例子才是真正的纯HLSL</p> <p>5.fx与HLSLE序鉴别Q?/p> <p>使用fxE序必定含有QD3DXCreateEffectXXX pd函数Q?ID3DXEffect对象Q渲染中能看到SetTechniqueQBeginPassQEndPass之类的字?/p> <p>使用UHLSLE序含有QD3DXCompileShaderQID3DXConstantTable对象QGetConstantByNameQGetConstantDesc之类的字?/p> <p>6. 在fx中包含有 VertexShaderQPixelShader代码及profileQentryQRenderState讄及简单的l制q程(pass)。一ơ编译后QVS,PS,Texture,Sampler及常量都是在ID3DXEffect对象中自动完成,无需手动讄?/p> <p>7. HLSL可以VS及PS代码写入1?hlsl文g。注意,以下q种代码可以在HLSL中编译过Q但实际没有M效果</p> <div id="icoqcua" class="csharpcode"><pre class="alt"><span id="ykmsmuk" class="lnum"> 1: </span>sampler_state</pre><pre><span id="skeacsy" class="lnum"> 2: </span>{</pre><pre class="alt"><span id="aquycua" class="lnum"> 3: </span> Texture = <tex>;</pre><pre><span id="gyuesqq" class="lnum"> 4: </span> MipFilter = LINEAR;</pre><pre class="alt"><span id="cieycka" class="lnum"> 5: </span> MinFilter = LINEAR;</pre><pre><span id="mocmaiy" class="lnum"> 6: </span> MagFilter = LINEAR;</pre><pre class="alt"><span id="ooseygo" class="lnum"> 7: </span>};</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>q点可以参考AMD RenderMonkey中只在shader中用sampler而忽略texture?/p> <p>8. fx中往shader讄U理使用的是ID3DXBaseEffect::SetTexture下的q个函数</p> <div id="umgkeee" class="csharpcode"><pre class="alt"><span id="ygcgsiy" class="lnum"> 1: </span>HRESULT SetTexture(</pre><pre><span id="ckeqmuu" class="lnum"> 2: </span> D3DXHANDLE hParameter,</pre><pre class="alt"><span id="ckyamms" class="lnum"> 3: </span> LPDIRECT3DBASETEXTURE9 pTexture</pre><pre><span id="ooieige" class="lnum"> 4: </span>);</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p> 但是在HLSL中,q点变得很ȝQ需要手动设|,可以参考这?a href="http://www.shnenglu.com/liangairan/articles/57971.html">文章</a></p> <p>Shader代码片段Q?/p> <div id="umqcwow" class="csharpcode"><pre class="alt"><span id="emiuoom" class="lnum"> 1: </span>sampler Samp0 = sampler_state</pre><pre><span id="yiuyaia" class="lnum"> 2: </span>{</pre><pre class="alt"><span id="owauqou" class="lnum"> 3: </span> Texture = <Tex0>;</pre><pre><span id="agkyisi" class="lnum"> 4: </span> MipFilter = LINEAR;</pre><pre class="alt"><span id="kauqcka" class="lnum"> 5: </span> MinFilter = LINEAR;</pre><pre><span id="iieycss" class="lnum"> 6: </span> MagFilter = LINEAR;</pre><pre class="alt"><span id="ooymwoe" class="lnum"> 7: </span>};</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>~译HLSL代码后得到ConstantTableQ然后取出句柄:</p> <div id="csmymus" class="csharpcode"><pre class="alt"><span id="csoaesk" class="lnum"> 1: </span>ScalarHandle = pixelConstTable->GetConstantByName(0, <span id="qoiwgyg" class="str">"Scalar"</span>);</pre><pre><span id="mcwacck" class="lnum"> 2: </span> </pre><pre class="alt"><span id="aqcgqqg" class="lnum"> 3: </span>Samp0Handle = pixelConstTable->GetConstantByName(0, <span id="gosokig" class="str">"Samp0"</span>);</pre><pre><span id="yycoiqg" class="lnum"> 4: </span> </pre><pre class="alt"><span id="mwqkgme" class="lnum"> 5: </span>Samp1Handle = pixelConstTable->GetConstantByName(0, <span id="uaoqsks" class="str">"Samp1"</span>);</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>再从句柄取出symbol的描qͼ</p> <div id="ucwaemk" class="csharpcode"><pre class="alt"><span id="ggiwgyo" class="lnum"> 1: </span>UINT count;</pre><pre><span id="kawquuu" class="lnum"> 2: </span> </pre><pre class="alt"><span id="kicoaqy" class="lnum"> 3: </span>pixelConstTable->GetConstantDesc(Samp0Handle, & Samp0Desc, &count);</pre><pre><span id="oequoew" class="lnum"> 4: </span> </pre><pre class="alt"><span id="sokomqi" class="lnum"> 5: </span>pixelConstTable->GetConstantDesc(Samp1Handle, & Samp1Desc, &count);</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>通过上面的描qͼ纹理变量的寄存器偏UM为纹理的stage</p> <p>8.  优化帔R讄速度的方法一般就是根据字W串取出句柄Q以后每ơ渲染时Q只通过句柄讄。但ID3DXConstantTable最后还是通过</p> <p>IDirect3DDevice9::SetPixelShaderConstantX pd函数来实现的</p> <div id="ykgkowu" class="csharpcode"><pre class="alt"><span id="oyw2282" class="lnum"> 1: </span>HRESULT SetPixelShaderConstantF(</pre><pre><span id="macq2a4" class="lnum"> 2: </span> UINT StartRegister,</pre><pre class="alt"><span id="cuaqayq" class="lnum"> 3: </span> CONST <span id="csiiyeu" class="kwrd">float</span> * pConstantData,</pre><pre><span id="2qksaa2" class="lnum"> 4: </span> UINT Vector4fCount</pre><pre class="alt"><span id="kcsg2i0" class="lnum"> 5: </span>);</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>9. HLSL一D包含VS和PS代码~译完成后,得到VS和PS两个单独的ID3DXConstantTable</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/108962.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-03-05 14:26 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/03/05/108962.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>枚D反射对象和结构体反射填充http://www.shnenglu.com/sunicdavy/archive/2010/02/26/108509.html战魂筑战魂筑Fri, 26 Feb 2010 09:58:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/02/26/108509.htmlhttp://www.shnenglu.com/sunicdavy/comments/108509.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/02/26/108509.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/108509.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/108509.html 

最q在写D3D9模拟D3D10接口的渲染系l中到大量的渲染状态对象,不仅成员多,枚D也多的要命?/p>

 

    struct CORE_API RasterizerState : ResourceHandle            
    {
        eFillMode            mFillMode;        
        eCullMode            mCullMode;
        bool                mFrontFaceCCW;
        float                mDepthBias;
        float                mSlopeScaledDepthBias;
        bool                mDepthClipEnable;
        bool                mScissorEnable;
        bool                mMultisampleEnable;

        RasterizerState();
    };

而要从配|文件中d数据q填充到q个l构体,对于C++来说完全是吃力不讨好的Q写出来的代码也是极E,修改和扩展极为麻烦的?/p>

因此军_使用反射的方法来填充数据Q先ȝ一下我的C++反射pȝ

class RTTIObject // 动态类型识别对象基c,对象通过一些宏后可以很方便的通过字符串创建出cd例,q且可以查询注册时的cd和其他绑定信?/span>
class NameRef  // 名字表,cM于虚qM的FNameQ可以定义Const和普通NameQ比较和拯只是一个dword耗费的时?/span>
value_parseQvalue_tostringQvalue_typename // 一pdcd模板函数Q提供对cd的ToStringQParse及类型名查询

 

首先需要处理的是枚举查询,q里枚N过宏做成一个个枚D对象Qƈ可以通过名字创徏实例

#define DECLARE_ENUMOBJECT( TEnum ) \
    struct EnumObject_##TEnum : EnumObject\
    {\
    DECLARE_RTTIOBJECT( EnumObject_##TEnum );\
    EnumObject_##TEnum( );\
    };


#define IMPLEMENT_ENUMOBJECT_BEGIN( TEnum, TEnum_prefixoffset, TMember_prefixoffset ) \
    IMPLEMENT_RTTIOBJECT_STRING( EnumObject_##TEnum, #TEnum + TEnum_prefixoffset, #TEnum + TEnum_prefixoffset, "EnumObject" )\
    EnumObject_##TEnum::EnumObject_##TEnum(){ const int member_prefixoffset = TMember_prefixoffset;

#define ENUMOBJECT_ADD( enumkey ) AddMember( #enumkey + member_prefixoffset, (dword)enumkey );

#define IMPLEMENT_ENUMOBJECT_END }

#define ENUMOBJECT_STATICINIT( TEnum ) EnumObject_##TEnum::StaticInit();

EnumObject 中通过宏将枚D的名U和g存在q个对象?/p>

IMPLEMENT_ENUMOBJECT_BEGIN( eFillMode, 1, 3 )  // q里?Q?是将eFillMode及FM_Point转成字符串后L前缀
    ENUMOBJECT_ADD( FM_Point )
    ENUMOBJECT_ADD( FM_Line )
    ENUMOBJECT_ADD( FM_Fill )
IMPLEMENT_ENUMOBJECT_END

// 注册到RTTIObjectpȝ

ENUMOBJECT_STATICINIT( eFillMode )

 

// 通过枚D对象可以查找到字W串对应的?/span>
dword v;
EnumObject::GetEnumValue( "FillMode", "Point", v )



下一步是结构体成员信息记录

    void SettingObject::BindMember( const NameRef& objname, void* instancePtr, void* dataPtr, SettingProxy* proxy )
    {
        proxy->mOffset = dword(dataPtr) - dword(instancePtr);

        MemberList& memberlist = mSettingMap[ objname ];
        memberlist[ proxy->mName ] = proxy;
    }

q里记录的是l构体成员的内存偏移

使用大量的宏Q可以让l构体绑定变得漂?/p>

#define BIND_SETTINGOBJECT_BEGIN( TClass ) \
    { const NameRef& soname = TClass::StaticGetClassInfo()->mClassName;TClass soobj;

#define BIND_SO_MEMBER( TMemberType, TMember ) \
    so.BindMember( soname, &soobj, &soobj.TMember, new TSettingElement<TMemberType>(#TMember + 1 ) );

#define BIND_SO_MEMBER_NAME( TMemberType, TMember, TName ) \
    so.BindMember( soname, &soobj, &soobj.TMember, new TSettingElement<TMemberType>(TName) );

#define BIND_SO_ENUM( TEnumType, TMember ) \
    so.BindMember( soname, &soobj, &soobj.TMember, new TSettingEnum(#TMember + 1, #TEnumType + 1) );

#define BIND_SO_ENUM_NAME( TEnumType, TMember, TName ) \
    so.BindMember( soname, &soobj, &soobj.TMember, new TSettingEnum(TName, #TEnumType + 1) );

#define BIND_SETTINGOBJECT_END }

l定代码如下

        BIND_SETTINGOBJECT_BEGIN( RasterizerState )
            BIND_SO_ENUM    ( eFillMode    , mFillMode )
            BIND_SO_ENUM    ( eCullMode    , mCullMode )
            BIND_SO_MEMBER    ( bool        , mFrontFaceCCW )
            BIND_SO_MEMBER    ( float        , mDepthBias )
            BIND_SO_MEMBER    ( float        , mSlopeScaledDepthBias)
            BIND_SO_MEMBER    ( bool        , mDepthClipEnable)
            BIND_SO_MEMBER    ( bool        , mScissorEnable)
            BIND_SO_MEMBER    ( bool        , mMultisampleEnable)
        BIND_SETTINGOBJECT_END

 

所有结构体的信息被记录在SettingObject中,d配置文g填充l构体的d变得异常的单了

    SettingObject settings;
// 所有的l构体信息记?/span>
    InitRenderStateObjectSetting( settings );

    const NameRef& rzname = DepthStencilState::StaticGetClassInfo()->mClassName;

    DepthStencilState a;
 // q里是配|文件的信息填充到结构体
    settings.SetMember( rzname, &a, "BackFace.StencilFunc", "Equal" );
 


战魂筑 2010-02-26 17:58 发表评论
]]>
设计D3D9 HLSL渲染脚本http://www.shnenglu.com/sunicdavy/archive/2010/02/15/107911.html战魂筑战魂筑Mon, 15 Feb 2010 15:18:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/02/15/107911.htmlhttp://www.shnenglu.com/sunicdavy/comments/107911.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/02/15/107911.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/107911.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/107911.html最q翻出很早之前自己写的一套用Direct3D 9  Effectpȝ的纯shader 3d引擎Q打用最新技术重写。重写的主要修改在于Q?/p>

1. LEffectpȝQ改用HLSL + 渲染脚本

2. 优化渲染接口Q用材质统一shader和渲染状?/p>

随即参考了DirectX SDK的Graphics部分文QDirectX9 时代的EffectpȝUa只是一个HLSL的简单渲染脚本实玎ͼ除了DXUTQFXComposer{极程序用这套东西外Q大型的引擎很少使用q种半成品系l。到了DirectX10甚至11Q因为架构更改,L固定线Q因此Effect成ؓ较ؓ高效和便L渲染脚本Q如果不是要求较高的3d引擎Q一般的游戏使用DirectX10的Effect渲染脚本q是很不错的?/p>

DX10的fx脚本与DX9的差异在?/p>

渲染状态,采样器状态等都变为对象,q与API高度l一

在脚本与API中均可以讄

DepthStencilState EnableDepth
{
    DepthEnable = TRUE;
    DepthWriteMask = ALL;
    DepthFunc = LESS_EQUAL;
};

BlendState NoBlending
{
    AlphaToCoverageEnable = FALSE;
    BlendEnable[0] = FALSE;
};

technique10 Render
{
    pass P0
    {

        SetDepthStencilState( EnableDepth, 0 );
        SetBlendState( NoBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }
}

本h觉得Q这L设计让图形API更ؓ敏捷与归cdQ另外,也便于StateManager或者自己做渲染状态{Ud差异比较时更为高?

 

Vista操作pȝ推出很久后,DX10的显卡也占有了大量的市场份额。但是由于DX10仍然是一个过渡APIQ类gDX8)Q因此,很多3D游戏要么仍然支持DX9Q要不然x持DX9也支持DX10Q甚至DX11.

   看博客上有达人组团编写类似DX10接口和系l的软渲染,DX10的设计是优秀的。因此,在DX9 HLSL基础上,l合自己~写的渲染脚本会是非常好的选择?

    渲染脚本我的设计思\是这LQ?

1. 只是一U预处理脚本Qƈ非实时运行脚本?

~译器将文本解析后,转化Z些运行指令,比如Q本pass使用一块小U理Q下一pass的target是这个纹理,q且开启哪些渲染状态?

2. 自定义格式的解析脚本?

使用luaQpython{脚本其实也是可以的。但是在出现错误Ӟ报出的错可能会让不熟悉这个脚本语a的h莫名其妙?

使用Nsq脚本语言Q可惜其在lua基础上,对table的slot初次赋值时必须使用<-而不是统一使用=Q因此会让你的脚本稀奇古?

XML脚本Q?XML可以避免复杂的语法检查,写完是归整的,但也是罗嗦的Q本来Texture[2]可以表达完毕的,非要<Texture index = 2/>来罗嗦下?

OGRE的compositor脚本和材质脚本就是自p析的Q不q出乎预料的使用了BNF范式q类较ؓ正规的方法。这是_需要先解析BNF表达式,然后再输入脚本解析,~写q程和系l复杂度会变得异常复杂?

最l选择q是使用自己解析的脚本,使用一些具体代码结构来替代BNFq类高深的东?

军_以后Q下一步需要制定渲染脚本具体各部分及制作过E?

1. 基本lexer

   从文本得到各Utoken

1. 渲染状态对?

   照着DX10抄就?

2. Shader导入?

     shader文g来自于何处,入口怎样定义

3. 渲染脚本VM及指?

  军_一个纹理怎样讄QRenderTarget怎样使用{的指o

战魂筑 2010-02-15 23:18 发表评论
]]>
ھƷۺϾþþ40p| һƷþð͹| 2020˾þþƷ| Ʒþþþþ벻| ѾƷþ| ŷղþ99 | Ʒtvþþþþþ| һþþƷ| ϵרþ| ۺϾþùһ鶹| þþþþþ99Ʒѹۿ| þۺϾƷһ| ƯޱгĻþ| þþþAVƬ| þþƷWWW456C0M| þպƷһ| þ99һ| 97þùۺϾƷŮ| Բľþþþþ| þþ97ɫ| þþþƷþþþþ| ݺɫþþۺϲ| ɫʹþۺ| 99þ99þþƷƬ| ޾ƷҹVAþó | ޹˾Ʒ91þþ | þþþAV| ˾þô߽avӰԺ| һһþþƷۺ| ŷ޾ƷþþavӰ| ŷԴսþþþþ| þԭۺ| þþþþþĻ | ޾ƷҾþþþþ| þþþۺĻ | ձŷƷһҳþ| ƷþþþӰӲ| þþƷAVũ帾Ů| þù¶ƷӰ| þ˾Ʒһ| þҹҹ³³ƬӰ |