winterhell's picture

[Solved]How do you unproject with OpenTK?

I googled this but the answers did not help. It used to work with SlimDX and XNA but not here.

 Matrix4 inverted = OpenTK.Matrix4.CreatePerspectiveFieldOfView(0.785, 1, 0.1f, 640).Inverted();
 Vector4 vec = new Vector4(-1, 0, 1, 1);
 vec = Vector4.Transform(vec, inverted);

Why is the unprojected X coordinate -0.41 instead of -1?
How do I get a point that lies on the front plane? If that works correctly I'll be able to take it from there.

Edit: It turned out the unproject Z depth has to be conformable to the field of view.