Answers for "Camera position in Viewport coordinates"
http://answers.unity.com/questions/1215981/camera-position-in-viewport-coordinates.html
The latest answers for the question "Camera position in Viewport coordinates"Answer by Glurth
http://answers.unity.com/answers/1216731/view.html
Sir Owen, you got my thinking back on the right track, here is what's going on.
Consider the usual viewing frustum. As show in this world-space image, we have a NEAR PLANE. This near plane distance is in-fact the Z coordinate of the "Screen" in veiwport space. The plane, at this z coordinate, has a rectangular shape, with some non-zero distance between the clipping planes.
![alt text][1]
In this world-space image, we can see what it looks like if we ignore the near-plane: All our clipping planes(top,bottom,left,right) meet at a single point, the camera's position, a.k.a our viewport space z=0. The effectively renders any x,y coordinate at z=0, in view-space, meaningless: **Since there is zero "distance" between the left and right clipping planes at z=0, an x value that represents a fraction of how far between them, is also, always zero.**
![alt text][2]
[1]: /storage/temp/74149-cam-w-near.png
[2]: /storage/temp/74150-cam-nonear.pngFri, 15 Jul 2016 23:25:07 GMTGlurthAnswer by Owen-Reynolds
http://answers.unity.com/answers/1216017/view.html
Looks like a very small glitch in Unity's worldToViewPoint. It doesn't work when you give it the exact world position of the camera. Moving it a tiny amount fixes it:
Transform T=Camera.current.transform;
Vector3 pp=T.position; // exact camera pos. gives incorrect 00
// pp += T.forward*0.01f; // <- fixes it
// pp -= T.forward*0.01; // <- also fixes it
Debug.Log( Camera.current.WorldToViewportPoint(pp) );
With pp as the exact camera coords, you get 000. But moving it a tiny bit forward or backward is fine.
I'm wondering if technically the exact camera pos doesn't have a viewport point -- but I think you're right. It's (0.5, 0.5, 0) by definition.Thu, 14 Jul 2016 17:11:08 GMTOwen-Reynolds