#version 100 precision mediump float; varying vec2 texcoord; varying vec3 v_normal; varying float v_position; varying vec3 v_cam_normal; uniform sampler2D u_image0; uniform vec2 fog; void main() { vec3 N = normalize(v_cam_normal); vec3 L = vec3(0.0, 0.0, 1.0); float NdotL = dot(N, L)/ 3.0 + 1.0 + (1.0/3.0); float fogAmount = smoothstep(fog.x, fog.y, v_position); float light = -dot(vec3(0.1, -1.0, 0.3), v_normal) / 3.0 + 1.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) * vec4(NdotL, NdotL, NdotL, 1.0); if(gl_FragColor.a < 0.0000001) discard; }