Sylvain Rochette

07-13-2013, 08:25 PM

Hello all,

I try to use the sample from Eric Lengyel without success,

I think my problem is related to the clip plane, since my plane is from world coordinate, it say it need to be in camera eye coord,

Do I need transform my plane (world space) before using it?

The perspective matrix is build using glm::perspective, my matrix are basically glm::mat4...

matrix4 oblique = projection;

vector4 plane(normal, distance);

vector4 q;

q.x = (sign(plane.x) + projection[0][2]) / projection[0][0];

q.y = (sign(plane.y) + projection[1][2]) / projection[1][1];

q.z = -1.0f;

q.w = (1.0f + projection[2][2]) / projection[2][3];

vector4 c = plane * (2.0f / glm::dot(plane, q));

oblique[0][2] = c.x;

oblique[1][2] = c.y;

oblique[2][2] = c.z + 1.0f;

oblique[3][2] = c.w;

Here the shot using the projection without the oblique. The second shot show the issue I try to resolve with oblique near clip plane.

If I am using this code, I am jumping out of the map, I just see the sky :)

I try to use the sample from Eric Lengyel without success,

I think my problem is related to the clip plane, since my plane is from world coordinate, it say it need to be in camera eye coord,

Do I need transform my plane (world space) before using it?

The perspective matrix is build using glm::perspective, my matrix are basically glm::mat4...

matrix4 oblique = projection;

vector4 plane(normal, distance);

vector4 q;

q.x = (sign(plane.x) + projection[0][2]) / projection[0][0];

q.y = (sign(plane.y) + projection[1][2]) / projection[1][1];

q.z = -1.0f;

q.w = (1.0f + projection[2][2]) / projection[2][3];

vector4 c = plane * (2.0f / glm::dot(plane, q));

oblique[0][2] = c.x;

oblique[1][2] = c.y;

oblique[2][2] = c.z + 1.0f;

oblique[3][2] = c.w;

Here the shot using the projection without the oblique. The second shot show the issue I try to resolve with oblique near clip plane.

If I am using this code, I am jumping out of the map, I just see the sky :)