1

次のサイトでは、法線行列を計算するときに model_view 行列を使用するように指示されています (組み込みの gl_NormalMatrix を使用していないと仮定します): (site) Light House . 私のプログラムには次のアルゴリズムがあります。

//Calculate Normal matrix

// 1. Multiply the model matrix by the view matrix and then grab the upper left
// corner 3 x 3 matrix.
mat3x3 mv_orientation = glext::orientation_matrix<float, glext::column>(
  glext::model_view<float, glext::column>(glext_model_, glext_view_));

// 2. Because openGL matrices use homogeneous coordinate an affine inversion
// should work???
mv_orientation.affine_invert();

// 3. The normal matrix is defined as the transpose of the inverse of the upper
// left 3 X 3 matrix
mv_orientation.transpose();

// 4. Place this into the shader
basic_shader_.set_uniform_3d_matrix("normal_matrix", mv_orientation.to_gl_matrix());

上記のほとんどのステートメントが前述のコードで正しいと仮定します。正規行列の計算に射影行列を含めませんか? そうでない場合、射影行列は法線に影響を与えませんか?

4

2 に答える 2

3

これは、射影がアフィン変換ではないためです。射影は内積を維持せず、角度も維持しません。そして、光の拡散と反射に影響を与える実際の角度は、アフィン 3 次元空間での角度です。したがって、射影行列も使用すると、さまざまな角度、間違った角度、したがって間違ったライトが得られます。

于 2013-09-22T14:19:54.787 に答える