Skip to content

Instantly share code, notes, and snippets.

@Akaricchi
Created January 15, 2012 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akaricchi/1616569 to your computer and use it in GitHub Desktop.
Save Akaricchi/1616569 to your computer and use it in GitHub Desktop.
#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