lum color from cpu
This commit is contained in:
parent
f9ebf9066c
commit
6be843c8bd
2 changed files with 5 additions and 2 deletions
|
@ -8,6 +8,7 @@ out vec4 fragColor;
|
||||||
uniform vec4 couleur;
|
uniform vec4 couleur;
|
||||||
uniform vec4 lumpos;
|
uniform vec4 lumpos;
|
||||||
uniform mat4 view;
|
uniform mat4 view;
|
||||||
|
uniform vec4 lumcolor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
const vec3 vue = vec3(0, 0, -1);
|
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;
|
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 * 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,10 @@ static void draw(void) {
|
||||||
GLint couleur_gpu = glGetUniformLocation(_pId, "couleur");
|
GLint couleur_gpu = glGetUniformLocation(_pId, "couleur");
|
||||||
static double deplacement = 0;
|
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, "lumpos"), 1, lumpos);
|
||||||
|
glUniform4fv(glGetUniformLocation(_pId, "lumcolor"), 1, lumcolor);
|
||||||
|
|
||||||
bindAndLoadf(matrix_proj);
|
bindAndLoadf(matrix_proj);
|
||||||
GLfloat ratio = (GLfloat)_dims[0] / (GLfloat)_dims[1];
|
GLfloat ratio = (GLfloat)_dims[0] / (GLfloat)_dims[1];
|
||||||
|
|
Reference in a new issue