【发布时间】:2010-03-07 12:12:26
【问题描述】:
我正在研究 OpenGL 中的阴影映射。
我看到如下代码:
// This is matrix transform every coordinate x,y,z
// x = x* 0.5 + 0.5
// y = y* 0.5 + 0.5
// z = z* 0.5 + 0.5
// Moving from unit cube [-1,1] to [0,1]
const GLdouble bias[16] = {
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0,
0.5, 0.5, 0.5, 1.0};
// Grab modelview and transformation matrices
glGetDoublev(GL_MODELVIEW_MATRIX, modelView);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glMatrixMode(GL_TEXTURE);
glActiveTextureARB(GL_TEXTURE7);
glLoadIdentity();
glLoadMatrixd(bias);
// concatating all matrice into one.
glMultMatrixd (projection);
glMultMatrixd (modelView);
// Go back to normal matrix mode
glMatrixMode(GL_MODELVIEW);
现在,如果我去掉偏置矩阵。代码不起作用。搜索其他阴影映射代码,我看到相同的偏差矩阵,没有任何解释。为什么我希望这种偏差将 x, y, z 映射到 0.5 * x + 0.5, 0.5 * y + y, ...?
谢谢!
【问题讨论】:
标签: opengl