This commit is contained in:
Mylloon 2023-05-12 15:59:45 +02:00
parent b976dbb707
commit 263c83843c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -5,7 +5,7 @@ in vec3 vec_normal;
out vec4 fragColor; out vec4 fragColor;
const int max = 2; // should change in cpu too const int max = 1; // should change in cpu too
uniform vec4 couleur; uniform vec4 couleur;
uniform vec4 lum_pos[max]; uniform vec4 lum_pos[max];
@ -16,14 +16,12 @@ void main() {
const vec3 vue = vec3(0, 0, -1); const vec3 vue = vec3(0, 0, -1);
const vec4 soleil_color = vec4(0.81f, 0.78f, 0.66f, 1.0f); const vec4 soleil_color = vec4(0.81f, 0.78f, 0.66f, 1.0f);
fragColor = vec4(1);
for(int i = 0; i < max; i++) { for(int i = 0; i < max; i++) {
vec3 torche = normalize(pos_model.xyz - lum_pos[i].xyz); vec3 torche = normalize(pos_model.xyz - lum_pos[i].xyz);
float intensite_lumineuse = clamp(dot(vec_normal, -torche), 0., 1.); float intensite_lumineuse = clamp(dot(vec_normal, -torche), 0., 1.);
vec3 reflet = (transpose(inverse(view)) * vec4(reflect(torche, vec_normal), 0)).xyz; vec3 reflet = (transpose(inverse(view)) * vec4(reflect(torche, vec_normal), 0)).xyz;
float intensite_specularite = pow(clamp(dot(reflet, -vue), 0., 1.), 10); float intensite_specularite = pow(clamp(dot(reflet, -vue), 0., 1.), 10);
fragColor *= intensite_specularite * lum_color[i] + 0.1 * soleil_color + 0.9 * intensite_lumineuse * couleur; fragColor = mix(fragColor, intensite_specularite * lum_color[i] + 0.1 * soleil_color + 0.9 * intensite_lumineuse * couleur, 0.5);
} }
} }