Unexpected result with Perspective3

Hello Everyone,

necessary disclaimer, I’m rather a beginner and I’m not sure if my request is here in the correct place, but it would be great if someone has the time to just have a look at my problem.

I programmed a small mini renderer to learn about glium and nalgebra. I had been using my own projection matrix for quite a while now, and wanted to switch to Perspective3 from nalgebra.

But that broke fundamental things in my mini Application. The best way to describe the result is as if I had changed the backculling mode.

The before used projection-matrix

let f = 1.0 / (fovy / 2.0).tan();
[
	[f * aspect_ratio, 0.0, 0.0, 0.0],
	[0.0, f, 0.0, 0.0],
	[0.0, 0.0, (zfar + znear) / (zfar - znear), 1.0],
	[0.0, 0.0, -(2.0 * zfar * znear) / (zfar - znear), 0.0],
]

Which is relatively similar to Perspective3 but not the exact same matrix.

The rendered primitive:

let shape = vec![
	Vertex { position: [-1.0, -1.0, -2.], texture: [0., 0.] },
	Vertex { position: [1.0, -1.0, -2.], texture: [1., 0.] },
	Vertex { position: [-1.0, 1.0, -2.], texture: [0., 1.] },
	Vertex { position: [1.0, 1.0, -2.], texture: [1., 1.] },
	Vertex { position: [-1.0, -1.0, -3.], texture: [0., 0.] },
	Vertex { position: [1.0, -1.0, -3.], texture: [0., 0.] },
	Vertex { position: [-1.0, 1.0, -3.], texture: [0., 0.] },
	Vertex { position: [1.0, 1.0, -3.], texture: [0., 0.] }
];

let indices: [u16; 24] = [
	2, 1, 0,
	1, 2, 3,
	5, 7, 6,
	4, 5, 6,
	1, 3, 7,
	5, 1, 7,
	4, 6, 2,
	0, 4, 2];

My Head tells me everything should be alright, the vertices are clockwise as is the culling-mode, but why is the mesh turned inside out? What should be the expected result?

I can happily add the whole program, but I didn’t want to overwhelm anyone with ~200 lines of code with my first post.

Thanks in advance and for your time,

Kind regard
Christian

So turns out, I’m an idiot… :smiley:

Everything works fine…

Small explanation: I replaced the Projection with an identity matrix and the visual result is the same. I checked the CullingMode and yeah I configured it to cull clockwise, and the indices are clockwise…

So I guess next time I just go to bed…