Skip to content

Instantly share code, notes, and snippets.

@PierrickKoch
Created January 25, 2013 17:51
Show Gist options
  • Select an option

  • Save PierrickKoch/4636456 to your computer and use it in GitHub Desktop.

Select an option

Save PierrickKoch/4636456 to your computer and use it in GitHub Desktop.
work in progress on z-buffer depth linerization shader
float Znear = 1.0;
float Zfar = 20.0;
float Q = Zfar / ( Zfar - Znear );
float inv_Zfar = 1.0 / Zfar;
uniform sampler2D bgl_DepthTexture;
void main()
{
// Sampling
float depth = texture2D(bgl_DepthTexture, gl_TexCoord[0].xy).r;
// Linearization
float z_e = inv_Zfar / (Q - depth);
gl_FragColor = vec4(vec3(z_e), 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment