Skip to content

Instantly share code, notes, and snippets.

@iodiot
Created March 30, 2014 09:46
Show Gist options
  • Save iodiot/9870326 to your computer and use it in GitHub Desktop.
Save iodiot/9870326 to your computer and use it in GitHub Desktop.
uniform sampler2D texture;
uniform vec3 tint;
varying vec2 texCoord;
void main() {
vec4 texel = texture2D(texture, texCoord);
if (texel.a < 0.5) {
discard;
}
float fogStart = 1.0;
float fogEnd = 50.0;
float fogDistance = gl_FragCoord.z / gl_FragCoord.w;
float fogAmount = (fogDistance - fogStart) / (fogEnd - fogStart);
texel.xyz = mix(texel.xyz, vec3(0.0), clamp(fogAmount, 0.0, 1.0));
gl_FragColor = texel;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment