Thanks for looking into it jcl!
I don't understand why -9999 is wrong though.
If the camera's pan/tilt/roll values are all zero (= camera looking in X axis direction) and i give vec_for_screen a point which should be 10000 quants in front of the camera, how can the resulting point not be 10000/9999 quants aways but rather be something crude like 8202 ? It makes even less sense the longer i think about it
Plus the position reconstruction in the shader gives wrong results (the shader should be correct as i'm using it in another engine, too). Also, for the reconstruction i always need the most far away points of the view frustum (basically the far frustum edges). So if camera.clip_far = 10000 i should get points which are 10000(or 9999) quants away from the camera. Instead i get 8202.
I'll try to create a workaround and directly fetch the far frustum corners instead of using vec_for_screen and compare that to what vec_for_screen outputs. Directly fetching/calculating the far frustum points should be faster anyway