...from Fragmentarium v1.0.25 Examples/Include/DE-kn2.frag
if(depthFlag) {
// do depth on the first hit not on reflections
depthFlag=false;
// for rendering depth to alpha channel in EXR images
// see http://www.fractalforums.com/index.php?topic=21759.msg87160#msg87160
if(DepthToAlpha==true) gl_FragDepth = 1.0/Ray.Pos;
else
// sets depth for spline path occlusion
// see http://www.fractalforums.com/index.php?topic=16405.0
gl_FragDepth = ((1000.0 / (1000.0 - 0.00001)) +
(1000.0 * 0.00001 / (0.00001 - 1000.0)) /
clamp(Ray.Pos, 0.00001, 1000.0));
}
the scene is calculated with 3D projection outside of the GL as an entirely mathematical representation, the derived color values are stored to a texture, the texture is applied to a quad, the quad is rendered by the GL with an (essentially) ortho projection to our screen view, that is : the flat quad fills the flat screen, after the last part of the rendering process the GL has only the quad object to work with so it will fill the depth buffer with the values of the quad surface, a flat plane that does not represent the depth values that correspond to the image. So the above GLSL code allows a choice of what is written to the depth buffer at image calculation time (the intermediate stage). In the case of spline path occlusion, the depth buffer needs values that make sense to the GL so that proper occlusion is done by the hardware wrt path splines vs scene objects, the splines are drawn into the scene before the buffershader (texture to quad) pass and after the mathematical scene calculation, in the case of sending the depth value to the EXR image alpha buffer, the value is : dark = far, light = close, and this is done by reading the depth buffer, C++, from the intermediate buffer before the next GL render cycle trashes it.
this method allows:
1. spline path occlusion (GL depth)
http://www.fractalforums.com/fragmentarium/cat-mull-rom-spline-paths-cameraparameter-keyframes/2. XYZ pos feedback (MBenesi spray gun)
http://www.fractalforums.com/fragmentarium/fractal-gun-paintbrushspraypaint-style-modification-of-fractals/30/3. depth to alpha channel (RGBZ EXR files)
http://www.fractalforums.com/fragmentarium/openexr-output-in-fragmentarium-1-0-10/msg86928/on the visual I posted you clearly see that the depth is somewhat radial from the center.
yes, depth values are a sphere with the camera as origin, in order to minimize the radial distortion you need to move the camera back and decrease the FOV to "flatten" the scene, a pretty standard thing commonly used by film and video directors/producers
Anybody stumbled upon a proper implementation of Z-Depth as a distance from the imaging plane towards the scene in Z-Direction?
to get this kind of Z-Depth the scene would have to be rendered with orthogonal projection and that depth would not match a video unless you have a camera that records video orthogonally.
a bit more info on exactly what you are trying to do might be helpful, I'm going to guess you are looking for a flat boolean clipping plane