Maik Xhani
Maik Xhani

Reputation: 65

OpenGl: Get distance information using z-buffer

I'd like to know how to get distance information from z-buffer (or depth buffer) in this way: based on my viewpoint I'd like to extract the distance as a 3x3 distance matrix of the objects in front of the viewplane. Is it possible?

Also is it possible to get the same information from another cop even if I am rendering in a completely different cop?

Upvotes: 0

Views: 543

Answers (1)

Bartek Banachewicz
Bartek Banachewicz

Reputation: 39370

You can't get information from the depth buffer other way that it is stored in it - as a depth value for each destination buffer (screen) pixel. If you'd like to calculate the distance to other objects from a given point, you could extract the data and reload it into another shader (or just to CPU-available array in memory), calculating the lenghts.

Upvotes: 2

Related Questions