Skip to content

Commit

Permalink
Merge pull request #94153 from clayjohn/SSAO-linearize
Browse files Browse the repository at this point in the history
Properly linearize depth buffer for SSAO when using orthogonal camera
  • Loading branch information
akien-mga committed Jul 10, 2024
2 parents fbac9c5 + e0f736e commit 198e55e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ layout(r16f, set = 2, binding = 3) uniform restrict writeonly image2DArray dest_
vec4 screen_space_to_view_space_depth(vec4 p_depth) {
if (params.orthogonal) {
vec4 depth = p_depth * 2.0 - 1.0;
return ((depth + (params.z_far + params.z_near) / (params.z_far - params.z_near)) * (params.z_far - params.z_near)) / 2.0;
return -(depth * (params.z_far - params.z_near) - (params.z_far + params.z_near)) / 2.0;
}

float depth_linearize_mul = params.z_near;
Expand All @@ -68,7 +68,7 @@ vec4 screen_space_to_view_space_depth(vec4 p_depth) {
float screen_space_to_view_space_depth(float p_depth) {
if (params.orthogonal) {
float depth = p_depth * 2.0 - 1.0;
return ((depth + (params.z_far + params.z_near) / (params.z_far - params.z_near)) * (params.z_far - params.z_near)) / (2.0 * params.z_far);
return -(depth * (params.z_far - params.z_near) - (params.z_far + params.z_near)) / 2.0;
}

float depth_linearize_mul = params.z_near;
Expand Down

0 comments on commit 198e55e

Please sign in to comment.