2023-07-28 21:04:54 +02:00
|
|
|
#version 100
|
|
|
|
precision mediump float;
|
|
|
|
|
|
|
|
varying vec2 texcoord;
|
|
|
|
varying vec3 v_normal;
|
|
|
|
varying float v_position;
|
2023-07-30 14:17:54 +02:00
|
|
|
varying vec3 v_cam_normal;
|
2023-07-28 21:04:54 +02:00
|
|
|
uniform sampler2D u_image0;
|
|
|
|
uniform vec2 fog;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
2023-07-30 14:17:54 +02:00
|
|
|
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);
|
|
|
|
|
2023-07-28 21:04:54 +02:00
|
|
|
float fogAmount = smoothstep(fog.x, fog.y, v_position);
|
|
|
|
|
2023-07-30 14:17:54 +02:00
|
|
|
float light = -dot(vec3(0.1, -1.0, 0.3), v_normal) / 3.0 + 1.0;
|
2023-07-28 21:04:54 +02:00
|
|
|
|
|
|
|
gl_FragColor =
|
|
|
|
texture2D(u_image0, texcoord)
|
|
|
|
* vec4(1.0 - fogAmount, 1.0 - fogAmount, 1.0 - fogAmount, 1.0 - fogAmount)
|
2023-07-30 14:17:54 +02:00
|
|
|
* vec4(light, light, light, 1.0)
|
|
|
|
* vec4(NdotL, NdotL, NdotL, 1.0);
|
2023-07-28 21:04:54 +02:00
|
|
|
if(gl_FragColor.a < 0.0000001)
|
|
|
|
discard;
|
|
|
|
}
|