- Home /
how to know the relationship between zoom ratio and field of view
I want to make a sinper game.I made zoom effect by adjust the field of view.And I know the default fov is 60 degree,and maximum is 179,minimum is 1.
I want to make 2x,4x,6x,8x,10x ... zoom effect,but I don't know how to adjust the field of view to correspond with the zoom radio.
For example the distance between camera and cube is 1000 meters ,and the cube size is (1,1,1),how to know the fov value when I zoom 2x scope ratio?and 4x? If the distance change to 600 ,how about the fov value,is it the same with 1000 meters?
Please help me,thanks.My english is poor,I don't know whether I make the question clear
Answer by Dakwamine · Mar 14, 2014 at 01:43 PM
Having 2x zoom simply divides your normal FOV by 2, 4x zoom => FOV / 4, etc.
It is just simply as that. The zoom values magnifies what you see, so it divides the field of view...
Thank you very much Dakwa$$anonymous$$e.I have made a test to caculate the zoom ratio,and the result is almost the same as you say.
here is the formula I test:
define defSize as object default size on screen(defFov == 60),and objSize as object zoom in size, 1<ZoomFov<60;
ZoomRatio=objSize/defSize;
FovRatio=defFov/ZoomFov;
the function caculate object size on screen reference screen render size
public Rect BoundsToScreenRect(Bounds bounds)
{
// Get mesh origin and farthest extent (this works best with simple convex meshes)
Vector3 origin = Camera.main.WorldToScreenPoint(new Vector3(bounds.$$anonymous$$.x, bounds.max.y, 0f));
Vector3 extent = Camera.main.WorldToScreenPoint(new Vector3(bounds.max.x, bounds.$$anonymous$$.y, 0f));
// Create rect in screen space and return - does not account for camera perspective
return new Rect(origin.x, Screen.height - origin.y, extent.x - origin.x, origin.y - extent.y);
}
Call the function when change zoom ratio:
void Update ()
{
if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.X)){
Zoom ();
}
if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.C)){
defaultObjSize=BoundsToScreenRect(target.renderer.bounds);
}
}
public void Zoom(){
Rect objSize=BoundsToScreenRect(target.renderer.bounds);
print ("target size"+objSize+" fov ratio "+60f/Camera.main.fieldOfView+" width radio: "+objSize.width/defaultObjSize.width+" height radio:"+ objSize.height/defaultObjSize.height);
}
here is the result:
Your answer
Follow this Question
Related Questions
Lining up Fov's 0 Answers
Lens Effect 1 Answer
Mathematical relation between zoom and camera position 1 Answer
Make camera Zoom in or Zoom Out to focus all target objects 0 Answers
Zooming camera using move z position. 0 Answers