Created
January 25, 2013 17:51
-
-
Save PierrickKoch/4636456 to your computer and use it in GitHub Desktop.
work in progress on z-buffer depth linerization shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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