Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
depth_ndc_to_view_z
for cpu-side (bevyengine#14590)
# Objective I want to get the visual depth (after view proj matrix stuff) of the object beneath my cursor. Even when having a write-back of the depth texture, you would still need to convert the NDC depth to a logical value. ## Solution This is done on shader-side by [this function](https://github.com/bevyengine/bevy/blob/e6261b0f5f1124ffa67b8fe9a2d24a2047795192/crates/bevy_pbr/src/render/view_transformations.wgsl#L151), which I ported over to the cpu-side. I also added `world_to_viewport_with_depth` to get a `Vec3` instead of `Vec2`. --- If anyone knows a smarter solution to get the visual depth instead of going `screen -> viewport ray -> screen`, please let me know :>
- Loading branch information