Top > エフェクト-ガウスフィルタ
*エフェクト-ガウスフィルタ [#w0f74216] ・ガウス関数による係数で複数のピクセルを参照、平滑化しスクリーンをぼかす。 ---- #contents ** 描画パス [#de049b8d] 1.ガウス分布の計算 2.横方向、縦方向、それぞれ一回ずつぼかしならがレンダリングする。 横軸フィルタ ↓ &ref(effect-gauss-h.JPG,,40%); ↓ 縦軸フィルタ ↓ &ref(effect-gauss.JPG,,40%); ↓ ガウスフィルタ結果 ** ガウス分布の計算 [#c166d0fd] const int Dispersion = 5.0; // ガウス散乱率 const int Sampling = 8; // 後述のサンプリング数 const int Sampling = 8; // サンプリング数 const float dispersion = Dispersion * Dispersion; const int sample = Sampling / 2; assert((sample > 0) && (sample <= 8)); // 重さ結果格納 float weight_list[sample] = {0}; // 重み計算 float total = 0.0f; for (int i = 0 ; i < sample ; ++i) { float weight = expf(-0.5f * (i*i)/dispersion); total += 2.0f * weight; weight_list[i] = weight; } for (int i = 0 ; i < sample ; ++i) weight_list[i] /= total; ** ぼかしフィルタ [#md59ed82] 横軸ぼかし:&ref(gauss-h.fx); 縦軸ぼかし:&ref(gauss-v.fx); ・VertexShaderの計算は、0.5pixelずらすと自動的に補間してくれるらしいのでそれを期待したコードになっています。 |