#version 100 precision mediump float; varying vec2 texcoord; varying vec3 v_normal; varying float v_position; uniform sampler2D u_image0; uniform vec2 fog; void main() { float fogAmount = smoothstep(fog.x, fog.y, v_position); float light = -dot(vec3(0.0, -1.0, 0.0), v_normal) / 3.0 + 1.0 + (1.0/3.0); gl_FragColor = texture2D(u_image0, texcoord) * vec4(1.0 - fogAmount, 1.0 - fogAmount, 1.0 - fogAmount, 1.0 - fogAmount) * vec4(light, light, light, 1.0); if(gl_FragColor.a < 0.0000001) discard; }