- Home /
Maintain screenspace scale/position as camera field of view changes?
I have a 3D model rendering in a perspective camera whose field of view changes from time to time.
When I change the cameras field of view the 3D model obviously also changes the position in screenspace it's rendering as well as its size.
Is it possible to calculate an offset scale/position as the cameras field of view changes to keep the 3D model in roughlyu the same spot and size in screenspace?
Answer by Sisso · Apr 11, 2013 at 02:31 PM
Yes...
Camera field of view is basically a Frustum, but I think that you will need alot of math to do this.
Answer by Bunny83 · Apr 11, 2013 at 03:02 PM
Uhm, i guess all you actually want to use is a second camera, but it's hard to say without knowing your exact purpose. The exact same position and scale isn't possible since changing the FOV will always change the perspective distortion.
If you just want to display an object at a fix position on the screen:
put that object on a seperate layer.
Exclude this layer from your normal camera's culling mask
Create a second camera which just renders the layer that contains your object by setting the culling mask accordingly
Make sure your second camera, which renders your object, has a greater "depth value" than your normal camera.
Also you should set your second camera's clearFlags to Depth or Nothing
Now your object will always look the same even when you change the main camera.
Your answer
Follow this Question
Related Questions
How to keep an object within the camera view? 2 Answers
Distribute terrain in zones 3 Answers
Drag And Drop with Perspective Camera 1 Answer