Initial Commit
This commit is contained in:
commit
54eaed1ca0
284 changed files with 55022 additions and 0 deletions
56
src/shader/fs_blinnPhong.glsl
Normal file
56
src/shader/fs_blinnPhong.glsl
Normal file
|
@ -0,0 +1,56 @@
|
|||
#version 410 core
|
||||
in vec3 position;
|
||||
in vec3 normal;
|
||||
|
||||
uniform vec3 cameraView;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
// Couleurs
|
||||
vec3 materialColor = vec3( 0.4, 1, 0.6);
|
||||
vec3 specularColor = vec3( 1, 1, 1);
|
||||
vec3 lightColor = vec3(0.95, 0.98, 1);
|
||||
|
||||
// Position de la lumière
|
||||
vec3 frontLightPos = vec3( 0, 0, 1);
|
||||
float specCoef = 128;
|
||||
|
||||
|
||||
/* Bibliographie:
|
||||
* https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model
|
||||
* http://www.opengl-tutorial.org/fr/beginners-tutorials/tutorial-8-basic-shading/
|
||||
*/
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 frontLight = frontLightPos - position;
|
||||
float distance = pow(length(frontLight), 2);
|
||||
frontLight = normalize(frontLight);
|
||||
vec3 normalizedNormal = normalize(normal);
|
||||
|
||||
// Paramètres de réflexion initiaux
|
||||
float lambertian = max(dot(frontLight, normalizedNormal), 0.0);
|
||||
float specularFactor = 0;
|
||||
|
||||
/* Ambient: simule l'éclairage indirect */
|
||||
vec3 ambient = vec3(0.15, 0.15, 0.15) * materialColor;
|
||||
|
||||
/* Diffuse: "couleur" de l'objet dans la zone illuminée */
|
||||
// Cosinus entre la normale et la direction de la lumière (positif)
|
||||
// - lumière à la verticale = 1
|
||||
// - lumière perpendiculaire ou derrière = 0
|
||||
float cosTheta = clamp( dot( normalizedNormal, frontLight ), 0, 1 );
|
||||
vec3 diffuse = materialColor * lightColor * cosTheta;
|
||||
|
||||
/* Specular: réflexion */
|
||||
if (lambertian > 0.0) {
|
||||
vec3 viewDir = normalize(-cameraView);
|
||||
vec3 halfDir = normalize(frontLight + viewDir);
|
||||
float specAngle = max(dot(halfDir, normalizedNormal), 0.0);
|
||||
specularFactor = pow(specAngle, specCoef);
|
||||
}
|
||||
vec3 specular = specularColor * lightColor * specularFactor;
|
||||
|
||||
/* Couleur = Ambient + Diffuse + Specular */
|
||||
color = vec4(ambient + diffuse + specular, 1);
|
||||
}
|
33
src/shader/fs_difference.glsl
Normal file
33
src/shader/fs_difference.glsl
Normal file
|
@ -0,0 +1,33 @@
|
|||
#version 410 core
|
||||
in vec3 position;
|
||||
uniform vec3 center;
|
||||
uniform float radius;
|
||||
uniform float errorMax;
|
||||
out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Colors
|
||||
vec4 bleu = vec4(0.094, 0, 1.0, 1.0);
|
||||
vec4 vert = vec4(0.07, 1.0, 0, 1.0);
|
||||
vec4 jaune = vec4(0.94, 1.0, 0, 1.0);
|
||||
vec4 rouge = vec4(1.0, 0, 0, 1.0);
|
||||
|
||||
// Compute Value
|
||||
float value = smoothstep(0.0, errorMax, abs(length(center - position) - radius) / radius);
|
||||
color = bleu; // Init color
|
||||
|
||||
// Heatmap gradient
|
||||
if (value < 0.85) {
|
||||
value = smoothstep(0.0, 0.85, value);
|
||||
color = mix(bleu, vert, value);
|
||||
}
|
||||
else if (value < 0.95) {
|
||||
value = smoothstep(0.85, 0.95, value);
|
||||
color = mix(vert, jaune, value);
|
||||
}
|
||||
else {
|
||||
value = smoothstep(0.95, 1.0, value);
|
||||
color = mix(jaune, rouge, value);
|
||||
}
|
||||
}
|
7
src/shader/fs_diffuse.glsl
Normal file
7
src/shader/fs_diffuse.glsl
Normal file
|
@ -0,0 +1,7 @@
|
|||
#version 410 core
|
||||
in vec3 normal;
|
||||
out vec4 color;
|
||||
void main()
|
||||
{
|
||||
color = vec4(vec3(clamp(dot(normalize(normal), vec3(0, 0,1)), 0, 1)), 1.0);
|
||||
}
|
7
src/shader/fs_normals.glsl
Normal file
7
src/shader/fs_normals.glsl
Normal file
|
@ -0,0 +1,7 @@
|
|||
#version 410 core
|
||||
in vec3 normal;
|
||||
out vec4 color;
|
||||
void main()
|
||||
{
|
||||
color = vec4(normalize(normal)*0.5+0.5, 1.0);
|
||||
}
|
15
src/shader/vs_default.glsl
Normal file
15
src/shader/vs_default.glsl
Normal file
|
@ -0,0 +1,15 @@
|
|||
#version 410 core
|
||||
layout (location = 0) in vec3 iposition;
|
||||
layout (location = 1) in vec3 inormal;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
out vec3 normal;
|
||||
out vec3 position;
|
||||
void main()
|
||||
{
|
||||
// Note that we read the multiplication from right to left
|
||||
gl_Position = projection * view * model * vec4(iposition, 1.0f);
|
||||
normal = inormal;
|
||||
position = iposition;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue