m2-ar-projet/shaders/main.frag

23 lines
478 B
GLSL
Raw Normal View History

2021-01-02 17:45:42 +01:00
varying vec3 norm;
varying vec2 uv;
varying vec3 frag_pos;
2020-12-28 17:36:45 +01:00
uniform sampler2D tex;
2021-01-03 17:10:26 +01:00
uniform bool highlight;
2020-12-28 17:36:45 +01:00
void main() {
vec3 light_col = vec3(1, .964, .783);
vec3 ambient = light_col * .2;
vec3 light_dir = normalize(vec3(5, 10, -8));
float diff = max(dot(normalize(norm), light_dir), 0.0);
vec3 diffuse = diff * light_col;
2021-01-03 17:10:26 +01:00
vec4 col = texture2D(tex, uv) * vec4(ambient + diffuse, 1);
if (highlight) {
col = mix(col, vec4(1, 0, 0, 1), .5);
}
gl_FragColor = col;
2020-12-28 17:36:45 +01:00
}