From 9abe85d64f5716e4e14f51abd491fe460f48800f Mon Sep 17 00:00:00 2001 From: onnowhere <17817284+onnowhere@users.noreply.github.com> Date: Mon, 5 Apr 2021 21:44:24 -0700 Subject: [PATCH] Add FOV function --- .shader_utils/vsh_util.glsl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.shader_utils/vsh_util.glsl b/.shader_utils/vsh_util.glsl index b043550..d4c7d9a 100644 --- a/.shader_utils/vsh_util.glsl +++ b/.shader_utils/vsh_util.glsl @@ -6,6 +6,14 @@ #define LIGHT0_DIRECTION vec3(0.2, 1.0, -0.7) // Default light 0 direction everywhere except in inventory #define LIGHT1_DIRECTION vec3(-0.2, 1.0, 0.7) // Default light 1 direction everywhere except in nether and inventory +/* + * Returns the FOV in degrees + * Calculates using the fact that top/near = tan(theta / 2) + */ +float getFOV(mat4 ProjMat) { + return atan(1.0, ProjMat[1][1]) * 114.591559; +} + /* * Returns if rendering in a GUI * In the GUI, near is 1000 and far is 3000, so -(far+near)/(far-near) = -2.0