Skip to content

Commit

Permalink
Add FOV function
Browse files Browse the repository at this point in the history
  • Loading branch information
onnowhere committed Apr 6, 2021
1 parent 8855f2d commit 9abe85d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .shader_utils/vsh_util.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9abe85d

Please sign in to comment.