Created
January 15, 2012 17:50
-
-
Save Akaricchi/1616569 to your computer and use it in GitHub Desktop.
This file contains 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
#version 110 | |
void main(void) { | |
gl_Position = ftransform(); | |
gl_FrontColor = gl_Color; | |
gl_TexCoord[0] = gl_MultiTexCoord0; | |
} | |
%% -- FRAG | |
#version 110 | |
uniform sampler2D tex; | |
uniform sampler2D depth; | |
uniform float start; | |
uniform float end; | |
uniform vec4 fog_color; | |
void main(void) { | |
vec2 pos = vec2(gl_TexCoord[0]); | |
float z = 1.0/texture2D(depth, pos).x; | |
float f = (end - z)/(end-start); | |
vec4 color; | |
color = texture2D(tex,pos); | |
color *= f; | |
color += (1.0-f)*fog_color; | |
gl_FragColor = color; | |
// gl_FragColor = vec4(z); | |
// gl_FragColor = 0.5*texture2D(tex, pos); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment