Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of Near and Far Z-Axis Camera Planes #21

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions addons/ShaderFunction-Extras/Utility/utility.gdshaderinc
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,19 @@ vec3 vertex_billboard(vec2 uv, mat4 view_mat, vec3 vertex, float scale) {
uv *= scale;
return vert + ((vec4(uv, 0.0, 0.0) * view_mat)).xyz;
}

float camera_z_near_plane_vulkan(mat4 proj_mat) {
return abs(proj_mat[3][2] / proj_mat[2][2]);
}

float camera_z_near_plane_gles(mat4 proj_mat) {
return proj_mat[3][2] / (proj_mat[2][2] - 1.0);
}

float camera_z_far_plane_vulkan(mat4 proj_mat) {
return abs((proj_mat[3][2] * camera_z_near_plane(mat4 proj_mat)) / (proj_mat[3][2] + camera_z_near_plane(mat4 proj_mat)));
}

float camera_z_far_plane_gles(mat4 proj_mat) {
return proj_mat[3][2] / (proj_mat[2][2] + 1.0);
}