Yes, in fact, I have replicated the basic algorithm with the same data in a c# function so I could debug
In engine you would have to press “k” and it will spawn a ray on your mouseposition, going out from the camera.
It’s basically ray tracing - you spawn a ray at the current pixel (you don’t need to trace the ray until the pixel, since we already know that’s where it’s gonna hit) and then we calculate the reflection from said pixel.
If we have the camera-to-pixel vector and the normal vector of the pixel we can simply calculate its reflection.
In the image above you can see this reflection from the side.
Then we step a certain distance and check in our depth map whether our ray is “behind” something. If it is - then yay, we don’t have to trace any further, we can return the pixel we are currently examing. In the picture you can see the violet lines, which mark the distance between where we are with the ray and what depth we measured at this position in screen space.
If not we continue and check the next position.
Of course once we hit something we don’t ahve to continue following our ray, it’s just for debugging purpose in the picture above.