opengl反向z
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
glDepthFunc(GL_GREATER);
glClearDepth(0.0);
m_proj = glm::perspective(glm::radians(fov), getAspect(), fnear, ffar);
改为
m_proj = glm::perspectiveZO(glm::radians(fov), getAspect(), ffar, fnear);
无限远平面
glm::mat4 MakeInfReversedZProjRH(float fovY_radians, float aspectWbyH, float zNear) {
float f = 1.0f / tan(fovY_radians / 2.0f);
return glm::mat4(
f / aspectWbyH, 0.0f, 0.0f, 0.0f,
0.0f, f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, -1.0f,
0.0f, 0.0f, zNear, 0.0f);
}