How To Get Vertical Camera FOV
I couldn’t find how to get the vertical camera FOV value directly so I wrote this.
This shader provieds an example of how to get the vertical FOV value of the camera in either radians or degrees from the PROJECTION_MATRIX.
Also, to prove that it works, you can apply this shader to any object and it wil be white if the ‘compare_FOV’ fits the camera FOV and it will be black otherwise. I chose 70° as default as that is the default FOV in the editor.
Shader code
shader_type spatial;
uniform float compare_FOV = 70;
void fragment() {
float FOV_in_radians = atan(-1.0 / PROJECTION_MATRIX[1][1]) * 2.0;
float FOV_in_degrees = degrees(FOV_in_radians);
if(FOV_in_degrees > compare_FOV - 0.1 && FOV_in_degrees < compare_FOV + 0.1)
{
ALBEDO = vec3(1.0,1.0,1.0);
}
else
{
ALBEDO = vec3(0.0,0.0,0.0);
}
}