I have a problem with depth calculating. VS shader:
#version 330 core
layout(location = 0) in vec3 i_Pos;
layout(location = 5) in mat4 i_ModelMat;
uniform mat4 u_LightSpace;
uniform float u_FarPlane;
uniform float u_CutOff;
void main()
{
gl_Position = u_LightSpace * i_ModelMat * vec4(i_Pos, 1.0f);
gl_Position.xy /= tan(u_CutOff) * -gl_Position.z;
gl_Position.z = (-gl_Position.z / u_FarPlane) * 2.0f - 1.0f;
gl_Position.w = 1.0f;
}
where:
u_LightSpace is a view matrix:
glm::lookAt(pos, pos + dir, up), pos = {-2, -2, 2}, dir = {√2/2, √2/2, 0}, up = {-√2/2, √2/2, 0}
u_FarPlane = 10
u_CutOff = π / 12 (15 degrees)
FS shader:
#version 330 core
void main()
{
}
Everything seems to be OK, however the depth buffer looks like:
