Fix occlusion culling by using depth instead of Euclidean distance when selecting the closest point

Co-authored-by: Florent Guiocheau <florent.guiocheau@gmail.com>
This commit is contained in:
Rudolph Bester
2024-10-01 20:04:21 +02:00
committed by Rudolph Bester
parent b5bdb88062
commit 18eb1c1072
2 changed files with 5 additions and 6 deletions

View File

@ -173,7 +173,9 @@ void RaycastOcclusionCull::RaycastHZBuffer::sort_rays(const Vector3 &p_camera_di
}
int k = tile_i * TILE_SIZE + tile_j;
int tile_index = i * tile_grid_size.x + j;
mips[0][y * buffer_size.x + x] = camera_rays[tile_index].ray.tfar[k];
Vector3 ray_dir(camera_rays[tile_index].ray.dir_x[k], camera_rays[tile_index].ray.dir_y[k], camera_rays[tile_index].ray.dir_z[k]);
mips[0][y * buffer_size.x + x] = camera_rays[tile_index].ray.tfar[k] * p_camera_dir.dot(ray_dir); // Store z-depth in view space.
}
}
}