- Home /
How to transform a viewport point to homogenous coordniate?
Hi guys,
Unity can use Camera.ViewportToWorldPoint to transform point to homogenous coodinate.
But, if I don't want to use this function how to do this by matrix?
Thanks a lot.
Camera.ViewportToWorldPoint doesn't return the homogenous coordinates. It returns usual cartesian world coordinates of the point (x, y, z), where (x, y) are normalized coordinates (both components are in [0,1] range) on the camera plane and z in the distance between the camera and that plane along camera's forward direction.
So what matrix do you need?
moonstruck, thank you for reply. Actually, I need the inverse of view-projection matrix. But, I can get this... Unity can get projection matrix(but, this matrix is opengl conversion)
http://docs.unity3d.com/Documentation/ScriptReference/Camera.html
So it may work you: ( camera.projection$$anonymous$$atrix * camera.cameraToWorld$$anonymous$$atrix ).inverse
(projection coordinates into the camera view space).
But, document say "that camera space matches OpenGL convention". If I run on directx version, is it still work correctlly?
Yeah, because it is the convention for this particular matrix (i.e. the orientation along z axis). It shouldn't depend on the library you are using.
Your answer
![](https://koobas.hobune.stream/wayback/20220613105030im_/https://answers.unity.com/themes/thub/images/avi.jpg)