This commit is contained in:
Mylloon 2023-05-21 07:52:10 +02:00
parent 2ca3d3a44f
commit f31b36f199
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 6 additions and 6 deletions

View file

@ -8,21 +8,21 @@ out vec4 fragColor;
const int max = 20; // should change in cpu too
uniform vec4 couleur;
uniform vec4 lum_pos[max];
uniform vec4 lumPos[max];
uniform mat4 view;
uniform vec4 lum_color[max];
uniform vec4 lumColor[max];
void main() {
const vec3 vue = vec3(0, 0, -1);
const vec4 soleil_color = vec4(0.81f, 0.78f, 0.66f, 1.0f);
for(int i = 0; i < max; i++) {
vec3 torche = normalize(pos_model.xyz - lum_pos[i].xyz);
vec3 torche = normalize(pos_model.xyz - lumPos[i].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);
vec4 color = intensite_specularite * lum_color[i] + 0.1 * soleil_color + 0.9 * intensite_lumineuse * couleur;
vec4 color = intensite_specularite * lumColor[i] + 0.1 * soleil_color + 0.9 * intensite_lumineuse * couleur;
if(i == 0) {
fragColor = color;
} else {

View file

@ -172,8 +172,8 @@ static void draw(void) {
/* On devrait donner HEROS_NUMBER mais pour éviter de ne plus rien voir avec
* les lumières, on en donne que 20 */
glUniform4fv(glGetUniformLocation(_pId, "lum_pos"), 20, (float *)lumpos);
glUniform4fv(glGetUniformLocation(_pId, "lum_color"), 20, (float *)lumcolor);
glUniform4fv(glGetUniformLocation(_pId, "lumPos"), 20, (float *)lumpos);
glUniform4fv(glGetUniformLocation(_pId, "lumColor"), 20, (float *)lumcolor);
deplacement += (float)(0.4 * M_PI * dt);
glUseProgram(0);