Tuesday, September 8, 2009

Ogre::BoneHandleMap (笑)

看了半天依然想不透這為什麼是一個 map...

typedef std::vector BoneHandleMap;
void Skeleton::_buildMapBoneByHandle
(const Skeleton* src,
BoneHandleMap& boneHandleMap) const
{
ushort numSrcBones = src->getNumBones();
boneHandleMap.resize(numSrcBones);


for (ushort handle = 0; handle < numSrcBones; ++handle)
{
// 這裡是重點... -_- handle = [0..numSrcBones-1]
boneHandleMap[handle] = handle;
}
}

Monday, August 24, 2009

Photon Mapping 閱讀小記

以下是閱讀 Realistic Image Synthesis Using Photon Mapping (Ch5) 記下的一些重點:

  • Power of photons:
    The power ("wattage") of the light source is divided among all the emitted photons, and each photon therefore transports a fraction of the light source power. It is important to note that the power of the photon is proportional only to the number of emitted photons and NOT to the number of photons stored in the model.

  • Emitted photons from a diffuse point light source:

    emit_photon_from_diffuse_point_light() {
    n = 0;
    while(not enough photons) {
    do {
    x = rand_0_1() * 2.0 - 1.0;
    y = rand_0_1() * 2.0 - 1.0;
    z = rand_0_1() * 2.0 - 1.0;
    } while(x*x + y*y + z*z >1);
    d = vector3(x, y, z);
    p = light source position;
    trace photon from p in direction d
    n = n + 1;
    }
    scale power of stored photons with 1 / n
    }


  • Specular Reflection
    If a photon hits a mirror surface:
    1. A new photon is reflected in w = 2 * dot(n,w') * n - w'. Where n is the surface normal, and w' is the incoming direction.
    2. The power of the reflected photon = The power of incoming photon * surface reflectivity.

  • Diffuse Reflection
    If a photon hits a diffuse surface:
    1. It is stored in the photon map.
    2. A new photon is reflected in a random direction in the hemisphere above the intersection point.
    3. The power of the reflected photon = The power of incoming photon * diffuse reflectance.

Friday, August 14, 2009

Test Facebook Share

這是 Facebook 分享的測試,請按以下連結在 Facebook 分享此 URL:





Share on Facebook

:-)

Wednesday, August 5, 2009

SSAO with Importance Sampling

看完了 ShaderX7 中的 Efficient Post-Processing with Importance Sampling,終於有時間把它加入到 SSAO中了。

以下是使用了16個樣本的 SSAO 效果:




效能上兩者沒有分別 (因為樣本是offline產成的),但結果則大家有目共堵。

其中的樣本是使用了這個 python 源碼產成的。

Sunday, August 2, 2009

Simple Real Time Global Illumination: Ambient Cube

最近重看了一遍Shading In Valves Source Engine,對其中的 Ambient Cube很有興趣,因此在構思了一段時間後,花了幾天終於把基本的原理實作了。

video

片段中有一個場景,以及兩個移動的Chamfer Box:
場景是以Light Map照光的,而兩個Chamfer Box則是以Ambient Cube照光。我們可以清楚看見當兩個Chamfer Box移動時,它們會受到場景的 indirect-lighting所影響。

由於我沒有時間像Valve一樣去編寫自己的Radiosity Processor,因此Ambient Cube的資料是在3dsMax中以Vertex Color烘焙再以Maxscript導去,因此受到限制而未能支援HDR Light T_T。

希望遲些會有時間把Demo改善到支援較大的場景,以及再寫更多有關Ambient Cube的講解吧。

註:Ambient Cube只需要支援Shader Model 1.0的顯示卡便可以使用 (Valve真的很強!!)。

Saturday, July 4, 2009

.NET中 Contorl.Invoke() 及 BeginInvoke() 小記

由於最近開始研究 responsive UI 的問題,在網路上終於找到了一篇與 Control.Invoke() / BeginInvoke() 以及 Thread 的文章

文章中舉了四個例子,第一及第二個例子解釋了一般人對 Control.Invoke() / BeginInvoke() 的誤解 (我也是其中一人。 :-P )
而第三及第四個例子側是 Control.Invoke() / BeginInvoke() 與 Thread 結合後的範例。

Saturday, May 23, 2009

Tangent Space Normal Mapping 小記

以下是一些網路上有關Tangent Space Normal Mapping 的文章: