If you want to view it fullscreen, then you're better off implementing the shader as a post-process effect:
Code:
import viz
viz.go()
viz.add('piazza.osgb')
NEAR = 0.1
FAR = 200.0
from vizfx.postprocess.effect import BaseShaderEffect
class DepthEffect(BaseShaderEffect):
def _getFragmentCode(self):
return """
uniform sampler2D vizpp_InputDepthTex;
uniform float near;
uniform float far;
void main()
{
float d = texture2D(vizpp_InputDepthTex,gl_TexCoord[0].st).r;
float z = (2 * near) / (far + near - d * (far - near));
gl_FragColor = vec4(z,z,z,1.0);
}
"""
def _createUniforms(self):
self.uniforms.addFloat('near',NEAR)
self.uniforms.addFloat('far',FAR)
viz.clip(NEAR,FAR)
import vizfx.postprocess
effect = DepthEffect()
vizfx.postprocess.addEffect(effect)