2020-04-05 15:28:22 +02:00
|
|
|
#version 300 es
|
|
|
|
|
|
|
|
// fragment shaders don't have a default precision so we need
|
|
|
|
// to pick one. mediump is a good default. It means "medium precision"
|
|
|
|
precision mediump float;
|
|
|
|
|
2020-08-05 11:24:59 +02:00
|
|
|
in vec4 pos;
|
|
|
|
in vec3 v_surfaceToLight;
|
2020-08-06 23:44:37 +02:00
|
|
|
in vec3 baseColor;
|
|
|
|
in vec3 maxColor;
|
2020-04-05 15:28:22 +02:00
|
|
|
uniform vec4 u_color;
|
|
|
|
|
|
|
|
out vec4 outColor;
|
|
|
|
|
|
|
|
void main() {
|
2020-08-05 11:24:59 +02:00
|
|
|
vec4 fragNormal = normalize(pos);
|
|
|
|
float u_light = 0.3;
|
|
|
|
float light = max(dot(fragNormal.xyz, normalize(v_surfaceToLight).xyz), u_light);
|
|
|
|
float y = pos.z;
|
|
|
|
if (y < 0.0) {
|
|
|
|
y = y * -1.0;
|
|
|
|
}
|
|
|
|
vec3 color = mix(baseColor, maxColor, y);
|
2020-08-01 21:51:54 +02:00
|
|
|
outColor = vec4(color, 1.0);
|
2020-08-05 11:24:59 +02:00
|
|
|
outColor.rgb *= light;
|
2020-04-05 15:28:22 +02:00
|
|
|
}
|