CSharpGL.glm.infinitePerspective C# (CSharp) Method

infinitePerspective() public static method

Creates a matrix for a symmetric perspective-view frustum with far plane at infinite.
public static infinitePerspective ( float fovy, float aspect, float zNear ) : CSharpGL.mat4
fovy float The fovy.
aspect float The aspect.
zNear float The z near.
return CSharpGL.mat4
        public static mat4 infinitePerspective(float fovy, float aspect, float zNear)
        {
            float range = tan(fovy / (2f)) * zNear;

            float left = -range * aspect;
            float right = range * aspect;
            float bottom = -range;
            float top = range;

            var result = new mat4(0);
            result[0, 0] = ((2f) * zNear) / (right - left);
            result[1, 1] = ((2f) * zNear) / (top - bottom);
            result[2, 2] = -(1f);
            result[2, 3] = -(1f);
            result[3, 2] = -(2f) * zNear;
            return result;
        }