在 vertex shader 動手腳的 projection:
不知道為什麼下圖有點走樣,不過似乎可以靠vertex shader 讓 z 值變成線性的,這樣的話應該可以避掉z fighting,效能差多少就不清楚了。
DXGI_FORMAT_R8G8B8A8_UNORM :
如果問題是A,答案是Z,可能存在最佳解法M,我的思路常常變成ABCZ或是ADEMZ,B或D是前幾個在腦袋裡浮現的解法,是「邏輯上」可行的做法,然後不斷的往前延伸,直到一連串邏輯上可行的解法達到Z,因為M比其他的路隱晦許多,所以雖然沒找到最佳解,但通常可以很快地找到可用解。壞處是只要問題夠複雜,這個方法就容易走進死胡同。即使是寫程式,整個流程也是這般流泄而出,通常能很快的寫出可行的程式,再花時間最佳化。就算一開始就找到M,也沒人能保證A到Z之間有更好的解法,也許把紙對折,A和Z就自然碰上了。
三年級的數學作業有這麼一題,一段圓弧跟圓弧外的點A,畫一條直線連接A跟圓弧的圓心。問題很簡單,在弧上畫兩段不重疊的弓,它們的中垂線會在圓心相交。不過當時我可不是這們寫的,因為題目的位子畫得太好了,所以只要以A為圓心,畫個弧能夠跟本來的弧線有兩個交點,那可以少做很多事……所以從國中開始,我就有當程式員的徵兆了嗎?
Long long ago, when I playing with Jaina, I don`t know why my Jaina can`t act as smooth as Blizzard`s. But there is a rumor about how to make Jaina move more like a really young girl. SSE is the first solution.
I don`t find any document about cost of SSE (ohh...I`m lzay, you know that...). But in my experience, there is a simple rule. The most general usage of SSE is matrix multiplication. And there are many many multiplication in bone skin animation. But you`ll find it cost more CPU power if you only write SSE to do "one" vector multiple "one" matrix.
The simple rule is :
if the number of vector multiplication is more than double of vector IO, SSE will gain higher performance.
For example, the dot value of 2 vectors need 3 IO (2 vectors in, one value out), but there is only 1 vector multiplication. Another example is vector multiple matrix, 6 IO (5 in, 1 out) with 4 vector mul ...... so we still can`t get better performance.
But in the bone animation case, there are less bones with many many point. That means many points will mul the same matrix in each frame. If you have to mul N points, you need :
Ignore the 1`st one, it just meet my simple rule. So there is a chance make my Jaina act more smooth. (Just write a function to mul many vectors to one matrix).
BTW, there are many 0 in normal 3d matrix......that`s another story.
最近玩戰鎚,不過大概快玩不下去了,bug很多,而且G1S跑起來也不順,3G的RAM加上8600GT還不能順暢的運作,這個game一定有些問題,雖然設定上還有些意思,但我從第一天開始就覺得:無論美術程式,都無法與Blizzard 打對台。今天累了,提一個奇怪的rendering bug就好,其他有空再說。
圖不是很清楚,左上角紅框裡還有個「方框」,喔不!這是個誤會,實際上那是盞燈,週遭則是充滿煙霧(風沙?)的場景,會跑出個這麼突兀的方框是 z check 跟 z write 的問題,燈看起來是張textue (texture animation?maybe)的billboard,屬於半透明物件,整片煙霧也是半透明物件,這兩個東西都會等到整個場景畫得差不多後才會畫上去,為得是半透明的渲染未經排序的話結果會是錯的。我猜問題是這樣發生的:燈影跟煙霧畫的順序不一定,有時燈先畫,有時煙霧先,所以這個問題不是一直存在。接著,畫燈影的時候 z write 是開著的,畫霧的時候 z check 是開著的,結果燈先畫的話,因為 z write(z 值還可能是錯的),導致畫煙霧時 z check 後沒辦法畫那一塊,最後就生出一個方框了。
ZZzzZzZzzzz...快睡著了......
Thanks for the debugging function of baseclass of dshow, I got some ugly assert and try to fix it.
BTW, the same isuue would happen in cocoa of Mac, too. If 2 objects are the owner of each other (retain each other), they should be disconnected before release the final reference outside of the scope.