From 6be843c8bdd1350e95f4c2ee0b2d7c54ead5aead Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 8 May 2023 15:11:07 +0200 Subject: [PATCH] lum color from cpu --- shaders/manif.fs | 3 ++- src/manif.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/shaders/manif.fs b/shaders/manif.fs index 03829a0..a797592 100644 --- a/shaders/manif.fs +++ b/shaders/manif.fs @@ -8,6 +8,7 @@ out vec4 fragColor; uniform vec4 couleur; uniform vec4 lumpos; uniform mat4 view; +uniform vec4 lumcolor; void main() { const vec3 vue = vec3(0, 0, -1); @@ -17,5 +18,5 @@ void main() { 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 * vec4(1.0f, 0.0f, 0.0f, 1.0f) + 0.1 * soleil_color + 0.9 * intensite_lumineuse * couleur; + fragColor = intensite_specularite * lumcolor + 0.1 * soleil_color + 0.9 * intensite_lumineuse * couleur; } diff --git a/src/manif.c b/src/manif.c index 2e23b23..b980898 100644 --- a/src/manif.c +++ b/src/manif.c @@ -52,8 +52,10 @@ static void draw(void) { GLint couleur_gpu = glGetUniformLocation(_pId, "couleur"); static double deplacement = 0; - const GLfloat lumpos[] = {1, (GLfloat)(2 + 2 * sin(deplacement)), 1, 1}; + const GLfloat lumpos[] = {1, (GLfloat)(2 + 2 * sin(deplacement)), 1, 1}, + lumcolor[] = {1, 0, 0, 1}; glUniform4fv(glGetUniformLocation(_pId, "lumpos"), 1, lumpos); + glUniform4fv(glGetUniformLocation(_pId, "lumcolor"), 1, lumcolor); bindAndLoadf(matrix_proj); GLfloat ratio = (GLfloat)_dims[0] / (GLfloat)_dims[1];