depth bounds

i have a (maybe not so advanced) problem with glDepthBoundsExt.

when using glDepthBoundsExt i have to pass values between [0,1]. in my implementation i calculate the intersection point of a frustum plane with a straight line (defined by the light source and a vertex from the object).

how can i transform those z-values to the range [0,1]?


Transform object’s point (your intersection)
Po = (Xo,Yo,Zo,1) by camera transform matrix (view * projection) to get point’s clip coordinate Pc = (Xc, Yc, Zc, W).

The point’s normalized device coordinate are then
Xd = Xc / W ; //[-1,1]
Yd = Yc / W ; //[-1,1]
Zd = Zc / W ; //[-1,1]

Since Z in range [0,1] :
wanted Z = Zd * 0.5 + 0.5; // put it within required range

thanks for your answer!