Unprojecting mouse position

Hi,

I'm trying to project the mouse position from screen space into world space, and I've come across two questions:

1. When the graphics api does the divide by the homogenous coordinate (z value), is it the z-value in camera space or ndc space?

2. Is the perspective matrix (one that was made using FOV) normalized & orthogonal? I.e. Does the transpose equal the inverse, or do I have to do a proper inverse to move NDC coordinates to camera space? (I assume have to do the inverse because the columns equal more than one)

Edited by Oliver Marsh on
1. it's the w value in clipspace, which is cameraspace transformed with the projection matrix.

2. no the perspective matrix is not an affine matrix at all. The last row is not the 0,0,0,1 but instead 0,0,1,0. This is what allows z to become w and effectively divide by z.

The most basic perspective-like matrix looks something like:

1
2
3
4
1,0,0,0
0,1,0,0
0,0,0,1
0,0,1,0


however this only does a very specific projection so a few scale and translate operations are added before and after the perspective transform.
Thanks, I forgot about clip space. I was combining clip space and NDC space into the same thing.
Hmm... Wrong section perhaps? :P