- Home /
How to set size of near clip plane
I would like to have a larger near clip plane on my camera than is the default to achieve a "more orthographic" look.
I suspect the answer will involve some matrix math, but I'm painfully ignorant about how to approach the problem. Any help would be much appreciated!
I found this code online to calculate the projection matrix, but I don't see anything in this formula about the size / shape of the near clip plane relative to the far clip plane...
var x = (2.0 near) / (right - left); var y = (2.0 near) / (top - bottom); var a = (right + left) / (right - left); var b = (top + bottom) / (top - bottom); var c = -(far + near) / (far - near); var d = -(2.0 far near) / (far - near); var e = -1.0;
var m : Matrix4x4; m[0,0] = x; m[0,1] = 0.0; m[0,2] = a; m[0,3] = 0.0; m[1,0] = 0.0; m[1,1] = y; m[1,2] = b; m[1,3] = 0.0; m[2,0] = 0.0; m[2,1] = 0.0; m[2,2] = c; m[2,3] = d; m[3,0] = 0.0; m[3,1] = 0.0; m[3,2] = e; m[3,3] = 0.0; return m;
Thanks!
The frustum is a pyramid and I would doubt you could shape it differently.
One way to fake an orthographic camera with perspective is to make a really small field of view (about 10/15) and then move the camera far away from the scene.
Answer by TheCheese · Nov 13, 2014 at 08:48 PM
The way I solved this issue was by creating a script that interpolated between an orthographic matrix and a perspective one - based off of this script:
http://forum.unity3d.com/threads/smooth-transition-between-perspective-and-orthographic-modes.32765/
Having a 98% orthographic camera view seems to work well.
Your answer