22 lines
665 B
GLSL
22 lines
665 B
GLSL
#version 330
|
|
|
|
in vec4 pos_model;
|
|
in vec3 vec_normal;
|
|
|
|
out vec4 fragColor;
|
|
|
|
uniform vec4 couleur;
|
|
uniform vec4 lumpos;
|
|
uniform mat4 view;
|
|
uniform vec4 lumcolor;
|
|
|
|
void main() {
|
|
const vec3 vue = vec3(0, 0, -1);
|
|
const vec4 soleil_color = vec4(0.81f, 0.78f, 0.66f, 1.0f);
|
|
vec3 torche = normalize(pos_model.xyz - lumpos.xyz);
|
|
float intensite_lumineuse = clamp(dot(vec_normal, -torche), 0, 1);
|
|
vec3 reflet = (transpose(inverse(view)) * vec4(reflect(torche, vec_normal), 0)).xyz;
|
|
float intensite_specularite = pow(clamp(dot(reflet, -vue), 0, 1), 10);
|
|
|
|
fragColor = intensite_specularite * lumcolor + 0.1 * soleil_color + 0.9 * intensite_lumineuse * couleur;
|
|
}
|