开发者

OpenGL perspective and lighting problem

开发者 https://www.devze.com 2023-03-19 00:33 出处:网络
I have a sample 3d scene rendered using OpenGL ES 1.1. Here is what I get when I have identity projection matrix (I\'m also using normal and specular maps):

I have a sample 3d scene rendered using OpenGL ES 1.1. Here is what I get when I have identity projection matrix (I'm also using normal and specular maps):

OpenGL perspective and lighting problem

So everything looks OK.

But if I set perspective using glFrustum I get this:

OpenGL perspective and lighting problem

So it seems that normals are being inverted and if I try to multiply them by -1 I get this:

OpenGL perspective and lighting problem

It has an effect like the light was from the opposite side.

I should also mention that when using identity proj开发者_JAVA百科ection matrix I have to set

glCullFace(GL_FRONT);

(I think this is because normalized device coords are left handed).

I'll be happy to hear any suggestions about how to fix this issue.

Edit. here is the projection setup:

float right = 0.03;
float top = 0.045;
float near = 0.1;
float far = 100.0;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustumf(-right, right, -top, top, near, far);


Your second screenshot looks okay, I don't see where your problem is. please highlight in the second picture, what you think doesn't look right.

Remember that in the projection matrix there should only be the projection, and kind of camera placement at all. The "camera placement" belongs into the modelview.

0

精彩评论

暂无评论...
验证码 换一张
取 消